Mesa (staging/21.3): r300: Fix omod failing to increase the number of channels stored.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 5 21:19:11 UTC 2022


Module: Mesa
Branch: staging/21.3
Commit: 9dd5c0d0390f3d2a205d6bc791c420b19e0976cb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9dd5c0d0390f3d2a205d6bc791c420b19e0976cb

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Jan  4 16:51:01 2022 -0800

r300: Fix omod failing to increase the number of channels stored.

In dEQP-GLES2.functional.shaders.operator.geometric.reflect.highp_vec2_fragment
and friends this pass would turn:

  0: DP3 temp[1].x, input[1].yx0_, input[0].wy0_;
  1: MUL temp[2].xy, temp[1].xx__, const[0].xx__;

into

  0: DP3 temp[2].x * 2, input[1].yx0_, input[0].wy0_;
  1: MUL temp[3].xy, temp[2].xy__, input[1].yx__;

Note the attempt to use .y of temp[2].  Just bail when we more dst
channels than src channels, since the rewrite can't generate more channels
for us.  Fixes this subset of tests (which I hadn't included in the xfails
until now since results hadn't quite been stable).

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Tested-by: Filip Gawin <filip.gawin at zoho.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14405>
(cherry picked from commit 105b48c85c2be2970bbe9c9185af98ec9c8ff674)

---

 .pick_status.json                                   |  2 +-
 src/gallium/drivers/r300/compiler/radeon_optimize.c | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6ba5c4f9b1a..e1bf3c65fac 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -22,7 +22,7 @@
         "description": "r300: Fix omod failing to increase the number of channels stored.",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/r300/compiler/radeon_optimize.c b/src/gallium/drivers/r300/compiler/radeon_optimize.c
index 64f3fc1300c..b248ce0c668 100644
--- a/src/gallium/drivers/r300/compiler/radeon_optimize.c
+++ b/src/gallium/drivers/r300/compiler/radeon_optimize.c
@@ -26,6 +26,8 @@
  *
  */
 
+#include "util/u_math.h"
+
 #include "radeon_dataflow.h"
 
 #include "radeon_compiler.h"
@@ -833,8 +835,15 @@ static int peephole_mul_omod(
 		return 0;
 	}
 
-	/* Rewrite the instructions */
 	writemask_sum = rc_variable_writemask_sum(writer_list->Item);
+
+	/* rc_normal_rewrite_writemask can't expand a previous writemask to store
+	 * more channels replicated.
+	 */
+	if (util_bitcount(writemask_sum) < util_bitcount(inst_mul->U.I.DstReg.WriteMask))
+		return 0;
+
+	/* Rewrite the instructions */
 	for (var = writer_list->Item; var; var = var->Friend) {
 		struct rc_variable * writer = var;
 		unsigned conversion_swizzle = rc_make_conversion_swizzle(



More information about the mesa-commit mailing list