Module: Mesa Branch: gallivm-mask-reg-load Commit: 75d9e72fb2bd79c4a85eada545a0de019ca172e9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=75d9e72fb2bd79c4a85eada545a0de019ca172e9
Author: Dave Airlie <[email protected]> Date: Tue Oct 27 14:35:17 2020 +1000 gallivm/nir: mask register loads. This fixes a crash running gtk4 gtk-demo reported via gtk gitlab. Otherwise you end up with very random values in the code, that can then cause subsequent issues. Fixes: 44a6b0107b37 ("gallivm: add nir->llvm translation (v2)") --- src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 0df4f6bfb32..d03d6d1bf60 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -651,6 +651,7 @@ static LLVMValueRef emit_load_reg(struct lp_build_nir_context *bld_base, int nc = reg->reg->num_components; LLVMValueRef vals[NIR_MAX_VEC_COMPONENTS] = { NULL }; struct lp_build_context *uint_bld = &bld_base->uint_bld; + LLVMValueRef exec_mask = mask_vec(bld_base); if (reg->reg->num_array_elems) { LLVMValueRef indirect_val = lp_build_const_int_vec(gallivm, uint_bld->type, reg->base_offset); if (reg->indirect) { @@ -670,6 +671,14 @@ static LLVMValueRef emit_load_reg(struct lp_build_nir_context *bld_base, vals[i] = LLVMBuildLoad(builder, this_storage, ""); } } + + if (reg->reg->bit_size < 32) + exec_mask = LLVMBuildTrunc(builder, exec_mask, reg_bld->vec_type, ""); + else + exec_mask = LLVMBuildSExt(builder, exec_mask, reg_bld->vec_type, ""); + for (unsigned i = 0; i < nc; i++) + vals[i] = LLVMBuildAnd(builder, vals[i], exec_mask, ""); + return nc == 1 ? vals[0] : lp_nir_array_build_gather_values(builder, vals, nc); } _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
