summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/amd/common/ac_nir_to_llvm.c4
-rw-r--r--src/amd/common/ac_shader_abi.h1
-rw-r--r--src/compiler/nir/nir.c4
-rw-r--r--src/compiler/nir/nir_intrinsics.py3
-rw-r--r--src/compiler/shader_enums.h1
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c4
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_nir.c6
7 files changed, 23 insertions, 0 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 440d4ec9e5e..219aa5f95f0 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3313,6 +3313,10 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
case nir_intrinsic_load_color1:
result = ctx->abi->color1;
break;
+ case nir_intrinsic_load_user_data_amd:
+ assert(LLVMTypeOf(ctx->abi->user_data) == ctx->ac.v4i32);
+ result = ctx->abi->user_data;
+ break;
case nir_intrinsic_load_instance_id:
result = ctx->abi->instance_id;
break;
diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index 3033ae0cac2..3a2b5322385 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -65,6 +65,7 @@ struct ac_shader_abi {
LLVMValueRef prim_mask;
LLVMValueRef color0;
LLVMValueRef color1;
+ LLVMValueRef user_data;
/* CS */
LLVMValueRef local_invocation_ids;
LLVMValueRef num_work_groups;
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 822c6ab5d27..1e6f15517f5 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -2022,6 +2022,8 @@ nir_intrinsic_from_system_value(gl_system_value val)
return nir_intrinsic_load_global_invocation_index;
case SYSTEM_VALUE_WORK_DIM:
return nir_intrinsic_load_work_dim;
+ case SYSTEM_VALUE_USER_DATA_AMD:
+ return nir_intrinsic_load_user_data_amd;
default:
unreachable("system value does not directly correspond to intrinsic");
}
@@ -2109,6 +2111,8 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
return SYSTEM_VALUE_LOCAL_GROUP_SIZE;
case nir_intrinsic_load_global_invocation_id:
return SYSTEM_VALUE_GLOBAL_INVOCATION_ID;
+ case nir_intrinsic_load_user_data_amd:
+ return SYSTEM_VALUE_USER_DATA_AMD;
default:
unreachable("intrinsic doesn't produce a system value");
}
diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py
index cbbf8fba89e..f4ca623bb3d 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -614,6 +614,9 @@ system_value("blend_const_color_aaaa8888_unorm", 1)
system_value("color0", 4)
system_value("color1", 4)
+# System value for internal compute shaders in radeonsi.
+system_value("user_data_amd", 4)
+
# Barycentric coordinate intrinsics.
#
# These set up the barycentric coordinates for a particular interpolation.
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index d9eb290abf4..20e62da5b11 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -609,6 +609,7 @@ typedef enum
SYSTEM_VALUE_LOCAL_GROUP_SIZE,
SYSTEM_VALUE_GLOBAL_GROUP_SIZE,
SYSTEM_VALUE_WORK_DIM,
+ SYSTEM_VALUE_USER_DATA_AMD,
/*@}*/
/** Required for VK_KHR_device_group */
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index a23ed4d685f..0a234808428 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -628,6 +628,10 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
op = nir_intrinsic_load_work_group_id;
load = nir_load_work_group_id(b);
break;
+ case TGSI_SEMANTIC_CS_USER_DATA_AMD:
+ op = nir_intrinsic_load_user_data_amd;
+ load = nir_load_user_data_amd(b);
+ break;
default:
unreachable("bad system value");
}
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 524af0e0a19..0aa17e7a37c 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -1240,6 +1240,12 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir)
ctx->abi.interp_at_sample_force_center =
ctx->shader->key.mono.u.ps.interpolate_at_sample_force_center;
+ } else if (nir->info.stage == MESA_SHADER_COMPUTE) {
+ if (nir->info.cs.user_data_components_amd) {
+ ctx->abi.user_data = LLVMGetParam(ctx->main_fn, ctx->param_cs_user_data);
+ ctx->abi.user_data = ac_build_expand_to_vec4(&ctx->ac, ctx->abi.user_data,
+ nir->info.cs.user_data_components_amd);
+ }
}
ctx->abi.inputs = &ctx->inputs[0];