From 5aa4bdc8e7da3273240cd3263cece7c8e440cfcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Thu, 26 Mar 2026 10:29:40 +0100 Subject: [PATCH] r300: fix BE CBZB clears for swapped 8888 formats On big-endian hosts, r300 handles A8R8G8B8 and X8R8G8B8 by using DWORD swap and programming component order as the matching B8G8R8A8 or B8G8R8X8 formats. Reuse the same mapping when packing CBZB clear colors. Fixes the bad lower-screen colors in Extreme TuxRacer on RV350. Part-of: --- src/gallium/drivers/r300/r300_blit.c | 3 +++ src/gallium/drivers/r300/r300_texture.c | 6 +++--- src/gallium/drivers/r300/r300_texture.h | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 118d1e52736..49d089e567b 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -109,6 +109,9 @@ static uint32_t r300_depth_clear_cb_value(enum pipe_format format, const float* rgba) { union util_color uc; + + format = r300_unbyteswap_array_format(format); + util_pack_color(rgba, format, &uc); if (util_format_get_blocksizebits(format) == 32) { diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 01a6ce06cd0..dda3bceeb59 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -25,10 +25,10 @@ * The swizzles must be set exactly like their non-swapped counterparts, * because byte-swapping is what reverses the component order, not swizzling. * - * This function returns the format that must be used to program CB and TX - * swizzles. + * This function returns the format that must be used to handle component order + * for r300 byte-swapped array formats. */ -static enum pipe_format r300_unbyteswap_array_format(enum pipe_format format) +enum pipe_format r300_unbyteswap_array_format(enum pipe_format format) { /* FIXME: Disabled on little endian because of a reported regression: * https://bugs.freedesktop.org/show_bug.cgi?id=98869 */ diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 5480385cf1c..a3dc7b31a8c 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -23,6 +23,8 @@ unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format, const unsigned char *swizzle_view, bool dxtc_swizzle); +enum pipe_format r300_unbyteswap_array_format(enum pipe_format format); + uint32_t r300_translate_texformat(enum pipe_format format, const unsigned char *swizzle_view, bool is_r500,