Skip to content

Commit 7afb152

Browse files
committed
add min tests
1 parent 9825eb1 commit 7afb152

File tree

5 files changed

+574
-0
lines changed

5 files changed

+574
-0
lines changed

test/Feature/HLSLLib/min.32.test

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
#--- source.hlsl
2+
StructuredBuffer<float4> X0 : register(t0);
3+
StructuredBuffer<float4> Y0 : register(t1);
4+
StructuredBuffer<int4> X1 : register(t2);
5+
StructuredBuffer<int4> Y1 : register(t3);
6+
StructuredBuffer<uint4> X2 : register(t4);
7+
StructuredBuffer<uint4> Y2 : register(t5);
8+
9+
RWStructuredBuffer<float4> Out0 : register(u6);
10+
RWStructuredBuffer<int4> Out1 : register(u7);
11+
RWStructuredBuffer<uint4> Out2 : register(u8);
12+
13+
14+
[numthreads(1,1,1)]
15+
void main() {
16+
// float
17+
Out0[0] = min(X0[0], Y0[0]);
18+
Out0[1] = float4(min(X0[1].xyz, Y0[1].xyz), min(X0[1].w, Y0[1].w));
19+
Out0[2] = float4(min(X0[2].xy, Y0[2].xy), min(X0[2].zw, Y0[2].zw));
20+
Out0[3] = min(X0[3], Y0[3]);
21+
Out0[4] = min(half4(1.0, -1.0, 31408, -415), half4(-1.0, 1.0, 1.5, 129.5));
22+
23+
// int
24+
Out1[0] = min(X1[0], Y1[0]);
25+
Out1[1] = int4(min(X1[1].xyz, Y1[1].xyz), min(X1[1].w, Y1[1].w));
26+
Out1[2] = int4(min(X1[2].xy, Y1[2].xy), min(X1[2].zw, Y1[2].zw));
27+
Out1[3] = min(X1[3], Y1[3]);
28+
Out1[3] = min(int4(-2147483648, -10, 10, 2147483647), int4(0, 10, 10, 0));;
29+
30+
// uint
31+
Out2[0] = min(X2[0], Y2[0]);
32+
Out2[1] = uint4(min(X2[1].xyz, Y2[1].xyz), min(X2[1].w, Y2[1].w));
33+
Out2[2] = uint4(min(X2[2].xy, Y2[2].xy), min(X2[2].zw, Y2[2].zw));
34+
Out2[3] = min(X2[3], Y2[3]);
35+
Out2[3] = min(uint4(0, 0, 10, 10000), uint4(0, 256, 4, 10001));
36+
}
37+
//--- pipeline.yaml
38+
39+
---
40+
Shaders:
41+
- Stage: Compute
42+
Entry: main
43+
DispatchSize: [1, 1, 1]
44+
Buffers:
45+
- Name: X0
46+
Format: Float32
47+
Stride: 16
48+
Data: [ -inf, -inf, -inf, -inf, inf, inf, inf, inf, NaN, NaN, NaN, NaN, 1.0, 1.0, -1.0, -1.0 ]
49+
- Name: Y0
50+
Format: Float32
51+
Stride: 16
52+
Data: [ -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN ]
53+
- Name: X1
54+
Format: Int32
55+
Stride: 16
56+
Data: [ -2147483648, -10, 0, 0, 10, 2147483647, 1000, 2500, 1, -1, 512, -2048 ]
57+
- Name: Y1
58+
Format: Int32
59+
Stride: 16
60+
Data: [ 0, 10, -10, 10, 10, 0, 1500, 2000, -1, 1, 511, -2047 ]
61+
- Name: X2
62+
Format: UInt32
63+
Stride: 16
64+
Data: [ 0, 0, 10, 10000, 2147483647, 4294967295, 1000, 2500, 1, 256, 512, 2048 ]
65+
- Name: Y2
66+
Format: UInt32
67+
Stride: 16
68+
Data: [ 0, 256, 4, 10001, 0, 4294967295, 1500, 2000, 0, 200, 511, 2047 ]
69+
- Name: Out0
70+
Format: Float32
71+
Stride: 16
72+
ZeroInitSize: 80
73+
- Name: ExpectedOut0
74+
Format: Float32
75+
Stride: 16
76+
Data: [ -inf, -inf, -inf, -inf, -inf, inf, 1.0, inf, -inf, inf, 1.0, NaN, -inf, 1.0, -1.0, -1.0, -1.0, -1.0, 1.5, -415 ]
77+
- Name: Out1
78+
Format: Int32
79+
Stride: 16
80+
ZeroInitSize: 64
81+
- Name: ExpectedOut1
82+
Format: Int32
83+
Stride: 16
84+
Data: [ -2147483648, -10, -10, 0, 10, 0, 1000, 2000, -1, -1, 511, -2048, -2147483648, -10, 10, 0 ]
85+
- Name: Out2
86+
Format: UInt32
87+
Stride: 16
88+
ZeroInitSize: 64
89+
- Name: ExpectedOut2
90+
Format: UInt32
91+
Stride: 16
92+
Data: [ 0, 0, 4, 10000, 0, 4294967295, 1000, 2000, 0, 200, 511, 2047, 0, 0, 4, 10000 ]
93+
Results:
94+
- Result: Test0
95+
Rule: BufferFloatEpsilon
96+
Epsilon: 0
97+
Actual: Out0
98+
Expected: ExpectedOut0
99+
- Result: Test1
100+
Rule: BufferExact
101+
Actual: Out1
102+
Expected: ExpectedOut1
103+
- Result: Test2
104+
Rule: BufferExact
105+
Actual: Out2
106+
Expected: ExpectedOut2
107+
DescriptorSets:
108+
- Resources:
109+
- Name: X0
110+
Kind: StructuredBuffer
111+
DirectXBinding:
112+
Register: 0
113+
Space: 0
114+
VulkanBinding:
115+
Binding: 0
116+
- Name: Y0
117+
Kind: StructuredBuffer
118+
DirectXBinding:
119+
Register: 1
120+
Space: 0
121+
VulkanBinding:
122+
Binding: 1
123+
- Name: X1
124+
Kind: StructuredBuffer
125+
DirectXBinding:
126+
Register: 2
127+
Space: 0
128+
VulkanBinding:
129+
Binding: 2
130+
- Name: Y1
131+
Kind: StructuredBuffer
132+
DirectXBinding:
133+
Register: 3
134+
Space: 0
135+
VulkanBinding:
136+
Binding: 3
137+
- Name: X2
138+
Kind: StructuredBuffer
139+
DirectXBinding:
140+
Register: 4
141+
Space: 0
142+
VulkanBinding:
143+
Binding: 4
144+
- Name: Y2
145+
Kind: StructuredBuffer
146+
DirectXBinding:
147+
Register: 5
148+
Space: 0
149+
VulkanBinding:
150+
Binding: 5
151+
- Name: Out0
152+
Kind: RWStructuredBuffer
153+
DirectXBinding:
154+
Register: 6
155+
Space: 0
156+
VulkanBinding:
157+
Binding: 6
158+
- Name: Out1
159+
Kind: RWStructuredBuffer
160+
DirectXBinding:
161+
Register: 7
162+
Space: 0
163+
VulkanBinding:
164+
Binding: 7
165+
- Name: Out2
166+
Kind: RWStructuredBuffer
167+
DirectXBinding:
168+
Register: 8
169+
Space: 0
170+
VulkanBinding:
171+
Binding: 8
172+
#--- end
173+
174+
175+
# RUN: split-file %s %t
176+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
177+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/min.fp16.test

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#--- source.hlsl
2+
StructuredBuffer<half4> X : register(t0);
3+
StructuredBuffer<half4> Y : register(t1);
4+
5+
RWStructuredBuffer<half4> Out : register(u2);
6+
7+
8+
[numthreads(1,1,1)]
9+
void main() {
10+
Out[0] = min(X[0], Y[0]);
11+
Out[1] = half4(min(X[1].xyz, Y[1].xyz), min(X[1].w, Y[1].w));
12+
Out[2] = half4(min(X[2].xy, Y[2].xy), min(X[2].zw, Y[2].zw));
13+
Out[3] = min(X[3], Y[3]);
14+
Out[4] = min(half4(1.0, -1.0, 31408, -415), half4(-1.0, 1.0, 1.5, 129.5));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: X
25+
Format: Float16
26+
Stride: 8
27+
Data: [ 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0x7c00, 0x7c00, 0x7c00, 0x7c00, 0x7e00, 0x7e00, 0x7e00, 0x7e00, 0x3c00, 0x3c00, 0xbc00, 0xbc00 ]
28+
# -inf, -inf, -inf, -inf, inf, inf, inf, inf, NaN, NaN, NaN, NaN, 1.0, 1.0, -1.0, -1.0
29+
- Name: Y
30+
Format: Float16
31+
Stride: 8
32+
Data: [ 0xfc00, 0x7c00, 0x3c00, 0x7e00, 0xfc00, 0x7c00, 0x3c00, 0x7e00, 0xfc00, 0x7c00, 0x3c00, 0x7e00, 0xfc00, 0x7c00, 0x3c00, 0x7e00 ]
33+
# -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN
34+
- Name: Out
35+
Format: Float16
36+
Stride: 8
37+
ZeroInitSize: 40
38+
- Name: ExpectedOut
39+
Format: Float16
40+
Stride: 8
41+
Data: [ 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0xfc00, 0x7c00, 0x3c00, 0x7c00, 0xfc00, 0x7c00, 0x3c00, 0x7e00, 0xfc00, 0x3c00, 0xbc00, 0xbc00, 0xbc00, 0xbc00, 0x3e00, 0xde7c ]
42+
# -inf, -inf, -inf, -inf, -inf, inf, 1.0, inf, -inf, inf, 1.0, NaN, -inf, 1.0, -1.0, -1.0, -1.0, -1.0, 1.5, -415
43+
Results:
44+
- Result: Test0
45+
Rule: BufferFloatEpsilon
46+
Epsilon: 0
47+
Actual: Out
48+
Expected: ExpectedOut
49+
DescriptorSets:
50+
- Resources:
51+
- Name: X
52+
Kind: StructuredBuffer
53+
DirectXBinding:
54+
Register: 0
55+
Space: 0
56+
VulkanBinding:
57+
Binding: 0
58+
- Name: Y
59+
Kind: StructuredBuffer
60+
DirectXBinding:
61+
Register: 1
62+
Space: 0
63+
VulkanBinding:
64+
Binding: 1
65+
- Name: Out
66+
Kind: RWStructuredBuffer
67+
DirectXBinding:
68+
Register: 2
69+
Space: 0
70+
VulkanBinding:
71+
Binding: 2
72+
#--- end
73+
74+
# REQUIRES: Half
75+
# RUN: split-file %s %t
76+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
77+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/min.fp64.test

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#--- source.hlsl
2+
StructuredBuffer<double4> X : register(t0);
3+
StructuredBuffer<double4> Y : register(t1);
4+
5+
RWStructuredBuffer<double4> Out : register(u2);
6+
7+
8+
[numthreads(1,1,1)]
9+
void main() {
10+
Out[0] = min(X[0], Y[0]);
11+
Out[1] = double4(min(X[1].xyz, Y[1].xyz), min(X[1].w, Y[1].w));
12+
Out[2] = double4(min(X[2].xy, Y[2].xy), min(X[2].zw, Y[2].zw));
13+
Out[3] = min(X[3], Y[3]);
14+
Out[4] = min(double4(1.0, -1.0, 31408, -415), double4(-1.0, 1.0, 1.5, 129.5));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: X
25+
Format: Float64
26+
Stride: 32
27+
Data: [ -inf, -inf, -inf, -inf, inf, inf, inf, inf, NaN, NaN, NaN, NaN, 1.0, 1.0, -1.0, -1.0 ]
28+
- Name: Y
29+
Format: Float64
30+
Stride: 32
31+
Data: [ -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN, -inf, inf, 1.0, NaN ]
32+
- Name: Out
33+
Format: Float64
34+
Stride: 32
35+
ZeroInitSize: 160
36+
- Name: ExpectedOut0
37+
Format: Float64
38+
Stride: 32
39+
Data: [ -inf, -inf, -inf, -inf, -inf, inf, 1.0, inf, -inf, inf, 1.0, NaN, -inf, 1.0, -1.0, -1.0, -1.0, -1.0, 1.5, -415 ]
40+
Results:
41+
- Result: Test0
42+
Rule: BufferFloatEpsilon
43+
Epsilon: 0
44+
Actual: Out
45+
Expected: ExpectedOut0
46+
DescriptorSets:
47+
- Resources:
48+
- Name: X
49+
Kind: StructuredBuffer
50+
DirectXBinding:
51+
Register: 0
52+
Space: 0
53+
VulkanBinding:
54+
Binding: 0
55+
- Name: Y
56+
Kind: StructuredBuffer
57+
DirectXBinding:
58+
Register: 1
59+
Space: 0
60+
VulkanBinding:
61+
Binding: 1
62+
- Name: Out
63+
Kind: RWStructuredBuffer
64+
DirectXBinding:
65+
Register: 2
66+
Space: 0
67+
VulkanBinding:
68+
Binding: 2
69+
#--- end
70+
71+
# REQUIRES: Double
72+
# RUN: split-file %s %t
73+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
74+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)