Skip to content

Commit 60f4d2c

Browse files
authored
Add test for WaveActiveAnyTrue (#234)
Test control flow divergence and WaveActiveAnyTrue Closes #146
1 parent 81e73ae commit 60f4d2c

File tree

1 file changed

+67
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)