Skip to content

Commit 1a9166e

Browse files
authored
Add test for asfloat (#297)
Add test for asfloat for float, int, and uint inputs. Closes #176
1 parent c19f620 commit 1a9166e

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed

test/Feature/HLSLLib/asfloat.test

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

0 commit comments

Comments
 (0)