From 588371b77229324c91a59180a2d623dde9830957 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 10 Jun 2017 21:59:07 +0200 Subject: [PATCH] st/mesa: simplify update_shader_samplers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Timothy Arceri Reviewed-by: Nicolai Hähnle --- src/mesa/state_tracker/st_atom_sampler.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 5f3f852..2a73535 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -265,38 +265,29 @@ update_shader_samplers(struct st_context *st, enum pipe_shader_type shader_stage, const struct gl_program *prog, struct pipe_sampler_state *samplers, - unsigned *num_samplers) + unsigned *out_num_samplers) { GLbitfield samplers_used = prog->SamplersUsed; GLbitfield free_slots = ~prog->SamplersUsed; GLbitfield external_samplers_used = prog->ExternalSamplersUsed; - GLuint unit; - const GLuint old_max = *num_samplers; + unsigned unit, num_samplers; const struct pipe_sampler_state *states[PIPE_MAX_SAMPLERS]; if (samplers_used == 0x0) return; - *num_samplers = 0; + num_samplers = util_last_bit(samplers_used); /* loop over sampler units (aka tex image units) */ for (unit = 0; samplers_used; unit++, samplers_used >>= 1) { struct pipe_sampler_state *sampler = samplers + unit; if (samplers_used & 1) { - const GLuint texUnit = prog->SamplerUnits[unit]; - - st_convert_sampler_from_unit(st, sampler, texUnit); + st_convert_sampler_from_unit(st, sampler, prog->SamplerUnits[unit]); states[unit] = sampler; - *num_samplers = unit + 1; - } - else if (samplers_used != 0 || unit < old_max) { + } else { states[unit] = NULL; } - else { - /* if we've reset all the old samplers and we have no more new ones */ - break; - } } /* For any external samplers with multiplaner YUV, stuff the additional @@ -331,10 +322,11 @@ update_shader_samplers(struct st_context *st, break; } - *num_samplers = MAX2(*num_samplers, extra + 1); + num_samplers = MAX2(num_samplers, extra + 1); } - cso_set_samplers(st->cso_context, shader_stage, *num_samplers, states); + cso_set_samplers(st->cso_context, shader_stage, num_samplers, states); + *out_num_samplers = num_samplers; } -- 2.7.4