From e571fb9d2e228f3c982e2c879253d22147618084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Mon, 31 Oct 2022 10:08:38 +0100 Subject: [PATCH] r300: properly account for per-channel negates when reswizzling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vertex shaders can have a per-channel negate so we need to properly update the negate mask when rewriting swizzles. Signed-off-by: Pavel Ondračka Reviewed-by: Filip Gawin Tested-by: Filip Gawin Part-of: --- .../drivers/r300/compiler/radeon_compiler_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c index f4e4238c541..a4bc60fa49d 100644 --- a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c +++ b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c @@ -220,6 +220,20 @@ static void normal_rewrite_writemask_cb( { unsigned int * conversion_swizzle = (unsigned int *)userdata; src->Swizzle = rc_adjust_channels(src->Swizzle, *conversion_swizzle); + + /* Per-channel negates are possible in vertex shaders, + * so we need to rewrite it properly as well. */ + unsigned int new_negate = 0; + for (unsigned int i = 0; i < 4; i++) { + unsigned int new_chan = get_swz(*conversion_swizzle, i); + + if (new_chan == RC_SWIZZLE_UNUSED) + continue; + + if ((1 << i) & src->Negate) + new_negate |= 1 << new_chan; + } + src->Negate = new_negate; } /**