Mesa (staging/22.1): r300: keep negation if w is an inline constant

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 23 18:09:43 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 3f715abd749ac29ca4513da0bf7ac8a0b62502c8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f715abd749ac29ca4513da0bf7ac8a0b62502c8

Author: Filip Gawin <filip at gawin.net>
Date:   Tue May 17 18:10:21 2022 +0200

r300: keep negation if w is an inline constant

(in dataflow swizzles pass)

helps with:
dEQP-GLES2.functional.shaders.random.conditionals.combined.73
on r300 and r400

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16559>
(cherry picked from commit fb2426db7a1eec78121609c0fb744c8f9cf885e9)

---

 .pick_status.json                                            | 2 +-
 src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c | 9 ++++++---
 src/gallium/drivers/r300/compiler/radeon_program_constants.h | 5 +++++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 9e916dd8f2a..572386ea813 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -166,7 +166,7 @@
         "description": "r300: keep negation if w is an inline constant",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c b/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c
index 2cc624f8982..a976d7ed8d6 100644
--- a/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c
+++ b/src/gallium/drivers/r300/compiler/radeon_dataflow_swizzles.c
@@ -97,6 +97,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c,
 {
 	unsigned new_swizzle, chan, swz0, swz1, swz2, swz3, found_swizzle, swz;
 	unsigned all_inline = 0;
+	bool w_inline_constant = false;
 	float imms[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 
 	if (!rc_src_reg_is_immediate(c, reg->File, reg->Index)) {
@@ -321,7 +322,9 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c,
 	swz3 = GET_SWZ(reg->Swizzle, 3);
 
 	/* We can skip this if the swizzle in channel w is an inline constant. */
-	if (swz3 <= RC_SWIZZLE_W) {
+	if (is_swizzle_inline_constant(swz3)) {
+		w_inline_constant = true;
+	} else {
 		for (chan = 0; chan < 3; chan++) {
 			unsigned old_swz = GET_SWZ(reg->Swizzle, chan);
 			unsigned new_swz = GET_SWZ(new_swizzle, chan);
@@ -372,7 +375,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c,
 		 *
 		 * Swizzles with a value > RC_SWIZZLE_W are inline constants.
 		 */
-		if (chan == 3 && old_swz > RC_SWIZZLE_W) {
+		if (chan == 3 && w_inline_constant) {
 			continue;
 		}
 
@@ -412,7 +415,7 @@ static unsigned try_rewrite_constant(struct radeon_compiler *c,
 	 * ONE, ZERO, HALF).
 	 */
 	reg->File = RC_FILE_CONSTANT;
-	reg->Negate = 0;
+	reg->Negate = w_inline_constant ? reg->Negate & (1 << 3) : 0;
 	return 1;
 }
 
diff --git a/src/gallium/drivers/r300/compiler/radeon_program_constants.h b/src/gallium/drivers/r300/compiler/radeon_program_constants.h
index e54c6a892dc..6a8cbe333bf 100644
--- a/src/gallium/drivers/r300/compiler/radeon_program_constants.h
+++ b/src/gallium/drivers/r300/compiler/radeon_program_constants.h
@@ -115,6 +115,11 @@ typedef enum {
 	RC_SWIZZLE_UNUSED
 } rc_swizzle;
 
+static inline int is_swizzle_inline_constant(rc_swizzle swizzle){
+	return swizzle >= RC_SWIZZLE_ZERO;
+
+}
+
 #define RC_MAKE_SWIZZLE(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
 #define RC_MAKE_SWIZZLE_SMEAR(a) RC_MAKE_SWIZZLE((a),(a),(a),(a))
 #define GET_SWZ(swz, idx)      (((swz) >> ((idx)*3)) & 0x7)



More information about the mesa-commit mailing list