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 <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23997>
This commit is contained in:
Dave Airlie
2023-07-05 10:12:47 +10:00
parent d0e6809ee5
commit bcb5dbf232
4 changed files with 9 additions and 13 deletions
@@ -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);
+1 -1
View File
@@ -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;
@@ -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;
+3 -7
View File
@@ -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));