<div dir="ltr"><div>Out of curiosity, are there any tests for this anywhere?<br><br></div>--Jason<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 7:24 PM, Connor Abbott <span dir="ltr"><<a href="mailto:connora@valvesoftware.com" target="_blank">connora@valvesoftware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>><br>
<br>
---<br>
src/amd/common/ac_nir_to_llvm.<wbr>c | 49 ++++++++++++++++++++++++++++++<wbr>+++++++++++<br>
src/amd/vulkan/radv_device.c | 8 +++++++<br>
src/amd/vulkan/radv_pipeline.c | 2 ++<br>
3 files changed, 59 insertions(+)<br>
<br>
diff --git a/src/amd/common/ac_nir_to_<wbr>llvm.c b/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
index f756b9a..3dd1cbb 100644<br>
--- a/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
+++ b/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
@@ -4142,6 +4142,55 @@ static void visit_intrinsic(struct ac_nir_context *ctx,<br>
case nir_intrinsic_load_patch_<wbr>vertices_in:<br>
result = LLVMConstInt(ctx->ac.i32, ctx->nctx->options->key.tcs.<wbr>input_vertices, false);<br>
break;<br>
+ case nir_intrinsic_ballot:<br>
+ result = ac_build_ballot(&ctx->ac, get_src(ctx, instr->src[0]));<br>
+ break;<br>
+ case nir_intrinsic_read_first_<wbr>invocation: {<br>
+ LLVMValueRef src0 = get_src(ctx, instr->src[0]);<br>
+ ac_build_optimization_barrier(<wbr>&ctx->ac, &src0);<br>
+ LLVMValueRef srcs[1] = { src0 };<br>
+ result = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.readfirstlane",<br>
+ ctx->ac.i32, srcs, 1,<br>
+ AC_FUNC_ATTR_NOUNWIND |<br>
+ AC_FUNC_ATTR_READNONE |<br>
+ AC_FUNC_ATTR_CONVERGENT);<br>
+ break;<br>
+ }<br>
+ case nir_intrinsic_read_invocation: {<br>
+ LLVMValueRef src0 = get_src(ctx, instr->src[0]);<br>
+ ac_build_optimization_barrier(<wbr>&ctx->ac, &src0);<br>
+ LLVMValueRef srcs[2] = { src0, get_src(ctx, instr->src[1]) };<br>
+ result = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.readlane",<br>
+ ctx->ac.i32, srcs, 2,<br>
+ AC_FUNC_ATTR_NOUNWIND |<br>
+ AC_FUNC_ATTR_READNONE |<br>
+ AC_FUNC_ATTR_CONVERGENT);<br>
+ break;<br>
+ }<br>
+ case nir_intrinsic_load_subgroup_<wbr>invocation:<br>
+ result = ac_get_thread_id(&ctx->ac);<br>
+ break;<br>
+ case nir_intrinsic_load_subgroup_<wbr>size:<br>
+ result = LLVMConstInt(ctx->ac.i32, 64, 0);<br>
+ break;<br>
+ case nir_intrinsic_vote_all:<br>
+ result = LLVMBuildSExt(ctx->ac.builder,<br>
+ ac_build_vote_all(&ctx->ac,<br>
+ get_src(ctx, instr->src[0])),<br>
+ ctx->ac.i32, "");<br>
+ break;<br>
+ case nir_intrinsic_vote_any:<br>
+ result = LLVMBuildSExt(ctx->ac.builder,<br>
+ ac_build_vote_any(&ctx->ac,<br>
+ get_src(ctx, instr->src[0])),<br>
+ ctx->ac.i32, "");<br>
+ break;<br>
+ case nir_intrinsic_vote_eq:<br>
+ result = LLVMBuildSExt(ctx->ac.builder,<br>
+ ac_build_vote_eq(&ctx->ac,<br>
+ get_src(ctx, instr->src[0])),<br>
+ ctx->ac.i32, "");<br>
+ break;<br>
default:<br>
fprintf(stderr, "Unknown intrinsic: ");<br>
nir_print_instr(&instr->instr, stderr);<br>
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c<br>
index eb25872..e8fe086 100644<br>
--- a/src/amd/vulkan/radv_device.c<br>
+++ b/src/amd/vulkan/radv_device.c<br>
@@ -165,6 +165,14 @@ static const VkExtensionProperties common_device_extensions[] = {<br>
.extensionName = VK_KHR_VARIABLE_POINTERS_<wbr>EXTENSION_NAME,<br>
.specVersion = 1,<br>
},<br>
+ {<br>
+ .extensionName = VK_EXT_SHADER_SUBGROUP_BALLOT_<wbr>EXTENSION_NAME,<br>
+ .specVersion = 1,<br>
+ },<br>
+ {<br>
+ .extensionName = VK_EXT_SHADER_SUBGROUP_VOTE_<wbr>EXTENSION_NAME,<br>
+ .specVersion = 1,<br>
+ },<br>
};<br>
static const VkExtensionProperties ext_sema_device_extensions[] = {<br>
{<br>
diff --git a/src/amd/vulkan/radv_<wbr>pipeline.c b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
index 2fc64e8..c354807 100644<br>
--- a/src/amd/vulkan/radv_<wbr>pipeline.c<br>
+++ b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
@@ -234,6 +234,8 @@ radv_shader_compile_to_nir(<wbr>struct radv_device *device,<br>
.tessellation = true,<br>
.int64 = true,<br>
.variable_pointers = true,<br>
+ .shader_ballot = true,<br>
+ .shader_group_vote = true,<br>
};<br>
entry_point = spirv_to_nir(spirv, module->size / 4,<br>
spec_entries, num_spec_entries,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>