From f0c0997277e3fcdba18ade60dc7ab52f07e5dc4a Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Fri, 28 Mar 2025 13:20:18 +0100 Subject: [PATCH] r600: fix textures with swizzles limited to zero and one This issue seems to be specific to textureGather() which could fail when processing some surfaces. These surfaces are configured with non-standard one and zero swizzles. The gpu doesn't support this very specific setup with all the possible hardware formats. This change selects a compatible configuration when this is possible. This change was tested on palm, barts and cayman. This change fixes the 216 remaining arb_texture_gather tests: spec/arb_texture_gather/texturegather/.*-zero-.*: fail pass spec/arb_texture_gather/texturegather/.*-one-.*: fail pass spec/arb_texture_gather/texturegatheroffset/.*-zero-.*: fail pass spec/arb_texture_gather/texturegatheroffset/.*-one-.*: fail pass Cc: mesa-stable Signed-off-by: Patrick Lerda Acked-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/r600_state_common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 7dfc3036b43..113ce14fbdb 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -3112,6 +3112,26 @@ out_word4: if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB && !is_srgb_valid) return ~0; + + if (unlikely(swizzle_view && + swizzle_view[0] >= PIPE_SWIZZLE_0 && + swizzle_view[1] >= PIPE_SWIZZLE_0 && + swizzle_view[2] >= PIPE_SWIZZLE_0 && + swizzle_view[3] >= PIPE_SWIZZLE_0)) { + switch (result) { + case FMT_32_32_32_32_FLOAT: + case FMT_32_32_FLOAT: + result = FMT_32_FLOAT; + break; + case FMT_16_16_16_16: + case FMT_16_16: + result = FMT_32; + break; + default: + break; + } + } + if (word4_p) *word4_p = word4; if (yuv_format_p)