nir: Add intrinsics from ARB_shader_group_vote
authorMatt Turner <mattst88@gmail.com>
Wed, 21 Jun 2017 05:37:43 +0000 (22:37 -0700)
committerMatt Turner <mattst88@gmail.com>
Thu, 20 Jul 2017 23:56:49 +0000 (16:56 -0700)
These are intrinsics rather than opcodes, because they operate across
channels.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/nir/nir_intrinsics.h

index 21530040a9691e88b187fdfa743e6b676bca29ba..01166f68655b5e58363ef75d6cd4e48cd9d81bb2 100644 (file)
@@ -799,6 +799,15 @@ nir_visitor::visit(ir_call *ir)
       case ir_intrinsic_shared_atomic_comp_swap:
          op = nir_intrinsic_shared_atomic_comp_swap;
          break;
+      case ir_intrinsic_vote_any:
+         op = nir_intrinsic_vote_any;
+         break;
+      case ir_intrinsic_vote_all:
+         op = nir_intrinsic_vote_all;
+         break;
+      case ir_intrinsic_vote_eq:
+         op = nir_intrinsic_vote_eq;
+         break;
       default:
          unreachable("not reached");
       }
@@ -1135,6 +1144,19 @@ nir_visitor::visit(ir_call *ir)
          nir_builder_instr_insert(&b, &instr->instr);
          break;
       }
+      case nir_intrinsic_vote_any:
+      case nir_intrinsic_vote_all:
+      case nir_intrinsic_vote_eq: {
+         nir_ssa_dest_init(&instr->instr, &instr->dest, 1, 32, NULL);
+
+         instr->variables[0] = evaluate_deref(&instr->instr, ir->return_deref);
+
+         ir_rvalue *value = (ir_rvalue *) ir->actual_parameters.get_head();
+         instr->src[0] = nir_src_for_ssa(evaluate_rvalue(value));
+
+         nir_builder_instr_insert(&b, &instr->instr);
+         break;
+      }
       default:
          unreachable("not reached");
       }
index 21e7d904b789d298f0a6429573bf75b068cd642c..8a838df0279e7e9251b562b2bf64f120da7d0280 100644 (file)
@@ -107,6 +107,11 @@ BARRIER(memory_barrier_shared)
 /** A conditional discard, with a single boolean source. */
 INTRINSIC(discard_if, 1, ARR(1), false, 0, 0, 0, xx, xx, xx, 0)
 
+/** ARB_shader_group_vote intrinsics */
+INTRINSIC(vote_any, 1, ARR(1), true, 1, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+INTRINSIC(vote_all, 1, ARR(1), true, 1, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+INTRINSIC(vote_eq,  1, ARR(1), true, 1, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+
 /**
  * Basic Geometry Shader intrinsics.
  *