aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-05-09 23:33:27 +0200
committerSamuel Pitoiset <[email protected]>2017-05-10 12:14:17 +0200
commit820966f9bc79640ba9f1d3858359c001e3583bb2 (patch)
treeedabaf8040c37d5665d4de18a83a9ef88e6e2763 /src
parent6a1f324e4a711d5c7258ea86132cd8d07c610cbe (diff)
mesa: use u_bit_scan() in update_program_texture_state()
The check in update_single_program_texture() can also be removed. v2: - remove unused 's' variable Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/texstate.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 830b230b5d7..1aac3cdbd8b 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -620,9 +620,6 @@ update_single_program_texture(struct gl_context *ctx, struct gl_program *prog,
struct gl_sampler_object *sampler;
int unit;
- if (!(prog->SamplersUsed & (1 << s)))
- return NULL;
-
unit = prog->SamplerUnits[s];
texUnit = &ctx->Texture.Unit[unit];
@@ -676,16 +673,15 @@ update_program_texture_state(struct gl_context *ctx, struct gl_program **prog,
int i;
for (i = 0; i < MESA_SHADER_STAGES; i++) {
- int s;
+ GLbitfield mask;
if (!prog[i])
continue;
- /* We can't only do the shifting trick as the loop condition because if
- * sampler 31 is active, the next iteration tries to shift by 32, which is
- * undefined.
- */
- for (s = 0; s < MAX_SAMPLERS && (1 << s) <= prog[i]->SamplersUsed; s++) {
+ mask = prog[i]->SamplersUsed;
+
+ while (mask) {
+ const int s = u_bit_scan(&mask);
struct gl_texture_object *texObj;
texObj = update_single_program_texture(ctx, prog[i], s);