Skip to content

Commit 46b90ec

Browse files
authored
add tests for cos (#247)
add 16 and 32 bit float tests for cos closes #114
1 parent 18a0d6b commit 46b90ec

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

test/Feature/HLSLLib/cos.16.test

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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] = cos(In[0]);
10+
half4 Tmp = {cos(In[1].xyz), cos(In[1].w)};
11+
Out[1] = Tmp;
12+
half4 Tmp2 = {cos(In[2].xy), cos(In[2].zw)};
13+
Out[2] = Tmp2;
14+
Out[3] = cos(In[3]);
15+
Out[4] = cos(In[4]);
16+
}
17+
18+
19+
//--- pipeline.yaml
20+
21+
---
22+
Shaders:
23+
- Stage: Compute
24+
Entry: main
25+
DispatchSize: [1, 1, 1]
26+
Buffers:
27+
- Name: In
28+
Format: Float16
29+
Stride: 8
30+
Data: [ 0x7e00, 0xfc00, 0x8001, 0x8000, 0x0000, 0x0001, 0x7c00, 0x3906, 0x3d06, 0x3f8a, 0x4106, 0x4248, 0x438a, 0x4466, 0x4506, 0x45a7, 0x4648, 0x7e00, 0x7e00, 0x7e00,]
31+
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 0.6279297, 1.255859, 1.884766, 2.511719, 3.140625, 3.769531, 4.398438, 5.023438, 5.652344, 6.281250,
32+
- Name: Out
33+
Format: Float16
34+
Stride: 8
35+
ZeroInitSize: 40
36+
- Name: ExpectedOut # The result we expect
37+
Format: Float16
38+
Stride: 8
39+
Data: [ 0x7e00, 0x7e00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x7e00, 0x3a79, 0x34f5, 0xb4f1, 0xba77, 0xbc00, 0xba79, 0xb4f1, 0x34e6, 0x3a76, 0x3c00, 0x7e00, 0x7e00, 0x7e00,]
40+
# NaN, NaN, 1.0, 1.0, 1.0, 1.0, NaN, 0.80924553, 0.30975693, -0.30883664, -0.80810183, -0.99999952, -0.80924052, -0.30881903, 0.30605716, 0.80753154, 0.99999809,
41+
Results:
42+
- Result: Test1
43+
Rule: BufferFloatEpsilon
44+
Epsilon: 0.003
45+
Actual: Out
46+
Expected: ExpectedOut
47+
DescriptorSets:
48+
- Resources:
49+
- Name: In
50+
Kind: StructuredBuffer
51+
DirectXBinding:
52+
Register: 0
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 0
56+
- Name: Out
57+
Kind: RWStructuredBuffer
58+
DirectXBinding:
59+
Register: 1
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 1
63+
...
64+
#--- end
65+
66+
# REQUIRES: Half
67+
# RUN: split-file %s %t
68+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
69+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/cos.32.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<float4> In : register(t0);
4+
5+
RWStructuredBuffer<float4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = cos(In[0]);
10+
float4 Tmp = {cos(In[1].xyz), cos(In[1].w)};
11+
Out[1] = Tmp;
12+
float4 Tmp2 = {cos(In[2].xy), cos(In[2].zw)};
13+
Out[2] = Tmp2;
14+
}
15+
16+
17+
//--- pipeline.yaml
18+
19+
---
20+
Shaders:
21+
- Stage: Compute
22+
Entry: main
23+
DispatchSize: [1, 1, 1]
24+
Buffers:
25+
- Name: In
26+
Format: Float32
27+
Stride: 16
28+
Data: [ nan, -inf, -0x1.e7d42cp-127, -0, 0, 0x1.e7d42cp-127, inf, -314.16, 314.16, nan, nan, nan,]
29+
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, -314.16, 314.16,
30+
- Name: Out
31+
Format: Float32
32+
Stride: 16
33+
ZeroInitSize: 48
34+
- Name: ExpectedOut # The result we expect
35+
Format: Float32
36+
Stride: 16
37+
Data: [ nan, nan, 1.0, 1.0, 1.0, 1.0, nan, 0.99999973015, 0.99999973015, nan, nan, nan,]
38+
# NaN, NaN, 1.0, 1.0, 1.0, 1.0, NaN, 0.99999973015, 0.99999973015,
39+
Results:
40+
- Result: Test1
41+
Rule: BufferFloatEpsilon
42+
Epsilon: 0.0008
43+
Actual: Out
44+
Expected: ExpectedOut
45+
DescriptorSets:
46+
- Resources:
47+
- Name: In
48+
Kind: StructuredBuffer
49+
DirectXBinding:
50+
Register: 0
51+
Space: 0
52+
VulkanBinding:
53+
Binding: 0
54+
- Name: Out
55+
Kind: RWStructuredBuffer
56+
DirectXBinding:
57+
Register: 1
58+
Space: 0
59+
VulkanBinding:
60+
Binding: 1
61+
...
62+
#--- end
63+
64+
65+
# RUN: split-file %s %t
66+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
67+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)