From: Alyssa Rosenzweig Date: Thu, 27 Aug 2020 19:13:19 +0000 (-0400) Subject: pan/mdg: Bounds check swizzle writing globals X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=41184f89eb90735b9423d1fed579d952697c978f;p=mesa.git 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: --- 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); }