diff options
author | José Fonseca <[email protected]> | 2010-01-03 00:47:30 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-01-03 00:50:13 +0000 |
commit | cdb445f3a9285e2d8f042a07021ade78b94e0156 (patch) | |
tree | de16097633746d5ce2d273ca9751b5cbf804153f /src/gallium/drivers/svga/svga_state_vs.c | |
parent | 904917dcc67e15830a4fe106a243eb57dde985ea (diff) |
svga: Use a shader id as low as possible.
Diffstat (limited to 'src/gallium/drivers/svga/svga_state_vs.c')
-rw-r--r-- | src/gallium/drivers/svga/svga_state_vs.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c index a947745732c..6cf51434d7f 100644 --- a/src/gallium/drivers/svga/svga_state_vs.c +++ b/src/gallium/drivers/svga/svga_state_vs.c @@ -26,6 +26,7 @@ #include "pipe/p_inlines.h" #include "pipe/p_defines.h" #include "util/u_math.h" +#include "util/u_bitmask.h" #include "translate/translate.h" #include "svga_context.h" @@ -77,8 +78,12 @@ static enum pipe_error compile_vs( struct svga_context *svga, goto fail; } + result->id = util_bitmask_add(svga->vs_bm); + if(result->id == UTIL_BITMASK_INVALID_INDEX) + goto fail; + ret = SVGA3D_DefineShader(svga->swc, - svga->state.next_vs_id, + result->id, SVGA3D_SHADERTYPE_VS, result->tokens, result->nr_tokens * sizeof result->tokens[0]); @@ -86,14 +91,16 @@ static enum pipe_error compile_vs( struct svga_context *svga, goto fail; *out_result = result; - result->id = svga->state.next_vs_id++; result->next = vs->base.results; vs->base.results = result; return PIPE_OK; fail: - if (result) + if (result) { + if (result->id != UTIL_BITMASK_INVALID_INDEX) + util_bitmask_clear( svga->vs_bm, result->id ); svga_destroy_shader_result( result ); + } return ret; } @@ -141,12 +148,14 @@ static int emit_hw_vs( struct svga_context *svga, id = result->id; } - if (id != svga->state.hw_draw.shader_id[PIPE_SHADER_VERTEX]) { - ret = SVGA3D_SetShader(svga->swc, - SVGA3D_SHADERTYPE_VS, - id ); - if (ret) - return ret; + if (result != svga->state.hw_draw.vs) { + if (id != svga->state.hw_draw.shader_id[PIPE_SHADER_VERTEX]) { + ret = SVGA3D_SetShader(svga->swc, + SVGA3D_SHADERTYPE_VS, + id ); + if (ret) + return ret; + } svga->dirty |= SVGA_NEW_VS_RESULT; svga->state.hw_draw.shader_id[PIPE_SHADER_VERTEX] = id; |