nir/spirv: add support for the SubgroupVoteKHR SPIR-V capability
authorDaniel Schürmann <daniel.schuermann@campus.tu-berlin.de>
Fri, 9 Mar 2018 09:27:20 +0000 (10:27 +0100)
committerConnor Abbott <cwabbott0@gmail.com>
Thu, 13 Jun 2019 12:44:23 +0000 (12:44 +0000)
This capability is required for the VK_EXT_shader_subgroup_vote extension.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_subgroup.c

index fdcc9fdb96b52b85cb84ee6812032c3dc2acc2f5..fe9fe6932e782eb265e34425788e88f77caf5d46 100644 (file)
@@ -3653,6 +3653,7 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
          spv_check_supported(subgroup_basic, cap);
          break;
 
+      case SpvCapabilitySubgroupVoteKHR:
       case SpvCapabilityGroupNonUniformVote:
          spv_check_supported(subgroup_vote, cap);
          break;
@@ -4524,6 +4525,9 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode,
    case SpvOpGroupNonUniformLogicalXor:
    case SpvOpGroupNonUniformQuadBroadcast:
    case SpvOpGroupNonUniformQuadSwap:
+   case SpvOpSubgroupAllKHR:
+   case SpvOpSubgroupAnyKHR:
+   case SpvOpSubgroupAllEqualKHR:
       vtn_handle_subgroup(b, opcode, w, count);
       break;
 
index 1b066f9340c253a80837fa2d9ebe2c272984ff02..dfa8347b2921b6730aa96ad9752811ef3964cd4c 100644 (file)
@@ -189,18 +189,24 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
 
    case SpvOpGroupNonUniformAll:
    case SpvOpGroupNonUniformAny:
-   case SpvOpGroupNonUniformAllEqual: {
+   case SpvOpGroupNonUniformAllEqual:
+   case SpvOpSubgroupAllKHR:
+   case SpvOpSubgroupAnyKHR:
+   case SpvOpSubgroupAllEqualKHR: {
       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:
+      case SpvOpSubgroupAllKHR:
          op = nir_intrinsic_vote_all;
          break;
       case SpvOpGroupNonUniformAny:
+      case SpvOpSubgroupAnyKHR:
          op = nir_intrinsic_vote_any;
          break;
-      case SpvOpGroupNonUniformAllEqual: {
+      case SpvOpGroupNonUniformAllEqual:
+      case SpvOpSubgroupAllEqualKHR: {
          switch (glsl_get_base_type(val->type->type)) {
          case GLSL_TYPE_FLOAT:
          case GLSL_TYPE_DOUBLE:
@@ -222,8 +228,14 @@ vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
          unreachable("Unhandled opcode");
       }
 
-      nir_ssa_def *src0 = vtn_ssa_value(b, w[4])->def;
-
+      nir_ssa_def *src0;
+      if (opcode == SpvOpGroupNonUniformAll ||
+          opcode == SpvOpGroupNonUniformAny ||
+          opcode == SpvOpGroupNonUniformAllEqual) {
+         src0 = vtn_ssa_value(b, w[4])->def;
+      } else {
+         src0 = vtn_ssa_value(b, w[3])->def;
+      }
       nir_intrinsic_instr *intrin =
          nir_intrinsic_instr_create(b->nb.shader, op);
       intrin->num_components = src0->num_components;