Mesa (master): pan/bi: Handle vectorized load_const

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 3 17:45:45 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Tue Jun  2 19:30:56 2020 -0400

pan/bi: Handle vectorized load_const

In preparation for 16-bit vectors.

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

---

 src/panfrost/bifrost/bifrost_compile.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 96ceb78cf07..31958426331 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -466,20 +466,29 @@ static void
 emit_load_const(bi_context *ctx, nir_load_const_instr *instr)
 {
         /* Make sure we've been lowered */
-        assert(instr->def.num_components == 1);
+        assert(instr->def.num_components <= (32 / instr->def.bit_size));
+
+        /* Accumulate all the channels of the constant, as if we did an
+         * implicit SEL over them */
+        uint32_t acc = 0;
+
+        for (unsigned i = 0; i < instr->def.num_components; ++i) {
+                unsigned v = nir_const_value_as_uint(instr->value[i], instr->def.bit_size);
+                acc |= (v << (i * instr->def.bit_size));
+        }
 
         bi_instruction move = {
                 .type = BI_MOV,
                 .dest = pan_ssa_index(&instr->def),
-                .dest_type = instr->def.bit_size | nir_type_uint,
+                .dest_type = nir_type_uint32,
                 .src = {
                         BIR_INDEX_CONSTANT
                 },
                 .src_types = {
-                        instr->def.bit_size | nir_type_uint,
+                        nir_type_uint32,
                 },
                 .constant = {
-                        .u64 = nir_const_value_as_uint(instr->value[0], instr->def.bit_size)
+                        .u32 = acc
                 }
         };
 



More information about the mesa-commit mailing list