From 23ea840f0805fe6ac1f9bec38aeed4e9614f1f3e Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 17 Jan 2019 11:17:27 +0100 Subject: [PATCH] renderer: walk along samplers_used_mask instead of view-array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The result is the same, we just skip a bit quicker over unused entries. Signed-off-by: Erik Faye-Lund Reviewed-by: Stéphane Marchesin --- src/vrend_renderer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 43c2ed3..3f90c90 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -3620,15 +3620,14 @@ static void vrend_draw_bind_samplers_shader(struct vrend_context *ctx, int *sampler_id) { int index = 0; - for (int i = 0; i < ctx->sub->views[shader_type].num_views; i++) { + uint32_t mask = ctx->sub->prog->samplers_used_mask[shader_type]; + while (mask) { + int i = u_bit_scan(&mask); struct vrend_sampler_view *tview = ctx->sub->views[shader_type].views[i]; if (!tview) continue; - if (!(ctx->sub->prog->samplers_used_mask[shader_type] & (1 << i))) - continue; - if (ctx->sub->prog->samp_locs[shader_type]) glUniform1i(ctx->sub->prog->samp_locs[shader_type][index], *sampler_id);