From 6a2d4621912af29cac8ac3141306d481be02eae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Wed, 19 Oct 2022 10:23:11 +0200 Subject: [PATCH] r300: fix generation of invalid swizzles in regalloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rc_adjust_channels is inteded for moving the swizzles to a new channels when rewriting the writemask of an instruction. However for readers one needs to keep the swizzles in the old channels but rather convert to the new values, so use the proper helper rc_rewrite_swizzle. With the new swizzle fixed, we should properly detect that it would be invalid and thus we can select the proper register class to prevent the writemask rewrite in the regalloc. Documentation was added to rc_adjust_channels to make it more clear what it actually does. Fixes a bunch of dEQP tests. Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7521 Signed-off-by: Pavel Ondračka Reviewed-by: Filip Gawin Part-of: (cherry picked from commit 1e9e5618110542550b9f92dca8392f213bfd46b7) Conflicts: src/gallium/drivers/r300/ci/r300-r480-fails.txt --- .pick_status.json | 2 +- .../drivers/r300/compiler/radeon_compiler_util.c | 11 +++++++++-- .../drivers/r300/compiler/radeon_pair_regalloc.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ebfd9ff5b17..79649d7e7eb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -7888,7 +7888,7 @@ "description": "r300: fix generation of invalid swizzles in regalloc", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c index 5d368299231..f4e4238c541 100644 --- a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c +++ b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c @@ -142,8 +142,15 @@ static unsigned int srcs_need_rewrite(const struct rc_opcode_info * info) } /** - * @return A swizzle the results from converting old_swizzle using - * conversion_swizzle + * This function moves the old swizzles to new channels using the values + * in the conversion swizzle. For example if the instruction writemask is + * changed from x to y, then conversion_swizzle should be y___ and this + * function will adjust the old argument swizzles (of the same instruction) + * to the new channels, so x___ will become _x__, etc... + * + * @param old_swizzle The swizzle to change + * @param conversion_swizzle Describes the conversion to perform on the swizzle + * @return A new swizzle */ unsigned int rc_adjust_channels( unsigned int old_swizzle, diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c index d3a589c98d1..53da5e5b48f 100644 --- a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c +++ b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c @@ -390,7 +390,7 @@ static enum rc_reg_class variable_get_class( can_change_writemask = 0; break; } - new_swizzle = rc_adjust_channels( + new_swizzle = rc_rewrite_swizzle( old_swizzle, conversion_swizzle); if (!r300_swizzle_is_native_basic( new_swizzle)) {