Skip to content

Commit 9eed08a

Browse files
authored
Add test for WaveActiveAllTrue (#236)
Test for control flow divergance and WaveActiveAllTrue. Closes #164
1 parent 0be0b73 commit 9eed08a

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#--- source.hlsl
2+
RWBuffer<int> value;
3+
RWStructuredBuffer<uint> Out : register(u1);
4+
5+
[numthreads(4, 1, 1)]
6+
void main(uint3 threadID : SV_DispatchThreadID) {
7+
bool B1 = true;
8+
switch (value[threadID.x]) {
9+
case 0: // threads 0 and 1
10+
B1 = false;
11+
Out[threadID.x] = WaveActiveAllTrue(B1); // Only threads 0 and 1 are active; result should be false;
12+
break;
13+
case 2: // thread 2
14+
Out[threadID.x] = WaveActiveAllTrue(B1); // only thread 2 is active; result should be true;
15+
break;
16+
default: // thread 3
17+
Out[threadID.x] = WaveActiveAllTrue(B1); // only thread 3 is active; result should be true;
18+
break;
19+
}
20+
Out[threadID.x + 4] = WaveActiveAllTrue(B1); // false because its false for threads 0 and 1
21+
}
22+
23+
//--- pipeline.yaml
24+
25+
---
26+
Shaders:
27+
- Stage: Compute
28+
Entry: main
29+
DispatchSize: [1, 1, 1]
30+
Buffers:
31+
- Name: value
32+
Format: Int32
33+
Data: [ 0, 0, 1, 2]
34+
- Name: Out
35+
Format: UInt32
36+
Stride: 4
37+
ZeroInitSize: 32
38+
- Name: ExpectedOut
39+
Format: UInt32
40+
Stride: 4
41+
Data: [0, 0, 1, 1, 0, 0, 0, 0]
42+
Results:
43+
- Result: Test
44+
Rule: BufferExact
45+
Actual: Out
46+
Expected: ExpectedOut
47+
DescriptorSets:
48+
- Resources:
49+
- Name: value
50+
Kind: RWBuffer
51+
DirectXBinding:
52+
Register: 0
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 0
56+
- Name: Out
57+
Kind: RWStructuredBuffer
58+
DirectXBinding:
59+
Register: 1
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 1
63+
...
64+
#--- end
65+
66+
# RUN: split-file %s %t
67+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
68+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)