Mesa (main): pan/bi: Constant fold swizzles on constants

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Feb 19 03:33:22 UTC 2022


Module: Mesa
Branch: main
Commit: 35ff537814b3086fb1d0eaf2971a5bd725ae0574
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=35ff537814b3086fb1d0eaf2971a5bd725ae0574

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Sat Jan 15 12:25:45 2022 -0500

pan/bi: Constant fold swizzles on constants

This lets us avoid generating SWZ instructions. Those instructions could
be constant folded but that complicates the replication analysis
introduced in the next commit.

Almost no shader-db changes.

quadwords HURT:   shaders/glmark/1-22.shader_test MESA_SHADER_FRAGMENT: 718 -> 722 (0.56%)

total quadwords in shared programs: 68169 -> 68173 (<.01%)
quadwords in affected programs: 718 -> 722 (0.56%)
helped: 0
HURT: 1

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14576>

---

 src/panfrost/bifrost/bi_lower_swizzle.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/panfrost/bifrost/bi_lower_swizzle.c b/src/panfrost/bifrost/bi_lower_swizzle.c
index ddb8d1854cd..32517ad93de 100644
--- a/src/panfrost/bifrost/bi_lower_swizzle.c
+++ b/src/panfrost/bifrost/bi_lower_swizzle.c
@@ -108,7 +108,21 @@ bi_lower_swizzle_16(bi_context *ctx, bi_instr *ins, unsigned src)
             return;
         }
 
-        /* If the instruction is scalar we can ignore the other component */
+        /* First, try to apply a given swizzle to a constant to clear the
+         * runtime swizzle. This is less heavy-handed than ignoring the
+         * swizzle for scalar destinations, since it maintains
+         * replication of the destination.
+         */
+        if (ins->src[src].type == BI_INDEX_CONSTANT) {
+                ins->src[src].value = bi_apply_swizzle(ins->src[src].value,
+                                                       ins->src[src].swizzle);
+                ins->src[src].swizzle = BI_SWIZZLE_H01;
+                return;
+        }
+
+        /* Even if the source does not replicate, if the consuming instruction
+         * produces a 16-bit scalar, we can ignore the other component.
+         */
         if (ins->dest[0].swizzle == BI_SWIZZLE_H00 &&
                         ins->src[src].swizzle == BI_SWIZZLE_H00)
         {



More information about the mesa-commit mailing list