[Mesa-dev] [PATCH 38/56] spirv: Add subgroup vote support
Jason Ekstrand
jason at jlekstrand.net
Wed Mar 7 14:35:26 UTC 2018
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/compiler/shader_info.h | 1 +
src/compiler/spirv/spirv_to_nir.c | 4 ++++
src/compiler/spirv/vtn_subgroup.c | 47 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 3a6e545..38fd5f8 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -46,6 +46,7 @@ struct spirv_supported_capabilities {
bool storage_16bit;
bool subgroup_ballot;
bool subgroup_basic;
+ bool subgroup_vote;
};
typedef struct shader_info {
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 451d44f..a3abee7 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3296,6 +3296,10 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
spv_check_supported(subgroup_basic, cap);
break;
+ case SpvCapabilityGroupNonUniformVote:
+ spv_check_supported(subgroup_vote, cap);
+ break;
+
case SpvCapabilitySubgroupBallotKHR:
case SpvCapabilityGroupNonUniformBallot:
spv_check_supported(subgroup_ballot, cap);
diff --git a/src/compiler/spirv/vtn_subgroup.c b/src/compiler/spirv/vtn_subgroup.c
index a86f0cb..09e4e59 100644
--- a/src/compiler/spirv/vtn_subgroup.c
+++ b/src/compiler/spirv/vtn_subgroup.c
@@ -180,7 +180,52 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
case SpvOpGroupNonUniformAll:
case SpvOpGroupNonUniformAny:
- case SpvOpGroupNonUniformAllEqual:
+ case SpvOpGroupNonUniformAllEqual: {
+ vtn_fail_if(val->type->type != glsl_bool_type(),
+ "OpGroupNonUniform(All|Any|AllEqual) must return a bool");
+ nir_intrinsic_op op;
+ switch (opcode) {
+ case SpvOpGroupNonUniformAll:
+ op = nir_intrinsic_vote_all;
+ break;
+ case SpvOpGroupNonUniformAny:
+ op = nir_intrinsic_vote_any;
+ break;
+ case SpvOpGroupNonUniformAllEqual: {
+ switch (glsl_get_base_type(val->type->type)) {
+ case GLSL_TYPE_FLOAT:
+ case GLSL_TYPE_DOUBLE:
+ op = nir_intrinsic_vote_feq;
+ break;
+ case GLSL_TYPE_UINT:
+ case GLSL_TYPE_INT:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
+ case GLSL_TYPE_BOOL:
+ op = nir_intrinsic_vote_ieq;
+ break;
+ default:
+ unreachable("Unhandled type");
+ }
+ break;
+ }
+ default:
+ unreachable("Unhandled opcode");
+ }
+
+ nir_ssa_def *src0 = vtn_ssa_value(b, w[4])->def;
+
+ nir_intrinsic_instr *intrin =
+ nir_intrinsic_instr_create(b->nb.shader, op);
+ intrin->num_components = src0->num_components;
+ intrin->src[0] = nir_src_for_ssa(src0);
+ nir_ssa_dest_init(&intrin->instr, &intrin->dest, 1, 32, NULL);
+ nir_builder_instr_insert(&b->nb, &intrin->instr);
+
+ val->ssa->def = &intrin->dest.ssa;
+ break;
+ }
+
case SpvOpGroupNonUniformShuffle:
case SpvOpGroupNonUniformShuffleXor:
case SpvOpGroupNonUniformShuffleUp:
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list