From ff0f0875135a7842e78fae002ee1187892f9405b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 16 Dec 2010 04:13:21 +0100 Subject: [PATCH] svga: Ensure that the wrong vdecls don't get used in swtnl path The draw module set new state that didn't require swtnl which caused need_swtnl to be unset. This caused the call from to svga_update_state(svga, SVGA_STATE_SWTNL_DRAW) from the vbuf backend to overwrite the vdecls we setup there to be overwritten with the real buffers vdecls. --- src/gallium/drivers/svga/svga_context.h | 5 +++++ src/gallium/drivers/svga/svga_state_need_swtnl.c | 8 ++++++++ src/gallium/drivers/svga/svga_swtnl_draw.c | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 04e281a506d..d4970908b1e 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -288,6 +288,11 @@ struct svga_sw_state boolean need_swvfetch; boolean need_pipeline; boolean need_swtnl; + + /* Flag to make sure that need sw is on while + * updating state within a swtnl call. + */ + boolean in_swtnl_draw; }; diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index 99263d82e13..8ba5ac8cdb4 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -175,6 +175,14 @@ static int update_need_swtnl( struct svga_context *svga, need_swtnl = 1; } + /* + * Some state changes the draw module does makes us belive we + * we don't need swtnl. This causes the vdecl code to pickup + * the wrong buffers and vertex formats. Try trivial/line-wide. + */ + if (svga->state.sw.in_swtnl_draw) + need_swtnl = 1; + if (need_swtnl != svga->state.sw.need_swtnl) { SVGA_DBG(DEBUG_SWTNL|DEBUG_PERF, "%s: need_swvfetch %s, need_pipeline %s\n", diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index d9039845819..05d86e1fb16 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -51,6 +51,9 @@ svga_swtnl_draw_vbo(struct svga_context *svga, assert(svga->state.sw.need_swtnl); assert(draw); + /* Make sure that the need_swtnl flag does not go away */ + svga->state.sw.in_swtnl_draw = TRUE; + ret = svga_update_state(svga, SVGA_STATE_SWTNL_DRAW); if (ret) { svga_context_flush(svga, NULL); @@ -119,6 +122,9 @@ svga_swtnl_draw_vbo(struct svga_context *svga, pipe_buffer_unmap(&svga->pipe, cb_transfer); } + /* Now safe to remove the need_swtnl flag in any update_state call */ + svga->state.sw.in_swtnl_draw = FALSE; + return ret; } -- 2.30.2