Skip to content

Commit 8749cdb

Browse files
authored
Add all tests (#360)
Closes #111. Adds tests for `all` testing 16 bit int types, half, 32 bit types, 64 bit int types, and double. I moved the bool tests from `all.32.test` to a separate file because [this bug](llvm/llvm-project#140824) is causing the vec1 test to fail on Clang, and I didn't want to XFAIL the rest of the 32 bit tests over it. We can combine them in the future once the bug is fixed.
1 parent 2ab4704 commit 8749cdb

File tree

6 files changed

+537
-0
lines changed

6 files changed

+537
-0
lines changed

test/Feature/HLSLLib/all.32.test

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#--- source.hlsl
2+
StructuredBuffer<float4> In0 : register(t0);
3+
StructuredBuffer<int4> In1 : register(t1);
4+
StructuredBuffer<uint4> In2 : register(t2);
5+
6+
RWStructuredBuffer<bool> Out0 : register(u3);
7+
RWStructuredBuffer<bool> Out1 : register(u4);
8+
RWStructuredBuffer<bool> Out2 : register(u5);
9+
10+
11+
[numthreads(1,1,1)]
12+
void main() {
13+
// float
14+
Out0[0] = all(In0[0]);
15+
Out0[1] = all(In0[1].xyz);
16+
Out0[2] = all(In0[1].w);
17+
Out0[3] = all(In0[2].xy);
18+
Out0[4] = all(In0[2].zw);
19+
Out0[5] = all(float4(1.0, -2.5, 0, 4.2));
20+
21+
// int
22+
Out1[0] = all(In1[0]);
23+
Out1[1] = all(In1[1].xyz);
24+
Out1[2] = all(In1[1].w);
25+
Out1[3] = all(In1[2].xy);
26+
Out1[4] = all(In1[2].zw);
27+
Out1[5] = all(int4(1, -2, 0, 4));
28+
29+
// uint
30+
Out2[0] = all(In2[0]);
31+
Out2[1] = all(In2[1].xyz);
32+
Out2[2] = all(In2[1].w);
33+
Out2[3] = all(In2[2].xy);
34+
Out2[4] = all(In2[2].zw);
35+
Out2[5] = all(uint4(1, 2, 0, 4));
36+
}
37+
//--- pipeline.yaml
38+
39+
---
40+
Shaders:
41+
- Stage: Compute
42+
Entry: main
43+
DispatchSize: [1, 1, 1]
44+
Buffers:
45+
- Name: In0
46+
Format: Float32
47+
Stride: 16
48+
Data: [ 1.0, -2.5, 0, 4.5, 2.0, 3.0, 4.0, -5.5, 0, 0, -0.01, 0.01 ]
49+
- Name: In1
50+
Format: Int32
51+
Stride: 16
52+
Data: [ 1, -2, 0, 4, 2, 3, 4, -5, 0, 0, -1, 1 ]
53+
- Name: In2
54+
Format: UInt32
55+
Stride: 16
56+
Data: [ 1, 2, 0, 4, 2, 3, 4, 5, 0, 0, 100, 1 ]
57+
- Name: Out0
58+
Format: Bool
59+
Stride: 4
60+
ZeroInitSize: 24
61+
- Name: ExpectedOut0
62+
Format: Bool
63+
Stride: 4
64+
Data: [ 0, 1, 1, 0, 1, 0 ]
65+
- Name: Out1
66+
Format: Bool
67+
Stride: 4
68+
ZeroInitSize: 24
69+
- Name: ExpectedOut1
70+
Format: Bool
71+
Stride: 4
72+
Data: [ 0, 1, 1, 0, 1, 0 ]
73+
- Name: Out2
74+
Format: Bool
75+
Stride: 4
76+
ZeroInitSize: 24
77+
- Name: ExpectedOut2
78+
Format: Bool
79+
Stride: 4
80+
Data: [ 0, 1, 1, 0, 1, 0 ]
81+
Results:
82+
- Result: Test0
83+
Rule: BufferExact
84+
Actual: Out0
85+
Expected: ExpectedOut0
86+
- Result: Test1
87+
Rule: BufferExact
88+
Actual: Out1
89+
Expected: ExpectedOut1
90+
- Result: Test2
91+
Rule: BufferExact
92+
Actual: Out2
93+
Expected: ExpectedOut2
94+
DescriptorSets:
95+
- Resources:
96+
- Name: In0
97+
Kind: StructuredBuffer
98+
DirectXBinding:
99+
Register: 0
100+
Space: 0
101+
VulkanBinding:
102+
Binding: 0
103+
- Name: In1
104+
Kind: StructuredBuffer
105+
DirectXBinding:
106+
Register: 1
107+
Space: 0
108+
VulkanBinding:
109+
Binding: 1
110+
- Name: In2
111+
Kind: StructuredBuffer
112+
DirectXBinding:
113+
Register: 2
114+
Space: 0
115+
VulkanBinding:
116+
Binding: 2
117+
- Name: Out0
118+
Kind: RWStructuredBuffer
119+
DirectXBinding:
120+
Register: 3
121+
Space: 0
122+
VulkanBinding:
123+
Binding: 3
124+
- Name: Out1
125+
Kind: RWStructuredBuffer
126+
DirectXBinding:
127+
Register: 4
128+
Space: 0
129+
VulkanBinding:
130+
Binding: 4
131+
- Name: Out2
132+
Kind: RWStructuredBuffer
133+
DirectXBinding:
134+
Register: 5
135+
Space: 0
136+
VulkanBinding:
137+
Binding: 5
138+
#--- end
139+
140+
# RUN: split-file %s %t
141+
# RUN: %dxc_target -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
142+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/all.bool.test

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#--- source.hlsl
2+
StructuredBuffer<bool4> In : register(t0);
3+
4+
RWStructuredBuffer<bool> Out : register(u1);
5+
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = all(In[0]);
10+
Out[1] = all(In[1].xyz);
11+
Out[2] = all(In[1].w);
12+
Out[3] = all(In[2].xy);
13+
Out[4] = all(In[2].zw);
14+
Out[5] = all(bool4(1, 1, 0, 1));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: Bool
26+
Stride: 16
27+
Data: [ 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1 ]
28+
- Name: Out
29+
Format: Bool
30+
Stride: 4
31+
ZeroInitSize: 24
32+
- Name: ExpectedOut
33+
Format: Bool
34+
Stride: 4
35+
Data: [ 0, 1, 1, 0, 1, 0 ]
36+
Results:
37+
- Result: Test0
38+
Rule: BufferExact
39+
Actual: Out
40+
Expected: ExpectedOut
41+
DescriptorSets:
42+
- Resources:
43+
- Name: In
44+
Kind: StructuredBuffer
45+
DirectXBinding:
46+
Register: 0
47+
Space: 0
48+
VulkanBinding:
49+
Binding: 0
50+
- Name: Out
51+
Kind: RWStructuredBuffer
52+
DirectXBinding:
53+
Register: 1
54+
Space: 0
55+
VulkanBinding:
56+
Binding: 1
57+
#--- end
58+
59+
# https://github.com/llvm/llvm-project/issues/140824
60+
# XFAIL: Clang
61+
62+
# RUN: split-file %s %t
63+
# RUN: %dxc_target -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
64+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/all.fp16.test

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#--- source.hlsl
2+
StructuredBuffer<half4> In : register(t0);
3+
4+
RWStructuredBuffer<bool> Out : register(u1);
5+
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = all(In[0]);
10+
Out[1] = all(In[1].xyz);
11+
Out[2] = all(In[1].w);
12+
Out[3] = all(In[2].xy);
13+
Out[4] = all(In[2].zw);
14+
Out[5] = all(half4(1.0, -2.5, 0, 4.2));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: Float16
26+
Stride: 8
27+
Data: [ 0x3c00, 0xc100, 0x0000, 0xc480, 0x4000, 0x4200, 0x4400, 0xc580, 0x0000, 0x0000, 0xa11f, 0x211f ]
28+
# 1.0, -2.5, 0, 4.5, 2.0, 3.0, 4.0, -5.5, 0, 0, -0.01, 0.01
29+
- Name: Out
30+
Format: Bool
31+
Stride: 4
32+
ZeroInitSize: 24
33+
- Name: ExpectedOut
34+
Format: Bool
35+
Stride: 4
36+
Data: [ 0, 1, 1, 0, 1, 0 ]
37+
Results:
38+
- Result: Test0
39+
Rule: BufferExact
40+
Actual: Out
41+
Expected: ExpectedOut
42+
DescriptorSets:
43+
- Resources:
44+
- Name: In
45+
Kind: StructuredBuffer
46+
DirectXBinding:
47+
Register: 0
48+
Space: 0
49+
VulkanBinding:
50+
Binding: 0
51+
- Name: Out
52+
Kind: RWStructuredBuffer
53+
DirectXBinding:
54+
Register: 1
55+
Space: 0
56+
VulkanBinding:
57+
Binding: 1
58+
#--- end
59+
60+
# REQUIRES: Half
61+
# RUN: split-file %s %t
62+
# RUN: %dxc_target -enable-16bit-types -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
63+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/all.fp64.test

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#--- source.hlsl
2+
StructuredBuffer<double4> In : register(t0);
3+
4+
RWStructuredBuffer<bool> Out : register(u1);
5+
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = all(In[0]);
10+
Out[1] = all(In[1].xyz);
11+
Out[2] = all(In[1].w);
12+
Out[3] = all(In[2].xy);
13+
Out[4] = all(In[2].zw);
14+
Out[5] = all(double4(1.0, -2.5, 0, 4.2));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: Float64
26+
Stride: 32
27+
Data: [ 1.0, -2.5, 0, 4.5, 2.0, 3.0, 4.0, -5.5, 0, 0, -0.01, 0.01 ]
28+
- Name: Out
29+
Format: Bool
30+
Stride: 4
31+
ZeroInitSize: 24
32+
- Name: ExpectedOut
33+
Format: Bool
34+
Stride: 4
35+
Data: [ 0, 1, 1, 0, 1, 0 ]
36+
Results:
37+
- Result: Test0
38+
Rule: BufferExact
39+
Actual: Out
40+
Expected: ExpectedOut
41+
DescriptorSets:
42+
- Resources:
43+
- Name: In
44+
Kind: StructuredBuffer
45+
DirectXBinding:
46+
Register: 0
47+
Space: 0
48+
VulkanBinding:
49+
Binding: 0
50+
- Name: Out
51+
Kind: RWStructuredBuffer
52+
DirectXBinding:
53+
Register: 1
54+
Space: 0
55+
VulkanBinding:
56+
Binding: 1
57+
#--- end
58+
59+
# REQUIRES: Double
60+
# RUN: split-file %s %t
61+
# RUN: %dxc_target -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
62+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)