Skip to content

Commit 19c7607

Browse files
committed
add wave prefix count bits tests
1 parent 9cdb2b0 commit 19c7607

File tree

3 files changed

+239
-0
lines changed

3 files changed

+239
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> Out1 : register(u1);
3+
RWStructuredBuffer<uint> Out2 : register(u2);
4+
5+
[WaveSize(128)]
6+
[numthreads(128, 1, 1)]
7+
void main(uint3 tid : SV_GroupThreadID) {
8+
9+
// this should be an ascending sequence of numbers
10+
Out1[tid.x] = WavePrefixCountBits(true);
11+
// this should look more like 1, 1, 2, 2, 3, 3, etc.
12+
Out2[tid.x] = WavePrefixCountBits(tid.x % 2 == 0);
13+
}
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: Out1
24+
Format: UInt32
25+
Stride: 4
26+
FillSize: 512
27+
- Name: ExpectedOut1
28+
Format: UInt32
29+
Stride: 4
30+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
31+
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32+
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
33+
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
34+
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
35+
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
36+
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
37+
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]
38+
39+
- Name: Out2
40+
Format: UInt32
41+
Stride: 4
42+
FillSize: 512
43+
- Name: ExpectedOut2
44+
Format: UInt32
45+
Stride: 4
46+
Data: [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
47+
9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16,
48+
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24,
49+
25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32,
50+
33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40,
51+
41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48,
52+
49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56,
53+
57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63,
54+
64]
55+
Results:
56+
- Result: Test1
57+
Rule: BufferExact
58+
Actual: Out1
59+
Expected: ExpectedOut1
60+
- Result: Test2
61+
Rule: BufferExact
62+
Actual: Out2
63+
Expected: ExpectedOut2
64+
DescriptorSets:
65+
- Resources:
66+
- Name: Out1
67+
Kind: RWStructuredBuffer
68+
DirectXBinding:
69+
Register: 1
70+
Space: 0
71+
VulkanBinding:
72+
Binding: 2
73+
- Name: Out2
74+
Kind: RWStructuredBuffer
75+
DirectXBinding:
76+
Register: 2
77+
Space: 0
78+
VulkanBinding:
79+
Binding: 2
80+
...
81+
#--- end
82+
83+
# REQUIRES: WaveSize_128
84+
85+
# RUN: split-file %s %t
86+
# RUN: %dxc_target -T cs_6_6 -Fo %t.o %t/source.hlsl
87+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> Out1 : register(u1);
3+
RWStructuredBuffer<uint> Out2 : register(u2);
4+
5+
[WaveSize(32)]
6+
[numthreads(32, 1, 1)]
7+
void main(uint3 tid : SV_GroupThreadID) {
8+
9+
// this should be an ascending sequence of numbers
10+
Out1[tid.x] = WavePrefixCountBits(true);
11+
// this should look more like 1, 1, 2, 2, 3, 3, etc.
12+
Out2[tid.x] = WavePrefixCountBits(tid.x % 2 == 0);
13+
}
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: Out1
24+
Format: UInt32
25+
Stride: 4
26+
FillSize: 128
27+
- Name: ExpectedOut1
28+
Format: UInt32
29+
Stride: 4
30+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
31+
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
32+
33+
- Name: Out2
34+
Format: UInt32
35+
Stride: 4
36+
FillSize: 128
37+
- Name: ExpectedOut2
38+
Format: UInt32
39+
Stride: 4
40+
Data: [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
41+
9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16]
42+
Results:
43+
- Result: Test1
44+
Rule: BufferExact
45+
Actual: Out1
46+
Expected: ExpectedOut1
47+
- Result: Test2
48+
Rule: BufferExact
49+
Actual: Out2
50+
Expected: ExpectedOut2
51+
DescriptorSets:
52+
- Resources:
53+
- Name: Out1
54+
Kind: RWStructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 2
60+
- Name: Out2
61+
Kind: RWStructuredBuffer
62+
DirectXBinding:
63+
Register: 2
64+
Space: 0
65+
VulkanBinding:
66+
Binding: 2
67+
...
68+
#--- end
69+
70+
# REQUIRES: WaveSize_32
71+
72+
# RUN: split-file %s %t
73+
# RUN: %dxc_target -T cs_6_6 -Fo %t.o %t/source.hlsl
74+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> Out1 : register(u1);
3+
RWStructuredBuffer<uint> Out2 : register(u2);
4+
5+
[WaveSize(64)]
6+
[numthreads(64, 1, 1)]
7+
void main(uint3 tid : SV_GroupThreadID) {
8+
9+
// this should be an ascending sequence of numbers
10+
Out1[tid.x] = WavePrefixCountBits(true);
11+
// this should look more like 1, 1, 2, 2, 3, 3, etc.
12+
Out2[tid.x] = WavePrefixCountBits(tid.x % 2 == 0);
13+
}
14+
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: Out1
24+
Format: UInt32
25+
Stride: 4
26+
FillSize: 256
27+
- Name: ExpectedOut1
28+
Format: UInt32
29+
Stride: 4
30+
Data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
31+
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32+
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
33+
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
34+
35+
- Name: Out2
36+
Format: UInt32
37+
Stride: 4
38+
FillSize: 256
39+
- Name: ExpectedOut2
40+
Format: UInt32
41+
Stride: 4
42+
Data: [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
43+
9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16,
44+
16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24,
45+
24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32]
46+
Results:
47+
- Result: Test1
48+
Rule: BufferExact
49+
Actual: Out1
50+
Expected: ExpectedOut1
51+
- Result: Test2
52+
Rule: BufferExact
53+
Actual: Out2
54+
Expected: ExpectedOut2
55+
DescriptorSets:
56+
- Resources:
57+
- Name: Out1
58+
Kind: RWStructuredBuffer
59+
DirectXBinding:
60+
Register: 1
61+
Space: 0
62+
VulkanBinding:
63+
Binding: 2
64+
- Name: Out2
65+
Kind: RWStructuredBuffer
66+
DirectXBinding:
67+
Register: 2
68+
Space: 0
69+
VulkanBinding:
70+
Binding: 2
71+
...
72+
#--- end
73+
74+
# REQUIRES: WaveSize_64
75+
76+
# RUN: split-file %s %t
77+
# RUN: %dxc_target -T cs_6_6 -Fo %t.o %t/source.hlsl
78+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)