From f01efcb12e3d35a9e005afb5bc0004ca90af2475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Fri, 12 Jun 2026 15:18:59 +0200 Subject: [PATCH] r300: fix BE depth/stencil raw transfer endian state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tiled depth/stencil transfers can raw-copy 32-bit ZS storage through an RGBA8 color alias. On big endian, the normal RGBA8 array policy programs no swap, while the underlying ZS storage uses the dword endian convention. Keep those raw aliases on dword swap so depth readback sees the same byte order that the ZS path wrote. Fixes spec@arb_depth_texture@depthstencil-render-miplevels 146 d=z24. Signed-off-by: Pavel Ondračka Part-of: --- src/gallium/drivers/r300/r300_texture.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 6379d74223f..eca020afc9e 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -58,6 +58,22 @@ static unsigned r300_get_endian_swap(enum pipe_format format, unsigned swap_size; #if UTIL_ARCH_BIG_ENDIAN + if (util_format_is_depth_or_stencil(tex->b.format)) { + switch (format) { + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8X8_UNORM: + /* Depth/stencil transfer blits can alias 32-bit ZS storage as + * RGBA8. Keep the alias on the ZS dword endian convention instead + * of the 8-bit array convention. + */ + return R300_SURF_DWORD_SWAP; + default: + break; + } + } + if ((tex->b.bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) == (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW) && !(tex->b.flags & R300_RESOURCE_FLAG_TRANSFER) &&