1 % Many of these tests fail on MoltenVK because of a bug in Metal, which causes
2 % SIMD operations (i.e., wave operations for Apple) to be hoisted out of the
3 % "if"statement, thereby changing which threads (i.e., wave groups for Apple)
4 % appear as active. This was reported to Apple as FB15624583.
8 format r32-uint uav-load
20 0x100 0x200 0x400 0x800
32 RWBuffer<uint> u0 : register(u0);
33 RWBuffer<uint> u1 : register(u1);
34 RWBuffer<uint> u2 : register(u2);
37 void main(uint id : SV_GroupIndex)
39 const unsigned int POS_COUNT = 5;
40 unsigned int i, pos = 0;
41 /* If SPV_KHR_subgroup_uniform_control_flow is not supported,
42 * SPIR-V doesn't guarantee reconvergence after the loop. */
43 for (i = 0; i < 2; ++i)
45 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 1;
46 if (u0[id] & (1 << i))
48 /* In many programming languages this statement could be
49 * moved after the loop. Not here, because the set of
50 * active invocations is supposed to depend on whether
51 * we're still in the loop (i.e., before reconverging the
52 * invocations that diverged during the loop) or not. */
53 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 2;
58 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 3;
61 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 4;
66 probe uav 2 (0) rui (0xf01)
67 bug(mvk) probe uav 2 (1) rui (0x503)
68 probe uav 2 (2) rui (0x511)
69 bug(mvk) probe uav 2 (3) rui (0x113)
70 probe uav 2 (4) rui (0xf24)
72 probe uav 2 (5) rui (0xf01)
73 bug(mvk) probe uav 2 (6) rui (0xa02)
74 probe uav 2 (7) rui (0xf04)
75 probe uav 2 (8) rui (0)
76 probe uav 2 (9) rui (0)
78 probe uav 2 (10) rui (0xf01)
79 bug(mvk) probe uav 2 (11) rui (0x503)
80 probe uav 2 (12) rui (0x511)
81 bug(mvk) probe uav 2 (13) rui (0x412)
82 probe uav 2 (14) rui (0xf14)
84 probe uav 2 (15) rui (0xf01)
85 bug(mvk) probe uav 2 (16) rui (0xa02)
86 probe uav 2 (17) rui (0xf04)
87 probe uav 2 (18) rui (0)
88 probe uav 2 (19) rui (0)
100 RWBuffer<uint> u0 : register(u0);
101 RWBuffer<uint> u1 : register(u1);
102 RWBuffer<uint> u2 : register(u2);
104 [numthreads(4, 1, 1)]
105 void main(uint id : SV_GroupIndex)
107 const unsigned int POS_COUNT = 5;
108 unsigned int i, pos = 0;
109 /* If SPV_KHR_maximal_reconvergence is not supported, SPIR-V
110 * doesn't guarantee reconvergence after the loop even if
111 * SPV_KHR_subgroup_uniform_control_flow is supported, because the
112 * flow wasn't fully convergent when entering the loop. */
113 if (!(u0[id] & 0x10))
115 for (i = 0; i < 2; ++i)
117 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 1;
118 if (u0[id] & (1 << i))
120 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 2;
125 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 3;
128 u2[POS_COUNT * id + pos++] = WaveActiveSum(u1[id]) + 16 * i + 4;
134 probe uav 2 (0) rui (0x701)
135 bug(mvk) probe uav 2 (1) rui (0x503)
136 probe uav 2 (2) rui (0x511)
137 bug(mvk) probe uav 2 (3) rui (0x113)
138 probe uav 2 (4) rui (0x724)
140 probe uav 2 (5) rui (0x701)
141 bug(mvk) probe uav 2 (6) rui (0x202)
142 probe uav 2 (7) rui (0x704)
143 probe uav 2 (8) rui (0)
144 probe uav 2 (9) rui (0)
146 probe uav 2 (10) rui (0x701)
147 bug(mvk) probe uav 2 (11) rui (0x503)
148 probe uav 2 (12) rui (0x511)
149 bug(mvk) probe uav 2 (13) rui (0x412)
150 probe uav 2 (14) rui (0x714)
152 probe uav 2 (15) rui (0)
153 probe uav 2 (16) rui (0)
154 probe uav 2 (17) rui (0)
155 probe uav 2 (18) rui (0)
156 probe uav 2 (19) rui (0)