From fef9ef48dd3a7c5d74c09b3e7a6d4ca13c616cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Pi=C3=B1eiro?= Date: Thu, 11 Nov 2021 13:04:36 +0100 Subject: [PATCH] gallium/u_blitter: clean up texcoords ZW when filling up just XY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid a scenario like this: * One blit needed the four components => XYZW filled up with 4 values * Following blit needing two components => ZW uses the previous values We detected this using the v3d driver with the arb_framebuffer_srgb-blit test, specifically: ./bin/arb_framebuffer_srgb-blit texture linear_to_srgb msaa enabled render -auto -fbo The main linear to srgb with msaa (not doing the resolve yet) blit requires the four components. At the end (after a resolve copy), the test uses glReadPixels, and internally it uses the blitter with two components, but the shader still uses lod on the texel fetch, so it gets the one used for the main blit, when it should be zero. Right now v3d works fine even with that wrong value, and I assume that any other driver too. But we can't ensure that would keep happening on the future, so let's use correct values. Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_blitter.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index f23474325e1..3eae80e9d8b 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -1424,8 +1424,16 @@ void util_blitter_draw_rectangle(struct blitter_context *blitter, ctx->vertices[i][1][2] = attrib->texcoord.z; ctx->vertices[i][1][3] = attrib->texcoord.w; } - FALLTHROUGH; + set_texcoords_in_vertices(attrib, &ctx->vertices[0][1][0], 8); + break; case UTIL_BLITTER_ATTRIB_TEXCOORD_XY: + /* We clean-up the ZW components, just in case we used before XYZW, + * to avoid feeding in the shader with wrong values (like on the lod) + */ + for (i = 0; i < 4; i++) { + ctx->vertices[i][1][2] = 0; + ctx->vertices[i][1][3] = 0; + } set_texcoords_in_vertices(attrib, &ctx->vertices[0][1][0], 8); break;