Skip to content

Commit 15c5bb3

Browse files
authored
add tests for floor (#244)
add 16 and 32 bit float tests for floor closes #138
1 parent 6316201 commit 15c5bb3

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

test/Feature/HLSLLib/floor.16.test

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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] = floor(In[0]);
10+
half4 Tmp = {floor(In[1].xyz), floor(In[1].w)};
11+
Out[1] = Tmp;
12+
half4 Tmp2 = {floor(In[2].xy), floor(In[2].zw)};
13+
Out[2] = Tmp2;
14+
Out[3] = floor(In[3]);
15+
}
16+
17+
18+
//--- pipeline.yaml
19+
20+
---
21+
Shaders:
22+
- Stage: Compute
23+
Entry: main
24+
DispatchSize: [1, 1, 1]
25+
Buffers:
26+
- Name: In
27+
Format: Float16
28+
Stride: 8
29+
Data: [ 0x7e00, 0xfc00, 0x8001, 0x8000, 0x0000, 0x0001, 0x7c00, 0x4900, 0x4933, 0x4940, 0x494d, 0xc900, 0xc933, 0xc940, 0xc94d, 0x7e00,]
30+
# NaN, -Inf, -denorm, -0, 0, denorm, Inf, 10.0, 10.4, 10.5, 10.6, -10.0, -10.4, -10.5, -10.6,
31+
- Name: Out
32+
Format: Float16
33+
Stride: 8
34+
ZeroInitSize: 32
35+
- Name: ExpectedOut # The result we expect
36+
Format: Float16
37+
Stride: 8
38+
Data: [ 0x7e00, 0xfc00, 0xbc00, 0x8000, 0x0000, 0x0000, 0x7c00, 0x4900, 0x4900, 0x4900, 0x4900, 0xc900, 0xc980, 0xc980, 0xc980, 0x7e00,]
39+
# NaN, -Inf, -1, -0, 0, 0, Inf, 10.0, 10.0, 10.0, 10.0, -10.0, -11.0, -11.0, -11.0,
40+
Results:
41+
- Result: Test1
42+
Rule: BufferFloatEpsilon
43+
Epsilon: 0
44+
Actual: Out
45+
Expected: ExpectedOut
46+
DescriptorSets:
47+
- Resources:
48+
- Name: In
49+
Kind: StructuredBuffer
50+
DirectXBinding:
51+
Register: 0
52+
Space: 0
53+
VulkanBinding:
54+
Binding: 0
55+
- Name: Out
56+
Kind: RWStructuredBuffer
57+
DirectXBinding:
58+
Register: 1
59+
Space: 0
60+
VulkanBinding:
61+
Binding: 1
62+
...
63+
#--- end
64+
65+
# REQUIRES: Half
66+
# RUN: split-file %s %t
67+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
68+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/floor.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] = floor(In[0]);
10+
float4 Tmp = {floor(In[1].xyz), floor(In[1].w)};
11+
Out[1] = Tmp;
12+
float4 Tmp2 = {floor(In[2].xy), floor(In[2].zw)};
13+
Out[2] = Tmp2;
14+
Out[3] = floor(In[3]);
15+
}
16+
17+
18+
//--- pipeline.yaml
19+
20+
---
21+
Shaders:
22+
- Stage: Compute
23+
Entry: main
24+
DispatchSize: [1, 1, 1]
25+
Buffers:
26+
- Name: In
27+
Format: Float32
28+
Stride: 16
29+
Data: [ nan, -inf, 0, -0, 0, 0x1.e7d42cp-127, inf, 10.0, 10.4, 10.5, 10.6, -10.0, -10.4, -10.5, -10.6, nan,]
30+
# NaN, -Inf, 0, -0, 0, denorm, Inf, 10.0, 10.4, 10.5, 10.6, -10.0, -10.4, -10.5, -10.6,
31+
- Name: Out
32+
Format: Float32
33+
Stride: 16
34+
ZeroInitSize: 64
35+
- Name: ExpectedOut # The result we expect
36+
Format: Float32
37+
Stride: 16
38+
Data: [ nan, -inf, 0, -0, 0, 0, inf, 10.0, 10.0, 10.0, 10.0, -10.0, -11.0, -11.0, -11.0, nan,]
39+
# NaN, -Inf, 0, -0, 0, 0, Inf, 10.0, 10.0, 10.0, 10.0, -10.0, -11.0, -11.0, -11.0,
40+
Results:
41+
- Result: Test1
42+
Rule: BufferFloatEpsilon
43+
Epsilon: 0
44+
Actual: Out
45+
Expected: ExpectedOut
46+
DescriptorSets:
47+
- Resources:
48+
- Name: In
49+
Kind: StructuredBuffer
50+
DirectXBinding:
51+
Register: 0
52+
Space: 0
53+
VulkanBinding:
54+
Binding: 0
55+
- Name: Out
56+
Kind: RWStructuredBuffer
57+
DirectXBinding:
58+
Register: 1
59+
Space: 0
60+
VulkanBinding:
61+
Binding: 1
62+
...
63+
#--- end
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)