Module: Mesa Branch: main Commit: bcb5dbf23227f59980bb67f8a7099f79a7a033a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bcb5dbf23227f59980bb67f8a7099f79a7a033a9
Author: Dave Airlie <[email protected]> Date: Wed Jul 5 10:12:47 2023 +1000 gallivm: store thread id in separate values. There is no real advantage to putting this into a vector to take it back out again. Reviewed-by: Mike Blumenkrantz <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23997> --- src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 8 ++++---- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 2 +- src/gallium/drivers/llvmpipe/lp_state_cs.c | 10 +++------- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index 609c06a5ca0..1005717e941 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -1886,12 +1886,12 @@ static LLVMValueRef get_local_invocation_index(struct lp_build_nir_soa_context * tmp = lp_build_broadcast_scalar(&bld_base->uint_bld, LLVMBuildExtractElement(gallivm->builder, bld->system_values.block_size, lp_build_const_int32(gallivm, 1), "")); tmp2 = lp_build_broadcast_scalar(&bld_base->uint_bld, LLVMBuildExtractElement(gallivm->builder, bld->system_values.block_size, lp_build_const_int32(gallivm, 0), "")); tmp = lp_build_mul(&bld_base->uint_bld, tmp, tmp2); - tmp = lp_build_mul(&bld_base->uint_bld, tmp, LLVMBuildExtractValue(gallivm->builder, bld->system_values.thread_id, 2, "")); + tmp = lp_build_mul(&bld_base->uint_bld, tmp, bld->system_values.thread_id[2]); tmp2 = lp_build_broadcast_scalar(&bld_base->uint_bld, LLVMBuildExtractElement(gallivm->builder, bld->system_values.block_size, lp_build_const_int32(gallivm, 0), "")); - tmp2 = lp_build_mul(&bld_base->uint_bld, tmp2, LLVMBuildExtractValue(gallivm->builder, bld->system_values.thread_id, 1, "")); + tmp2 = lp_build_mul(&bld_base->uint_bld, tmp2, bld->system_values.thread_id[1]); tmp = lp_build_add(&bld_base->uint_bld, tmp, tmp2); - tmp = lp_build_add(&bld_base->uint_bld, tmp, LLVMBuildExtractValue(gallivm->builder, bld->system_values.thread_id, 0, "")); + tmp = lp_build_add(&bld_base->uint_bld, tmp, bld->system_values.thread_id[0]); return tmp; } @@ -1933,7 +1933,7 @@ static void emit_sysval_intrin(struct lp_build_nir_context *bld_base, } case nir_intrinsic_load_local_invocation_id: for (unsigned i = 0; i < 3; i++) - result[i] = LLVMBuildExtractValue(gallivm->builder, bld->system_values.thread_id, i, ""); + result[i] = bld->system_values.thread_id[i]; break; case nir_intrinsic_load_local_invocation_index: result[0] = get_local_invocation_index(bld); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index e183cec2827..8f750077600 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -172,7 +172,7 @@ struct lp_bld_tgsi_system_values { LLVMValueRef firstvertex; LLVMValueRef invocation_id; LLVMValueRef draw_id; - LLVMValueRef thread_id; + LLVMValueRef thread_id[3]; LLVMValueRef block_id; LLVMValueRef grid_size; LLVMValueRef front_facing; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 61d8f4aae8b..b3b29a7e8ac 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1538,7 +1538,7 @@ emit_fetch_system_value( break; case TGSI_SEMANTIC_THREAD_ID: - res = LLVMBuildExtractValue(gallivm->builder, bld->system_values.thread_id, swizzle, ""); + res = bld->system_values.thread_id[swizzle]; atype = TGSI_TYPE_UNSIGNED; break; diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index 9ce0ebd7fd0..efaee973bb7 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -644,7 +644,6 @@ generate_compute(struct llvmpipe_context *lp, alloced_ptr = LLVMBuildGEP2(gallivm->builder, mem_ptr_type, alloced_ptr, &coro_entry, 1, ""); LLVMValueRef coro_hdl = lp_build_coro_begin(gallivm, coro_id, alloced_ptr); LLVMValueRef has_partials = LLVMBuildICmp(gallivm->builder, LLVMIntNE, partials, lp_build_const_int32(gallivm, 0), ""); - LLVMValueRef tid_vals[3]; LLVMValueRef tids_x[LP_MAX_VECTOR_LENGTH], tids_y[LP_MAX_VECTOR_LENGTH], tids_z[LP_MAX_VECTOR_LENGTH]; LLVMValueRef base_val = LLVMBuildMul(gallivm->builder, x_size_arg, vec_length, ""); for (i = 0; i < cs_type.length; i++) { @@ -652,12 +651,9 @@ generate_compute(struct llvmpipe_context *lp, tids_y[i] = y_size_arg; tids_z[i] = z_size_arg; } - tid_vals[0] = lp_build_gather_values(gallivm, tids_x, cs_type.length); - tid_vals[1] = lp_build_gather_values(gallivm, tids_y, cs_type.length); - tid_vals[2] = lp_build_gather_values(gallivm, tids_z, cs_type.length); - system_values.thread_id = LLVMGetUndef(LLVMArrayType(LLVMVectorType(int32_type, cs_type.length), 3)); - for (i = 0; i < 3; i++) - system_values.thread_id = LLVMBuildInsertValue(builder, system_values.thread_id, tid_vals[i], i, ""); + system_values.thread_id[0] = lp_build_gather_values(gallivm, tids_x, cs_type.length); + system_values.thread_id[1] = lp_build_gather_values(gallivm, tids_y, cs_type.length); + system_values.thread_id[2] = lp_build_gather_values(gallivm, tids_z, cs_type.length); LLVMValueRef gtids[3] = { grid_x_arg, grid_y_arg, grid_z_arg }; system_values.block_id = LLVMGetUndef(LLVMVectorType(int32_type, 3));
