diff options
author | Brian Paul <[email protected]> | 2012-08-06 08:35:20 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-08-06 08:50:19 -0600 |
commit | 819e786339fe0eebcd6e8e0ec9e501da548846ba (patch) | |
tree | 717c6b2aa4aa667be45e9ecce3205a91772574dc | |
parent | 2aac0d145a3f03572f19fd913bed2e951d543030 (diff) |
st/mesa: massage update_vertex_samplers() code
...to look like update_fragment_samplers() code, as with the previous
commit. The next step would be to merge the two functions.
Reviewed-by: José Fonseca <[email protected]>
-rw-r--r-- | src/mesa/state_tracker/st_atom_sampler.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index e8348327326..c219b21cb07 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -201,27 +201,32 @@ update_vertex_samplers(struct st_context *st) const struct gl_context *ctx = st->ctx; struct gl_vertex_program *vprog = ctx->VertexProgram._Current; GLuint su; + GLuint samplers_used = vprog->Base.SamplersUsed; + const GLuint old_max = st->state.num_vertex_samplers; if (st->state.num_vertex_samplers == 0 && vprog->Base.SamplersUsed == 0) return; + st->state.num_vertex_samplers = 0; /* loop over sampler units (aka tex image units) */ - for (su = 0; su < ctx->Const.MaxVertexTextureImageUnits; su++) { + for (su = 0; su < ctx->Const.MaxVertexTextureImageUnits; su++, samplers_used >>= 1) { struct pipe_sampler_state *sampler = st->state.vertex_samplers + su; - if (vprog->Base.SamplersUsed & (1 << su)) { - GLuint texUnit; - - texUnit = vprog->Base.SamplerUnits[su]; + if (samplers_used & 1) { + GLuint texUnit = vprog->Base.SamplerUnits[su]; - convert_sampler(st, sampler, texUnit); + convert_sampler(st, sampler, texUnit); - st->state.num_vertex_samplers = su + 1; + st->state.num_vertex_samplers = su + 1; - cso_single_sampler(st->cso_context, PIPE_SHADER_VERTEX, su, sampler); + cso_single_sampler(st->cso_context, PIPE_SHADER_VERTEX, su, sampler); + } + else if (samplers_used != 0 || su < old_max) { + cso_single_sampler(st->cso_context, PIPE_SHADER_VERTEX, su, NULL); } else { - cso_single_sampler(st->cso_context, PIPE_SHADER_VERTEX, su, NULL); + /* if we've reset all the old samplers and we have no more new ones */ + break; } } cso_single_sampler_done(st->cso_context, PIPE_SHADER_VERTEX); @@ -235,7 +240,10 @@ update_fragment_samplers(struct st_context *st) struct gl_fragment_program *fprog = ctx->FragmentProgram._Current; GLuint su; GLuint samplers_used = fprog->Base.SamplersUsed; - GLuint old_max = st->state.num_fragment_samplers; + const GLuint old_max = st->state.num_fragment_samplers; + + if (st->state.num_fragment_samplers == 0 && fprog->Base.SamplersUsed == 0) + return; st->state.num_fragment_samplers = 0; @@ -244,22 +252,18 @@ update_fragment_samplers(struct st_context *st) struct pipe_sampler_state *sampler = st->state.fragment_samplers + su; if (samplers_used & 1) { - GLuint texUnit; - - texUnit = fprog->Base.SamplerUnits[su]; + GLuint texUnit = fprog->Base.SamplerUnits[su]; convert_sampler(st, sampler, texUnit); st->state.num_fragment_samplers = su + 1; - /*printf("%s su=%u non-null\n", __FUNCTION__, su);*/ cso_single_sampler(st->cso_context, PIPE_SHADER_FRAGMENT, su, sampler); } else if (samplers_used != 0 || su < old_max) { - /*printf("%s su=%u null\n", __FUNCTION__, su);*/ cso_single_sampler(st->cso_context, PIPE_SHADER_FRAGMENT, su, NULL); } else { - /* if we've reset all the old views and we have no more new ones */ + /* if we've reset all the old samplers and we have no more new ones */ break; } } |