Skip to content

Commit df3760b

Browse files
Firestar99LegNeato
authored andcommitted
subgroup: don't special case ClusteredReduce anymore
1 parent 0b32144 commit df3760b

9 files changed

+18
-21
lines changed

crates/spirv-std/src/arch/subgroup.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ pub enum GroupOperation {
3030
/// A binary operation with an identity I and n (where n is the size of the workgroup)
3131
/// elements[a0, a1, … an-1] resulting in [I, a0, (a0 op a1), … (a0 op a1 op … op an-2)].
3232
ExclusiveScan = 2,
33-
// /// See [`GROUP_OPERATION_CLUSTERED_REDUCE`]
34-
// ClusteredReduce = 3,
33+
/// The [`GroupOperation`] `ClusteredReduce`.
34+
///
35+
/// All instructions with a [`GroupOperation`] require an additional `ClusterSize` parameter when [`GroupOperation`] is
36+
/// `ClusteredReduce`. To map this requirement into rust, all function have a base version accepting [`GroupOperation`]
37+
/// as a const generic, and a `_clustered` variant that is fixed to `ClusteredReduce` and takes the additional
38+
/// `ClusterSize` parameter as a const generic. To not accidentally use a `ClusteredReduce` in the base variant of the
39+
/// function, it was removed from the [`GroupOperation`] enum and instead resides individually.
40+
ClusteredReduce = 3,
3541
/// Reserved.
3642
///
3743
/// Requires Capability `GroupNonUniformPartitionedNV`.
@@ -46,15 +52,6 @@ pub enum GroupOperation {
4652
PartitionedExclusiveScanNV = 8,
4753
}
4854

49-
/// The [`GroupOperation`] `ClusteredReduce`.
50-
///
51-
/// All instructions with a [`GroupOperation`] require an additional `ClusterSize` parameter when [`GroupOperation`] is
52-
/// `ClusteredReduce`. To map this requirement into rust, all function have a base version accepting [`GroupOperation`]
53-
/// as a const generic, and a `_clustered` variant that is fixed to `ClusteredReduce` and takes the additional
54-
/// `ClusterSize` parameter as a const generic. To not accidentally use a `ClusteredReduce` in the base variant of the
55-
/// function, it was removed from the [`GroupOperation`] enum and instead resides individually.
56-
pub const GROUP_OPERATION_CLUSTERED_REDUCE: u32 = 3;
57-
5855
/// Only usable if the extension GL_KHR_shader_subgroup_basic is enabled.
5956
///
6057
/// The function subgroupBarrier() enforces that all active invocations within a
@@ -782,7 +779,7 @@ macro_rules! macro_subgroup_op_clustered {
782779
concat!("%result = ", $asm_op, " _ %subgroup {groupop} %value %clustersize"),
783780
"OpStore {result} %result",
784781
subgroup = const SUBGROUP,
785-
groupop = const GROUP_OPERATION_CLUSTERED_REDUCE,
782+
groupop = const (GroupOperation::ClusteredReduce as u32),
786783
clustersize = const CLUSTER_SIZE,
787784
value = in(reg) &value,
788785
result = in(reg) &mut result,

tests/ui/arch/subgroup/subgroup_ballot.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 381 8
4+
OpLine %6 378 8
55
%7 = OpGroupNonUniformBallot %8 %9 %4
6-
OpLine %6 417 8
6+
OpLine %6 414 8
77
%10 = OpGroupNonUniformInverseBallot %2 %9 %7
88
OpNoLine
99
OpReturnValue %10

tests/ui/arch/subgroup/subgroup_ballot_bit_count.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %5
33
%6 = OpLabel
4-
OpLine %7 513 0
4+
OpLine %7 510 0
55
%8 = OpGroupNonUniformBallotBitCount %2 %9 Reduce %4
66
OpNoLine
77
OpReturnValue %8

tests/ui/arch/subgroup/subgroup_broadcast_first.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 348 8
4+
OpLine %6 345 8
55
%7 = OpGroupNonUniformBroadcastFirst %2 %8 %4
66
OpNoLine
77
OpReturnValue %7

tests/ui/arch/subgroup/subgroup_elect.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 183 8
3+
OpLine %5 180 8
44
%6 = OpGroupNonUniformElect %2 %7
55
OpNoLine
66
OpReturnValue %6

tests/ui/arch/subgroup/subgroup_i_add_clustered.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 811 0
4+
OpLine %6 808 0
55
%7 = OpGroupNonUniformIAdd %2 %8 ClusteredReduce %4 %9
66
OpNoLine
77
OpReturnValue %7

tests/ui/arch/subgroup/subgroup_i_add_exclusive_scan.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 798 0
4+
OpLine %6 795 0
55
%7 = OpGroupNonUniformIAdd %2 %8 ExclusiveScan %4
66
OpNoLine
77
OpReturnValue %7

tests/ui/arch/subgroup/subgroup_i_add_inclusive_scan.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 798 0
4+
OpLine %6 795 0
55
%7 = OpGroupNonUniformIAdd %2 %8 InclusiveScan %4
66
OpNoLine
77
OpReturnValue %7

tests/ui/arch/subgroup/subgroup_i_add_reduce.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpFunctionParameter %2
33
%5 = OpLabel
4-
OpLine %6 798 0
4+
OpLine %6 795 0
55
%7 = OpGroupNonUniformIAdd %2 %8 Reduce %4
66
OpNoLine
77
OpReturnValue %7

0 commit comments

Comments
 (0)