diff options
author | Jason Ekstrand <[email protected]> | 2017-05-09 16:44:13 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-03-07 12:13:47 -0800 |
commit | 5162a1d88428c9a89454c17bc7d12539d7d5714d (patch) | |
tree | a9f4116cee8a08815b73f1e1875f4ec92791f857 | |
parent | 752e9697030389e5b09553d55f9c4fc68edf08a2 (diff) |
nir: Add new SPIR-V ballot intrinsics and lowering
Someone can make the lowering optional later if they want something
different for their hardware.
Reviewed-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
-rw-r--r-- | src/compiler/nir/nir_intrinsics.h | 12 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_subgroups.c | 10 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h index 1a816b46792..46f67a908ed 100644 --- a/src/compiler/nir/nir_intrinsics.h +++ b/src/compiler/nir/nir_intrinsics.h @@ -106,6 +106,18 @@ INTRINSIC(ballot, 1, ARR(1), true, 0, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMIN 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(), diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index acc6ed9a36e..e45a7d723ac 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -244,6 +244,16 @@ lower_subgroups_intrin(nir_builder *b, nir_intrinsic_instr *intrin, 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; } |