From a41d73278497abc61d111dcf718cd82a73ad680d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 2 Sep 2022 22:23:05 -0400 Subject: [PATCH] asahi: Fix depth for cube maps For cube maps, depth=1 in the hardware (but 6 in Gallium). Likewise for cube map arrays, depth=n in the hardware (but 6n in Gallium). We need to divide to compensate. This will be relevant for cube map arrays in the future -- add the dimension XML for cube map arrays too. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/cmdbuf.xml | 1 + src/gallium/drivers/asahi/agx_state.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/asahi/lib/cmdbuf.xml b/src/asahi/lib/cmdbuf.xml index 66fdbc8684b..ee58bddddd7 100644 --- a/src/asahi/lib/cmdbuf.xml +++ b/src/asahi/lib/cmdbuf.xml @@ -205,6 +205,7 @@ + diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index c1bf2cf5de8..3116b345efa 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -476,10 +476,16 @@ agx_create_sampler_view(struct pipe_context *pctx, cfg.unk_mipmapped = rsrc->mipmapped; cfg.srgb_2_channel = cfg.srgb && util_format_colormask(desc) == 0x3; - if (state->target == PIPE_TEXTURE_3D) + if (state->target == PIPE_TEXTURE_3D) { cfg.depth = u_minify(texture->depth0, level); - else - cfg.depth = state->u.tex.last_layer - state->u.tex.first_layer + 1; + } else { + unsigned layers = state->u.tex.last_layer - state->u.tex.first_layer + 1; + + if ((state->target == PIPE_TEXTURE_CUBE) || (state->target == PIPE_TEXTURE_CUBE_ARRAY)) + layers /= 6; + + cfg.depth = layers; + } if (rsrc->modifier == DRM_FORMAT_MOD_LINEAR) { cfg.stride = ail_get_linear_stride_B(&rsrc->layout, level) - 16;