From ced585e3f4443115f7f8760468cad19945799d0a 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: (cherry picked from commit f0c0997277e3fcdba18ade60dc7ab52f07e5dc4a) --- .pick_status.json | 2 +- src/gallium/drivers/r600/r600_state_common.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 88926fe4ed7..ad7d4a645a9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1584,7 +1584,7 @@ "description": "r600: fix textures with swizzles limited to zero and one", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index e86bf3cd365..a1e773d1e07 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -3103,6 +3103,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)