Skip to content

Commit 9e8e7db

Browse files
authored
Add test for WaveIsFirstLane (#233)
Test divergent control flow and usage of WaveIsFirstLane. Closes #126
1 parent f27d336 commit 9e8e7db

File tree

1 file changed

+66
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)