Mesa (master): pan/midgard: Break out one-src read_components

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Feb 2 16:13:11 UTC 2020


Module: Mesa
Branch: master
Commit: a12fe52cbc86b2d33cd5a726ce1020cdcd6c064c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a12fe52cbc86b2d33cd5a726ce1020cdcd6c064c

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Fri Jan 31 08:11:13 2020 -0500

pan/midgard: Break out one-src read_components

For constant packing, this is interesting to break down further.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3653>

---

 src/panfrost/midgard/compiler.h |  1 +
 src/panfrost/midgard/mir.c      | 53 +++++++++++++++++++++++------------------
 2 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index ef89589ced6..8a187e18572 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -530,6 +530,7 @@ bool mir_special_index(compiler_context *ctx, unsigned idx);
 unsigned mir_use_count(compiler_context *ctx, unsigned value);
 bool mir_is_written_before(compiler_context *ctx, midgard_instruction *ins, unsigned node);
 uint16_t mir_bytemask_of_read_components(midgard_instruction *ins, unsigned node);
+uint16_t mir_bytemask_of_read_components_index(midgard_instruction *ins, unsigned i);
 midgard_reg_mode mir_typesize(midgard_instruction *ins);
 midgard_reg_mode mir_srcsize(midgard_instruction *ins, unsigned i);
 unsigned mir_bytes_for_mode(midgard_reg_mode mode);
diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c
index d4ce935934c..c3f1eaafb00 100644
--- a/src/panfrost/midgard/mir.c
+++ b/src/panfrost/midgard/mir.c
@@ -466,40 +466,47 @@ mir_bytemask_of_read_components_single(unsigned *swizzle, unsigned inmask, midga
 }
 
 uint16_t
-mir_bytemask_of_read_components(midgard_instruction *ins, unsigned node)
+mir_bytemask_of_read_components_index(midgard_instruction *ins, unsigned i)
 {
         uint16_t mask = 0;
 
-        if (node == ~0)
-                return 0;
+        /* Branch writeout uses all components */
+        if (ins->compact_branch && ins->writeout && (i == 0))
+                return 0xFFFF;
 
-        mir_foreach_src(ins, i) {
-                if (ins->src[i] != node) continue;
+        /* Conditional branches read one 32-bit component = 4 bytes (TODO: multi branch??) */
+        if (ins->compact_branch && ins->branch.conditional && (i == 0))
+                return 0xF;
 
-                /* Branch writeout uses all components */
-                if (ins->compact_branch && ins->writeout && (i == 0))
-                        return 0xFFFF;
+        /* ALU ops act componentwise so we need to pay attention to
+         * their mask. Texture/ldst does not so we don't clamp source
+         * readmasks based on the writemask */
+        unsigned qmask = (ins->type == TAG_ALU_4) ? ins->mask : ~0;
 
-                /* Conditional branches read one 32-bit component = 4 bytes (TODO: multi branch??) */
-                if (ins->compact_branch && ins->branch.conditional && (i == 0))
-                        return 0xF;
+        /* Handle dot products and things */
+        if (ins->type == TAG_ALU_4 && !ins->compact_branch) {
+                unsigned props = alu_opcode_props[ins->alu.op].props;
 
-                /* ALU ops act componentwise so we need to pay attention to
-                 * their mask. Texture/ldst does not so we don't clamp source
-                 * readmasks based on the writemask */
-                unsigned qmask = (ins->type == TAG_ALU_4) ? ins->mask : ~0;
+                unsigned channel_override = GET_CHANNEL_COUNT(props);
 
-                /* Handle dot products and things */
-                if (ins->type == TAG_ALU_4 && !ins->compact_branch) {
-                        unsigned props = alu_opcode_props[ins->alu.op].props;
+                if (channel_override)
+                        qmask = mask_of(channel_override);
+        }
 
-                        unsigned channel_override = GET_CHANNEL_COUNT(props);
+        return mir_bytemask_of_read_components_single(ins->swizzle[i], qmask, mir_srcsize(ins, i));
+}
 
-                        if (channel_override)
-                                qmask = mask_of(channel_override);
-                }
+uint16_t
+mir_bytemask_of_read_components(midgard_instruction *ins, unsigned node)
+{
+        uint16_t mask = 0;
+
+        if (node == ~0)
+                return 0;
 
-                mask |= mir_bytemask_of_read_components_single(ins->swizzle[i], qmask, mir_srcsize(ins, i));
+        mir_foreach_src(ins, i) {
+                if (ins->src[i] != node) continue;
+                mask |= mir_bytemask_of_read_components_index(ins, i);
         }
 
         return mask;



More information about the mesa-commit mailing list