Skip to content

Commit fd7c7bc

Browse files
authored
test for acos (#215)
Test for 16 bit and 32 bit acos
1 parent 621f976 commit fd7c7bc

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

test/Feature/HLSLLib/acos.16.test

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<half4> In : register(t0);
4+
5+
RWStructuredBuffer<half4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = acos(In[0]);
10+
half4 Tmp = {acos(In[1].xyz), acos(In[1].w)};
11+
Out[1] = Tmp;
12+
half4 Tmp2 = {acos(In[2].xy), acos(In[2].zw)};
13+
Out[2] = Tmp2;
14+
}
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: [0x7e00, 0xfc00, 0x8001, 0x8000, 0x0, 0x0001, 0x7c00, 0x3c00, 0xbc00, 0x3e00, 0xbe00, 0x7e00]
28+
# nan, -inf, -denorm, -0, 0, denorm, inf, 1, -1, 1.5, -1.5, nan (filler)
29+
- Name: Out
30+
Format: Float16
31+
Stride: 8
32+
ZeroInitSize: 24
33+
- Name: ExpectedOut # The result we expect
34+
Format: Float16
35+
Stride: 8
36+
Data: [0x7e00, 0x7e00, 0x3e48, 0x3e48, 0x3e48, 0x3e48, 0x7e00, 0x0, 0x4248, 0x7e00, 0x7e00, 0x7e00]
37+
# nan, nan, 1.570796, 1.570796, 1.570796, 1.570796, nan, 0, 3.1415926, nan, nan, nan
38+
Results:
39+
- Result: Test1
40+
Rule: BufferFloatEpsilon
41+
Epsilon: 0.0010
42+
Actual: Out
43+
Expected: ExpectedOut
44+
DescriptorSets:
45+
- Resources:
46+
- Name: In
47+
Kind: StructuredBuffer
48+
DirectXBinding:
49+
Register: 0
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 0
53+
- Name: Out
54+
Kind: RWStructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 1
60+
...
61+
#--- end
62+
63+
# REQUIRES: Half
64+
65+
# RUN: split-file %s %t
66+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
67+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/acos.32.test

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<float4> In : register(t0);
4+
5+
RWStructuredBuffer<float4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = acos(In[0]);
10+
float4 Tmp = {acos(In[1].xyz), acos(In[1].w)};
11+
Out[1] = Tmp;
12+
float4 Tmp2 = {acos(In[2].xy), acos(In[2].zw)};
13+
Out[2] = Tmp2;
14+
}
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: Float32
26+
Stride: 16
27+
Data: [nan, -inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, inf, 1, -1, 1.5, -1.5, nan]
28+
# nan, -inf, -denorm, -0, 0, denorm, inf, 1, -1, 1.5, -1.5, nan
29+
- Name: Out
30+
Format: Float32
31+
Stride: 16
32+
ZeroInitSize: 48
33+
- Name: ExpectedOut # The result we expect
34+
Format: Float32
35+
Stride: 16
36+
Data: [nan, nan, 0x1.921fb6p+0, 0x1.921fb6p+0, 0x1.921fb6p+0, 0x1.921fb6p+0, nan, 0, 3.1415926, nan, nan, nan]
37+
#[nan, nan, 1.570796, 1.570796, 1.570796, 1.570796, nan, 0, 3.14, nan, nan, nan
38+
Results:
39+
- Result: Test1
40+
Rule: BufferFloatEpsilon
41+
Epsilon: 0.0008
42+
Actual: Out
43+
Expected: ExpectedOut
44+
DescriptorSets:
45+
- Resources:
46+
- Name: In
47+
Kind: StructuredBuffer
48+
DirectXBinding:
49+
Register: 0
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 0
53+
- Name: Out
54+
Kind: RWStructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 1
60+
...
61+
#--- end
62+
63+
# RUN: split-file %s %t
64+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
65+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)