Skip to content

Commit f27d336

Browse files
authored
Add test for WaveActiveCountBits (#232)
Test for wave active count bits; Tries to test for divergent control flow and special values of true and false. Closes #166
1 parent 60f4d2c commit f27d336

File tree

1 file changed

+70
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)