From 41184f89eb90735b9423d1fed579d952697c978f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 27 Aug 2020 15:13:19 -0400 Subject: [PATCH] pan/mdg: Bounds check swizzle writing globals Fixes scheduler hang in: dEQP-GLES31.functional.shaders.opaque_type_indexing.ubo.const_literal_compute Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_compile.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 4b15ef93209..1f7d22a2335 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -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); } -- 2.30.2