summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Abbott <cwabbott0@gmail.com>2017-06-06 18:01:46 -0700
committerConnor Abbott <cwabbott0@gmail.com>2017-08-08 12:05:25 -0700
commite0300ac735799843a777bb0bf88c65c5a328c5e3 (patch)
tree4c10961cfa4a89c14229f7130617d5f8b765cbf5
parent838e618146a22472abbf839f69812d9c8d08d399 (diff)
radv/ac: enable EXT_shader_subgroup_ballot and EXT_shader_subgroup_voteradv-shader-ballot-v4
-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,