Skip to content

Commit 786a0b1

Browse files
authored
Add WaveActiveBallot tests (#645)
Fixes #96
1 parent d502da2 commit 786a0b1

File tree

3 files changed

+182
-0
lines changed

3 files changed

+182
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint4> Out : register(u1);
3+
4+
[WaveSize(128)]
5+
[numthreads(128, 1, 1)]
6+
void main(uint3 threadID : SV_DispatchThreadID) {
7+
// We expect all resulting uint's bitmask to be
8+
// 0xBFFFFFFF
9+
Out[0] = WaveActiveBallot(threadID.x != 30 && threadID.x != 62 && threadID.x != 94 && threadID.x != 126);
10+
11+
// We expect the first resulting uint's bitmask to be
12+
// 0x0000FFFF, and the second to be 0xFFFF0000
13+
// third and fourth should be 0xFFFFFF00 and 0x00FFFFFF
14+
Out[1] = WaveActiveBallot(threadID.x < 16 || (threadID.x >= 48 && threadID.x < 64) ||
15+
(threadID.x >= 72 && threadID.x < 96) || (threadID.x >= 96 && threadID.x < 120));
16+
17+
// We expect the resulting uint4 to be 4 0x00000000's
18+
Out[2] = WaveActiveBallot(false);
19+
20+
// We expect all resulting uint's bitmask to be
21+
// 0xAAAAAAAA
22+
Out[3] = WaveActiveBallot(threadID.x % 2 == 1);
23+
}
24+
25+
//--- pipeline.yaml
26+
27+
---
28+
Shaders:
29+
- Stage: Compute
30+
Entry: main
31+
DispatchSize: [1, 1, 1]
32+
Buffers:
33+
- Name: Out
34+
Format: UInt32
35+
Stride: 4
36+
FillSize: 64
37+
- Name: ExpectedOut
38+
Format: UInt32
39+
Stride: 4
40+
Data: [3221225471, 3221225471, 3221225471, 3221225471, 65535, 4294901760, 4294967040, 16777215, 0, 0, 0, 0, 2863311530, 2863311530, 2863311530, 2863311530]
41+
Results:
42+
- Result: Test
43+
Rule: BufferExact
44+
Actual: Out
45+
Expected: ExpectedOut
46+
DescriptorSets:
47+
- Resources:
48+
- Name: Out
49+
Kind: RWStructuredBuffer
50+
DirectXBinding:
51+
Register: 1
52+
Space: 0
53+
VulkanBinding:
54+
Binding: 1
55+
...
56+
#--- end
57+
58+
# REQUIRES: WaveSize_128
59+
60+
# RUN: split-file %s %t
61+
# RUN: %dxc_target -T cs_6_6 -Fo %t.o %t/source.hlsl
62+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint4> Out : register(u1);
3+
4+
[WaveSize(32)]
5+
[numthreads(32, 1, 1)]
6+
void main(uint3 threadID : SV_DispatchThreadID) {
7+
// We expect the first resulting uint's bitmask to be
8+
// 0xBFFFFFFF
9+
Out[0] = WaveActiveBallot(threadID.x != 30);
10+
11+
// We expect the first resulting uint's bitmask to be
12+
// 0x0000FFFF
13+
Out[1] = WaveActiveBallot(threadID.x < 16);
14+
15+
// We expect the resulting uint4 to be 4 0x00000000's
16+
Out[2] = WaveActiveBallot(false);
17+
18+
// We expect the first resulting uint's bitmask to be
19+
// 0xAAAAAAAA
20+
Out[3] = WaveActiveBallot(threadID.x % 2 == 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: Out
32+
Format: UInt32
33+
Stride: 4
34+
FillSize: 64
35+
- Name: ExpectedOut
36+
Format: UInt32
37+
Stride: 4
38+
Data: [3221225471, 0, 0, 0, 65535, 0, 0, 0, 0, 0, 0, 0, 2863311530, 0, 0, 0]
39+
Results:
40+
- Result: Test
41+
Rule: BufferExact
42+
Actual: Out
43+
Expected: ExpectedOut
44+
DescriptorSets:
45+
- Resources:
46+
- Name: Out
47+
Kind: RWStructuredBuffer
48+
DirectXBinding:
49+
Register: 1
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 1
53+
...
54+
#--- end
55+
56+
# REQUIRES: WaveSize_32
57+
58+
# RUN: split-file %s %t
59+
# RUN: %dxc_target -T cs_6_6 -Fo %t.o %t/source.hlsl
60+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint4> Out : register(u1);
3+
4+
[WaveSize(64)]
5+
[numthreads(64, 1, 1)]
6+
void main(uint3 threadID : SV_DispatchThreadID) {
7+
// We expect the first and second resulting uint's bitmask to be
8+
// 0xBFFFFFFF
9+
Out[0] = WaveActiveBallot(threadID.x != 30 && threadID.x != 62);
10+
11+
// We expect the first resulting uint's bitmask to be
12+
// 0x0000FFFF, and the second to be 0xFFFF0000
13+
Out[1] = WaveActiveBallot(threadID.x < 16 || threadID.x > 47 );
14+
15+
// We expect the resulting uint4 to be 4 0x00000000's
16+
Out[2] = WaveActiveBallot(false);
17+
18+
// We expect the first and second resulting uint's bitmask to be
19+
// 0xAAAAAAAA
20+
Out[3] = WaveActiveBallot(threadID.x % 2 == 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: Out
32+
Format: UInt32
33+
Stride: 4
34+
FillSize: 64
35+
- Name: ExpectedOut
36+
Format: UInt32
37+
Stride: 4
38+
Data: [3221225471, 3221225471, 0, 0, 65535, 4294901760, 0, 0, 0, 0, 0, 0, 2863311530, 2863311530, 0, 0]
39+
Results:
40+
- Result: Test
41+
Rule: BufferExact
42+
Actual: Out
43+
Expected: ExpectedOut
44+
DescriptorSets:
45+
- Resources:
46+
- Name: Out
47+
Kind: RWStructuredBuffer
48+
DirectXBinding:
49+
Register: 1
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 1
53+
...
54+
#--- end
55+
56+
# REQUIRES: WaveSize_64
57+
58+
# RUN: split-file %s %t
59+
# RUN: %dxc_target -T cs_6_6 -Fo %t.o %t/source.hlsl
60+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)