summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/amd/common/ac_nir_to_llvm.c49
-rw-r--r--src/amd/vulkan/radv_device.c8
-rw-r--r--src/amd/vulkan/radv_pipeline.c2
3 files changed, 59 insertions, 0 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 17bfe5b96f..fb6863dad6 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -4149,6 +4149,55 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
case nir_intrinsic_load_patch_vertices_in:
result = LLVMConstInt(ctx->ac.i32, ctx->nctx->options->key.tcs.input_vertices, false);
break;
+ case nir_intrinsic_ballot:
+ result = ac_build_ballot(&ctx->ac, get_src(ctx, instr->src[0]));
+ break;
+ case nir_intrinsic_read_first_invocation: {
+ LLVMValueRef src0 = get_src(ctx, instr->src[0]);
+ ac_build_optimization_barrier(&ctx->ac, &src0);
+ LLVMValueRef srcs[1] = { src0 };
+ result = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.readfirstlane",
+ ctx->ac.i32, srcs, 1,
+ AC_FUNC_ATTR_NOUNWIND |
+ AC_FUNC_ATTR_READNONE |
+ AC_FUNC_ATTR_CONVERGENT);
+ break;
+ }
+ case nir_intrinsic_read_invocation: {
+ LLVMValueRef src0 = get_src(ctx, instr->src[0]);
+ ac_build_optimization_barrier(&ctx->ac, &src0);
+ LLVMValueRef srcs[2] = { src0, get_src(ctx, instr->src[1]) };
+ result = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.readlane",
+ ctx->ac.i32, srcs, 2,
+ AC_FUNC_ATTR_NOUNWIND |
+ AC_FUNC_ATTR_READNONE |
+ AC_FUNC_ATTR_CONVERGENT);
+ break;
+ }
+ case nir_intrinsic_load_subgroup_invocation:
+ result = ac_get_thread_id(&ctx->ac);
+ break;
+ case nir_intrinsic_load_subgroup_size:
+ result = LLVMConstInt(ctx->ac.i32, 64, 0);
+ break;
+ case nir_intrinsic_vote_all:
+ result = LLVMBuildSExt(ctx->ac.builder,
+ ac_build_vote_all(&ctx->ac,
+ get_src(ctx, instr->src[0])),
+ ctx->ac.i32, "");
+ break;
+ case nir_intrinsic_vote_any:
+ result = LLVMBuildSExt(ctx->ac.builder,
+ ac_build_vote_any(&ctx->ac,
+ get_src(ctx, instr->src[0])),
+ ctx->ac.i32, "");
+ break;
+ case nir_intrinsic_vote_eq:
+ result = LLVMBuildSExt(ctx->ac.builder,
+ ac_build_vote_eq(&ctx->ac,
+ get_src(ctx, instr->src[0])),
+ ctx->ac.i32, "");
+ break;
default:
fprintf(stderr, "Unknown intrinsic: ");
nir_print_instr(&instr->instr, stderr);
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 85ba165b4c..21f2437b2a 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -168,6 +168,14 @@ static const VkExtensionProperties common_device_extensions[] = {
.extensionName = VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME,
.specVersion = 1,
},
+ {
+ .extensionName = VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME,
+ .specVersion = 1,
+ },
+ {
+ .extensionName = VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME,
+ .specVersion = 1,
+ },
};
static const VkExtensionProperties ext_sema_device_extensions[] = {
{
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index e2fec93db6..fd86519c73 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -234,6 +234,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
.tessellation = true,
.int64 = true,
.variable_pointers = true,
+ .shader_ballot = true,
+ .shader_group_vote = true,
};
entry_point = spirv_to_nir(spirv, module->size / 4,
spec_entries, num_spec_entries,