INTRINSIC(read_invocation, 2, ARR(0, 1), true, 0, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
INTRINSIC(read_first_invocation, 1, ARR(0), true, 0, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+/** Additional SPIR-V ballot intrinsics
+ *
+ * These correspond to the SPIR-V opcodes
+ *
+ * OpGroupUniformElect
+ * OpSubgroupFirstInvocationKHR
+ */
+INTRINSIC(elect, 0, ARR(0), true, 1, 0, 0, xx, xx, xx,
+ NIR_INTRINSIC_CAN_ELIMINATE)
+INTRINSIC(first_invocation, 0, ARR(0), true, 1, 0, 0, xx, xx, xx,
+ NIR_INTRINSIC_CAN_ELIMINATE)
+
/*
* Memory barrier with semantics analogous to the compute shader
* groupMemoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(),
return nir_bit_count(b, nir_iand(b, int_val, mask));
}
+ case nir_intrinsic_elect: {
+ nir_intrinsic_instr *first =
+ nir_intrinsic_instr_create(b->shader,
+ nir_intrinsic_first_invocation);
+ nir_ssa_dest_init(&first->instr, &first->dest, 1, 32, NULL);
+ nir_builder_instr_insert(b, &first->instr);
+
+ return nir_ieq(b, nir_load_subgroup_invocation(b), &first->dest.ssa);
+ }
+
default:
break;
}