asahi: Fix Z32S8 harder
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 29 Nov 2022 02:30:49 +0000 (21:30 -0500)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 11 Dec 2022 02:51:04 +0000 (21:51 -0500)
Fixes dEQP-GLES3.functional.texture.format.sized.2d.depth32f_stencil8_pot after
stencil texturing broke it.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20123>

src/gallium/drivers/asahi/agx_state.c

index ae140c2..8caa4aa 100644 (file)
@@ -624,11 +624,19 @@ agx_create_sampler_view(struct pipe_context *pctx,
    struct pipe_resource *texture = orig_texture;
    enum pipe_format format = state->format;
 
-   /* Use stencil attachment, separate stencil always used on G13 */
-   if (rsrc->separate_stencil) {
-      rsrc = rsrc->separate_stencil;
-      texture = &rsrc->base;
-      format = texture->format;
+   const struct util_format_description *desc = util_format_description(format);
+
+   /* Separate stencil always used on G13, so we need to fix up for Z32S8 */
+   if (util_format_has_stencil(desc) && rsrc->separate_stencil) {
+      if (util_format_has_depth(desc)) {
+         /* Reinterpret as the depth-only part */
+         format = util_format_get_depth_only(format);
+      } else {
+         /* Use the stencil-only-part */
+         rsrc = rsrc->separate_stencil;
+         texture = &rsrc->base;
+         format = texture->format;
+      }
    }
 
    /* Save off the resource that we actually use, with the stencil fixed up */