Mesa (main): gallium/u_blitter: clean up texcoords ZW when filling up just XY

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 16 09:45:39 UTC 2021


Module: Mesa
Branch: main
Commit: fef9ef48dd3a7c5d74c09b3e7a6d4ca13c616cca
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fef9ef48dd3a7c5d74c09b3e7a6d4ca13c616cca

Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date:   Thu Nov 11 13:04:36 2021 +0100

gallium/u_blitter: clean up texcoords ZW when filling up just XY

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 <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13753>

---

 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;
 



More information about the mesa-commit mailing list