Skip to content

Commit cf2c894

Browse files
committed
add mad tests
1 parent 266bdd7 commit cf2c894

File tree

5 files changed

+695
-0
lines changed

5 files changed

+695
-0
lines changed

test/Feature/HLSLLib/mad.32.test

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
#--- source.hlsl
2+
StructuredBuffer<float4> M0 : register(t0);
3+
StructuredBuffer<float4> A0 : register(t1);
4+
StructuredBuffer<float4> B0 : register(t2);
5+
StructuredBuffer<int4> M1 : register(t3);
6+
StructuredBuffer<int4> A1 : register(t4);
7+
StructuredBuffer<int4> B1 : register(t5);
8+
StructuredBuffer<uint4> M2 : register(t6);
9+
StructuredBuffer<uint4> A2 : register(t7);
10+
StructuredBuffer<uint4> B2 : register(t8);
11+
12+
RWStructuredBuffer<float4> Out0 : register(u9);
13+
RWStructuredBuffer<int4> Out1 : register(u10);
14+
RWStructuredBuffer<uint4> Out2 : register(u11);
15+
16+
17+
[numthreads(1,1,1)]
18+
void main() {
19+
// float
20+
Out0[0] = mad(M0[0], A0[0], B0[0]);
21+
Out0[1] = float4(mad(M0[1].xyz, A0[1].xyz, B0[1].xyz), mad(M0[1].w, A0[1].w, B0[1].w));
22+
Out0[2] = float4(mad(M0[2].xy, A0[2].xy, B0[2].xy), mad(M0[2].zw, A0[2].zw, B0[2].zw));
23+
Out0[3] = mad(float4(1.0, 1.5, 1e+38, -1e+38), float4(1.0, 10, 4, 4), float4(1.0, -5.5, 0, 0));
24+
25+
// int
26+
Out1[0] = mad(M1[0], A1[0], B1[0]);
27+
Out1[1] = int4(mad(M1[1].xyz, A1[1].xyz, B1[1].xyz), mad(M1[1].w, A1[1].w, B1[1].w));
28+
Out1[2] = int4(mad(M1[2].xy, A1[2].xy, B1[2].xy), mad(M1[2].zw, A1[2].zw, B1[2].zw));
29+
Out1[3] = mad(int4(-2147483647, -256, 2147483647, -2147483648), int4(1, -256, 1, 1), int4(0, 0, 1, -1));
30+
31+
// uint
32+
Out2[0] = mad(M2[0], A2[0], B2[0]);
33+
Out2[1] = uint4(mad(M2[1].xyz, A2[1].xyz, B2[1].xyz), mad(M2[1].w, A2[1].w, B2[1].w));
34+
Out2[2] = uint4(mad(M2[2].xy, A2[2].xy, B2[2].xy), mad(M2[2].zw, A2[2].zw, B2[2].zw));
35+
Out2[3] = mad(uint4(2, 16, 65536, 4294967295), uint4(2, 16, 65536, 1), uint4(1, 15, 1, 1));
36+
}
37+
//--- pipeline.yaml
38+
39+
---
40+
Shaders:
41+
- Stage: Compute
42+
Entry: main
43+
DispatchSize: [1, 1, 1]
44+
Buffers:
45+
- Name: M0
46+
Format: Float32
47+
Stride: 16
48+
Data: [ NaN, -Inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, Inf, 1.0, -1.0, 0, 1, 1.5 ]
49+
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1.0, -1.0, 0, 1, 1.5
50+
- Name: A0
51+
Format: Float32
52+
Stride: 16
53+
Data: [ NaN, -Inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, Inf, 1.0, -1.0, 0, 1, 10 ]
54+
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1.0, -1.0, 0, 1, 10
55+
- Name: B0
56+
Format: Float32
57+
Stride: 16
58+
Data: [ NaN, -Inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, Inf, 1.0, -1.0, 1, 0, -5.5 ]
59+
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 1.0, -1.0, 1, 0, -5.5
60+
- Name: M1
61+
Format: Int32
62+
Stride: 16
63+
Data: [ -2147483647, -256, -1, 0, 1, 2, 16, 2147483647, 1, -1, 1, 10 ]
64+
- Name: A1
65+
Format: Int32
66+
Stride: 16
67+
Data: [ 1, -256, -1, 0, 1, 3, 16, 0, 1, -1, 10, 100 ]
68+
- Name: B1
69+
Format: Int32
70+
Stride: 16
71+
Data: [ 0, 0, 0, 0, 1, 3, 1, 255, 2147483646, -2147483647, -10, -2000 ]
72+
- Name: M2
73+
Format: UInt32
74+
Stride: 16
75+
Data: [ 0, 1, 2, 16, 2147483647, 0, 10, 0, 100, 1000, 65536, 4294967295 ]
76+
- Name: A2
77+
Format: UInt32
78+
Stride: 16
79+
Data: [ 0, 1, 2, 16, 1, 0, 10, 1, 2, 5, 65536, 1 ]
80+
- Name: B2
81+
Format: UInt32
82+
Stride: 16
83+
Data: [ 0, 0, 1, 15, 0, 10, 10, 1, 50, 100, 1, 1 ]
84+
- Name: Out0
85+
Format: Float32
86+
Stride: 16
87+
ZeroInitSize: 64
88+
- Name: ExpectedOut0
89+
Format: Float32
90+
Stride: 16
91+
Data: [ NaN, NaN, 0, 0, 0, 0, Inf, 2, 0, 1, 1, 9.5, 2, 9.5, Inf, -Inf ]
92+
- Name: Out1
93+
Format: Int32
94+
Stride: 16
95+
ZeroInitSize: 64
96+
- Name: ExpectedOut1
97+
Format: Int32
98+
Stride: 16
99+
Data: [ -2147483647, 65536, 1, 0, 2, 9, 257, 255, 2147483647, -2147483646, 0, -1000, -2147483647, 65536, -2147483648, 2147483647 ]
100+
- Name: Out2
101+
Format: UInt32
102+
Stride: 16
103+
ZeroInitSize: 64
104+
- Name: ExpectedOut2
105+
Format: UInt32
106+
Stride: 16
107+
Data: [ 0, 1, 5, 271, 2147483647, 10, 110, 1, 250, 5100, 1, 0, 5, 271, 1, 0 ]
108+
Results:
109+
- Result: Test0
110+
Rule: BufferFloatULP
111+
ULPT: 1
112+
Actual: Out0
113+
Expected: ExpectedOut0
114+
- Result: Test1
115+
Rule: BufferExact
116+
Actual: Out1
117+
Expected: ExpectedOut1
118+
- Result: Test2
119+
Rule: BufferExact
120+
Actual: Out2
121+
Expected: ExpectedOut2
122+
DescriptorSets:
123+
- Resources:
124+
- Name: M0
125+
Kind: StructuredBuffer
126+
DirectXBinding:
127+
Register: 0
128+
Space: 0
129+
VulkanBinding:
130+
Binding: 0
131+
- Name: A0
132+
Kind: StructuredBuffer
133+
DirectXBinding:
134+
Register: 1
135+
Space: 0
136+
VulkanBinding:
137+
Binding: 1
138+
- Name: B0
139+
Kind: StructuredBuffer
140+
DirectXBinding:
141+
Register: 2
142+
Space: 0
143+
VulkanBinding:
144+
Binding: 2
145+
- Name: M1
146+
Kind: StructuredBuffer
147+
DirectXBinding:
148+
Register: 3
149+
Space: 0
150+
VulkanBinding:
151+
Binding: 3
152+
- Name: A1
153+
Kind: StructuredBuffer
154+
DirectXBinding:
155+
Register: 4
156+
Space: 0
157+
VulkanBinding:
158+
Binding: 4
159+
- Name: B1
160+
Kind: StructuredBuffer
161+
DirectXBinding:
162+
Register: 5
163+
Space: 0
164+
VulkanBinding:
165+
Binding: 5
166+
- Name: M2
167+
Kind: StructuredBuffer
168+
DirectXBinding:
169+
Register: 6
170+
Space: 0
171+
VulkanBinding:
172+
Binding: 6
173+
- Name: A2
174+
Kind: StructuredBuffer
175+
DirectXBinding:
176+
Register: 7
177+
Space: 0
178+
VulkanBinding:
179+
Binding: 7
180+
- Name: B2
181+
Kind: StructuredBuffer
182+
DirectXBinding:
183+
Register: 8
184+
Space: 0
185+
VulkanBinding:
186+
Binding: 8
187+
- Name: Out0
188+
Kind: RWStructuredBuffer
189+
DirectXBinding:
190+
Register: 9
191+
Space: 0
192+
VulkanBinding:
193+
Binding: 9
194+
- Name: Out1
195+
Kind: RWStructuredBuffer
196+
DirectXBinding:
197+
Register: 10
198+
Space: 0
199+
VulkanBinding:
200+
Binding: 10
201+
- Name: Out2
202+
Kind: RWStructuredBuffer
203+
DirectXBinding:
204+
Register: 11
205+
Space: 0
206+
VulkanBinding:
207+
Binding: 11
208+
#--- end
209+
210+
# TODO: File bug and link here
211+
# XFAIL: Clang-DirectX
212+
213+
# RUN: split-file %s %t
214+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
215+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/mad.fp16.test

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#--- source.hlsl
2+
StructuredBuffer<half4> M : register(t0);
3+
StructuredBuffer<half4> A : register(t1);
4+
StructuredBuffer<half4> B : register(t2);
5+
6+
RWStructuredBuffer<half4> Out : register(u3);
7+
8+
9+
[numthreads(1,1,1)]
10+
void main() {
11+
Out[0] = mad(M[0], A[0], B[0]);
12+
Out[1] = half4(mad(M[1].xyz, A[1].xyz, B[1].xyz), mad(M[1].w, A[1].w, B[1].w));
13+
Out[2] = half4(mad(M[2].xy, A[2].xy, B[2].xy), mad(M[2].zw, A[2].zw, B[2].zw));
14+
Out[3] = mad(half4(1, 1.5, 300, -300), half4(1, 10, 300, 300), half4(1, -5.5, 1, -1));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: M
25+
Format: Float16
26+
Stride: 8
27+
Data: [ 0x7e00, 0xfc00, 0x03FF, 0x8000, 0x0000, 0x7c00, 0x3c00, 0xbc00, 0x0000, 0x3c00, 0x3e00, 0xc300 ]
28+
# NaN, -Inf, denorm, -0, 0, Inf, 1, -1, 0, 1, 1.5, -3.5
29+
- Name: A
30+
Format: Float16
31+
Stride: 8
32+
Data: [ 0x7e00, 0xfc00, 0x3c00, 0x8000, 0x0000, 0x7c00, 0x3c00, 0xbc00, 0x0000, 0x3c00, 0x4900, 0x4500 ]
33+
# NaN, -Inf, 1, -0, 0, Inf, 1, -1, 0, 1, 10, 5
34+
- Name: B
35+
Format: Float16
36+
Stride: 8
37+
Data: [ 0x7e00, 0xfc00, 0x03FF, 0x8000, 0x0000, 0x7c00, 0x3c00, 0xbc00, 0x3c00, 0x0000, 0xc580, 0x3c00 ]
38+
# NaN, -Inf, denorm, -0, 0, Inf, 1, -1, 1, 0, -5.5, 1
39+
- Name: Out
40+
Format: Float16
41+
Stride: 8
42+
ZeroInitSize: 32
43+
- Name: ExpectedOut
44+
Format: Float16
45+
Stride: 8
46+
Data: [ 0x7e00, 0x7e00, 0x07FE, 0x0000, 0x0000, 0x7c00, 0x4000, 0, 0x3c00, 0x3c00, 0x48c0, 0xcc20, 0x4000, 0x48c0, 0x7c00, 0xfc00 ]
47+
# NaN, NaN, 0.00012195110, 0, 0, Inf, 2, 0, 1, 1, 9.5, -16.5, 2, 9.5, Inf, -Inf
48+
Results:
49+
- Result: Test0
50+
Rule: BufferFloatULP
51+
ULPT: 1
52+
Actual: Out
53+
Expected: ExpectedOut
54+
DescriptorSets:
55+
- Resources:
56+
- Name: M
57+
Kind: StructuredBuffer
58+
DirectXBinding:
59+
Register: 0
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 0
63+
- Name: A
64+
Kind: StructuredBuffer
65+
DirectXBinding:
66+
Register: 1
67+
Space: 0
68+
VulkanBinding:
69+
Binding: 1
70+
- Name: B
71+
Kind: StructuredBuffer
72+
DirectXBinding:
73+
Register: 2
74+
Space: 0
75+
VulkanBinding:
76+
Binding: 2
77+
- Name: Out
78+
Kind: RWStructuredBuffer
79+
DirectXBinding:
80+
Register: 3
81+
Space: 0
82+
VulkanBinding:
83+
Binding: 3
84+
#--- end
85+
86+
# REQUIRES: Half
87+
# RUN: split-file %s %t
88+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
89+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/mad.fp64.test

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#--- source.hlsl
2+
StructuredBuffer<double4> M : register(t0);
3+
StructuredBuffer<double4> A : register(t1);
4+
StructuredBuffer<double4> B : register(t2);
5+
6+
RWStructuredBuffer<double4> Out : register(u3);
7+
8+
9+
[numthreads(1,1,1)]
10+
void main() {
11+
Out[0] = mad(M[0], A[0], B[0]);
12+
Out[1] = double4(mad(M[1].xyz, A[1].xyz, B[1].xyz), mad(M[1].w, A[1].w, B[1].w));
13+
Out[2] = double4(mad(M[2].xy, A[2].xy, B[2].xy), mad(M[2].zw, A[2].zw, B[2].zw));
14+
Out[3] = mad(double4(1.0, 1.5, 1e+308, -1e+308), double4(1.0, 10, 2, 2), double4(1.0, -5.5, 0, 0));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: M
25+
Format: Float64
26+
Stride: 32
27+
Data: [ NaN, -Inf, 0x0.fffffffffffffp-1022, -0, 0, Inf, 1.0, -1.0, 0, 1, 1.5, -3.5 ]
28+
# NaN, -Inf, denorm, -0, 0, Inf, 1.0, -1.0, 0, 1, 1.5, -3.5
29+
- Name: A
30+
Format: Float64
31+
Stride: 32
32+
Data: [ NaN, -Inf, 1, -0, 0, Inf, 1.0, -1.0, 0, 1, 10, 5 ]
33+
# NaN, -Inf, 1, -0, 0, Inf, 1.0, -1.0, 0, 1, 10, 5
34+
- Name: B
35+
Format: Float64
36+
Stride: 32
37+
Data: [ NaN, -Inf, 0x0.fffffffffffffp-1022, -0, 0, Inf, 1.0, -1.0, 1, 0, -5.5, 1 ]
38+
# NaN, -Inf, denorm, -0, 0, Inf, 1.0, -1.0, 1, 0, -5.5, 1
39+
- Name: Out
40+
Format: Float64
41+
Stride: 32
42+
ZeroInitSize: 128
43+
- Name: ExpectedOut
44+
Format: Float64
45+
Stride: 32
46+
Data: [ NaN, NaN, 0x1.ffffffffffffep-1022, 0, 0, Inf, 2, 0, 1, 1, 9.5, -16.5, 2, 9.5, Inf, -Inf ]
47+
Results:
48+
- Result: Test0
49+
Rule: BufferFloatULP
50+
ULPT: 1
51+
Actual: Out
52+
Expected: ExpectedOut
53+
DescriptorSets:
54+
- Resources:
55+
- Name: M
56+
Kind: StructuredBuffer
57+
DirectXBinding:
58+
Register: 0
59+
Space: 0
60+
VulkanBinding:
61+
Binding: 0
62+
- Name: A
63+
Kind: StructuredBuffer
64+
DirectXBinding:
65+
Register: 1
66+
Space: 0
67+
VulkanBinding:
68+
Binding: 1
69+
- Name: B
70+
Kind: StructuredBuffer
71+
DirectXBinding:
72+
Register: 2
73+
Space: 0
74+
VulkanBinding:
75+
Binding: 2
76+
- Name: Out
77+
Kind: RWStructuredBuffer
78+
DirectXBinding:
79+
Register: 3
80+
Space: 0
81+
VulkanBinding:
82+
Binding: 3
83+
#--- end
84+
85+
# TODO: File bug and link here
86+
# XFAIL: DirectX-WARP
87+
88+
# REQUIRES: Double
89+
# RUN: split-file %s %t
90+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
91+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)