From: Emma Anholt Date: Tue, 28 Feb 2023 20:30:36 +0000 (-0800) Subject: gallivm: Use first_active_invocation for scalar SSBO loads. X-Git-Tag: upstream/23.3.3~12333 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=66dff3d39c5c67a72547592e6e1d74ea57952fbf;p=platform%2Fupstream%2Fmesa.git gallivm: Use first_active_invocation for scalar SSBO loads. Again, this should reduce the complexity of the LLVM IR we emit in some cases. We don't use it for shared loads, due to the noted corner case. Reviewed-by: Dave Airlie Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 31487af..a80675f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -1304,15 +1304,19 @@ static void emit_load_mem(struct lp_build_nir_context *bld_base, offset = LLVMBuildAShr(gallivm->builder, offset, lp_build_const_int_vec(gallivm, uint_bld->type, shift_val), ""); - /* If the address is uniform, then use the address from invocation 0 to load, - * and broadcast to all invocations. + /* If the address is uniform, then use the address from the first active + * invocation 0 to load, and broadcast to all invocations. We can't do + * computed first active invocation for shared accesses (index == NULL), + * though, since those don't do bounds checking and we could use an invalid + * offset if exec_mask == 0. */ - if (index_and_offset_are_uniform && invocation_0_must_be_active(bld_base)) { + if (index_and_offset_are_uniform && (invocation_0_must_be_active(bld_base) || index)) { LLVMValueRef ssbo_limit; + LLVMValueRef first_active = first_active_invocation(bld_base); LLVMValueRef mem_ptr = mem_access_base_pointer(bld_base, load_bld, bit_size, index, - lp_build_const_int32(gallivm, 0), &ssbo_limit); + first_active, &ssbo_limit); - offset = LLVMBuildExtractElement(gallivm->builder, offset, lp_build_const_int32(gallivm, 0), ""); + offset = LLVMBuildExtractElement(gallivm->builder, offset, first_active, ""); for (unsigned c = 0; c < nc; c++) { LLVMValueRef chan_offset = LLVMBuildAdd(builder, offset, lp_build_const_int32(gallivm, c), "");