pan/mdg: Bounds check swizzle writing globals
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 27 Aug 2020 19:13:19 +0000 (15:13 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 31 Aug 2020 11:46:31 +0000 (07:46 -0400)
Fixes scheduler hang in:

dEQP-GLES31.functional.shaders.opaque_type_indexing.ubo.const_literal_compute

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

src/panfrost/midgard/midgard_compile.c

index 4b15ef93209ca6578bf3161aa3a242afb92f3da3..1f7d22a233593094bf5b9fcd658a8298cf4d6c53 100644 (file)
@@ -1357,6 +1357,15 @@ emit_global(
         mir_set_offset(ctx, &ins, offset, is_shared);
         mir_set_intr_mask(instr, &ins, is_read);
 
+        /* Set a valid swizzle for masked out components */
+        assert(ins.mask);
+        unsigned first_component = __builtin_ffs(ins.mask) - 1;
+
+        for (unsigned i = 0; i < ARRAY_SIZE(ins.swizzle[0]); ++i) {
+                if (!(ins.mask & (1 << i)))
+                        ins.swizzle[0][i] = first_component;
+        }
+
         emit_mir_instruction(ctx, ins);
 }