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 <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
This commit is contained in:
Alyssa Rosenzweig 2022-09-02 22:23:05 -04:00 committed by Marge Bot
parent 99a5b11af5
commit a41d732784
2 changed files with 10 additions and 3 deletions

View file

@ -205,6 +205,7 @@
<value name="2D Multisampled" value="4"/>
<value name="3D" value="5"/>
<value name="Cube" value="6"/>
<value name="Cube Array" value="7"/>
<value name="2D Array Multisampled" value="8"/>
</enum>

View file

@ -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;