[Mesa-dev] [PATCH 2/2] nir/spirv: add support for the SubgroupBallotKHR SPIR-V capability
Daniel Schürmann
daniel.schuermann at campus.tu-berlin.de
Fri Mar 9 10:17:05 UTC 2018
This capability is required for the VK_EXT_shader_subgroup_ballot extension.
Signed-off-by: Daniel Schürmann <daniel.schuermann at campus.tu-berlin.de>
---
src/compiler/spirv/spirv_to_nir.c | 3 +++
src/compiler/spirv/vtn_subgroup.c | 17 ++++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index a7e01a705b..ff32338bfe 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3936,6 +3936,9 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
case SpvOpGroupNonUniformLogicalXor:
case SpvOpGroupNonUniformQuadBroadcast:
case SpvOpGroupNonUniformQuadSwap:
+ case SpvOpSubgroupBallotKHR:
+ case SpvOpSubgroupFirstInvocationKHR:
+ case SpvOpSubgroupReadInvocationKHR:
case SpvOpSubgroupAllKHR:
case SpvOpSubgroupAnyKHR:
case SpvOpSubgroupAllEqualKHR:
diff --git a/src/compiler/spirv/vtn_subgroup.c b/src/compiler/spirv/vtn_subgroup.c
index 0042217616..6a593cc3fd 100644
--- a/src/compiler/spirv/vtn_subgroup.c
+++ b/src/compiler/spirv/vtn_subgroup.c
@@ -87,12 +87,13 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
break;
}
- case SpvOpGroupNonUniformBallot: {
+ case SpvOpGroupNonUniformBallot: ++w;
+ case SpvOpSubgroupBallotKHR: {
vtn_fail_if(val->type->type != glsl_vector_type(GLSL_TYPE_UINT, 4),
"OpGroupNonUniformBallot must return a uvec4");
nir_intrinsic_instr *ballot =
nir_intrinsic_instr_create(b->nb.shader, nir_intrinsic_ballot);
- ballot->src[0] = nir_src_for_ssa(vtn_ssa_value(b, w[4])->def);
+ ballot->src[0] = nir_src_for_ssa(vtn_ssa_value(b, w[3])->def);
nir_ssa_dest_init(&ballot->instr, &ballot->dest, 4, 32, NULL);
ballot->num_components = 4;
nir_builder_instr_insert(&b->nb, &ballot->instr);
@@ -173,15 +174,17 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
break;
}
- case SpvOpGroupNonUniformBroadcastFirst:
+ case SpvOpGroupNonUniformBroadcastFirst: ++w;
+ case SpvOpSubgroupFirstInvocationKHR:
vtn_build_subgroup_instr(b, nir_intrinsic_read_first_invocation,
- val->ssa, vtn_ssa_value(b, w[4]), NULL, 0, 0);
+ val->ssa, vtn_ssa_value(b, w[3]), NULL, 0, 0);
break;
- case SpvOpGroupNonUniformBroadcast:
+ case SpvOpGroupNonUniformBroadcast: ++w;
+ case SpvOpSubgroupReadInvocationKHR:
vtn_build_subgroup_instr(b, nir_intrinsic_read_invocation,
- val->ssa, vtn_ssa_value(b, w[4]),
- vtn_ssa_value(b, w[5])->def, 0, 0);
+ val->ssa, vtn_ssa_value(b, w[3]),
+ vtn_ssa_value(b, w[4])->def, 0, 0);
break;
case SpvOpGroupNonUniformAll:
--
2.14.1
More information about the mesa-dev
mailing list