From 603699f169a4966075d5c265af4e22e6e3b223e8 Mon Sep 17 00:00:00 2001 From: Ryan Neph Date: Wed, 18 Aug 2021 14:23:49 -0700 Subject: [PATCH] vrend: fix sampler state updates misreporting next_sampler_id Discovered while investigating broken floor tile rendering in Factorio (game). Skipping increment of next_sampler_id, regardless of dirty status, results in collision with caller's use of next_sampler_id for additional samplers. Closes: https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/227 Fixes: c08c8419 ("vrend: use helper pointers in draw_bind_samplers_shader") Signed-off-by: Ryan Neph Reviewed-by: Gert Wollny --- src/vrend_renderer.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 9a2e766..a49ec66 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -4301,11 +4301,8 @@ static int vrend_draw_bind_samplers_shader(struct vrend_sub_context *sub_ctx, while (mask) { int i = u_bit_scan(&mask); - if (!(dirty & (1 << i))) - continue; - struct vrend_sampler_view *tview = sviews->views[i]; - if (tview) { + if ((dirty & (1 << i)) && tview) { if (sub_ctx->prog->shadow_samp_mask[shader_type] & (1 << i)) { glUniform4f(sub_ctx->prog->shadow_samp_mask_locs[shader_type][index], (tview->gl_swizzle[0] == GL_ZERO || tview->gl_swizzle[0] == GL_ONE) ? 0.0 : 1.0, @@ -4317,6 +4314,7 @@ static int vrend_draw_bind_samplers_shader(struct vrend_sub_context *sub_ctx, tview->gl_swizzle[1] == GL_ONE ? 1.0 : 0.0, tview->gl_swizzle[2] == GL_ONE ? 1.0 : 0.0, tview->gl_swizzle[3] == GL_ONE ? 1.0 : 0.0); + index++; } if (tview->texture) { @@ -4349,7 +4347,6 @@ static int vrend_draw_bind_samplers_shader(struct vrend_sub_context *sub_ctx, } } next_sampler_id++; - index++; } sub_ctx->n_samplers[shader_type] = n_samplers;