Skip to content

Commit 4aeeadd

Browse files
authored
add test for fmod (#301)
Add test for half and float versions of fmod. closes #172
1 parent 41fd913 commit 4aeeadd

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

test/Feature/HLSLLib/fmod.16.test

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#--- source.hlsl
2+
StructuredBuffer<half4> In0 : register(t0);
3+
StructuredBuffer<half4> In1 : register(t1);
4+
5+
RWStructuredBuffer<half4> Out0 : register(u2);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out0[0] = fmod(In0[0], In1[0]);
10+
Out0[1] = half4(fmod(In0[1].xyz, In1[1].xyz), fmod(In0[1].w, In1[1].w));
11+
Out0[2] = half4(fmod(In0[2].xy, In1[2].xy), fmod(In0[2].zw, In1[2].zw));
12+
Out0[3] = fmod(half4(10.5, -99.5, 5, 0.25), half4(1, -3, 0.25, 5));
13+
}
14+
//--- pipeline.yaml
15+
16+
---
17+
Shaders:
18+
- Stage: Compute
19+
Entry: main
20+
DispatchSize: [1, 1, 1]
21+
Buffers:
22+
- Name: In0
23+
Format: Float16
24+
Stride: 8
25+
Data: [0x4940, 0xd638, 0x4500, 0x3400, 0, 0x6056, 0x4940, 0xd638, 0x4500, 0x3400, 0, 0x6056]
26+
# 10.5, -99.5, 5, 0.25, 0, 555, 10.5, -99.5, 5, 0.25, 0, 555
27+
- Name: In1
28+
Format: Float16
29+
Stride: 8
30+
Data: [0x3c00, 0xc200, 0x3400, 0x4500, 0x4900, 0x4100, 0x3c00, 0xc200, 0x3400, 0x4500, 0x4900, 0x4100]
31+
# 1, -3, 0.25, 5, 10, 2.5, 1, -3, 0.25, 5, 10, 2.5
32+
- Name: Out0
33+
Format: Float16
34+
Stride: 8
35+
ZeroInitSize: 32
36+
- Name: ExpectedOut0
37+
Format: Float16
38+
Stride: 8
39+
Data: [ 0x3800, 0xB800, 0x0, 0x3400, 0x0, 0x0, 0x3800, 0xB800, 0x0, 0x3400, 0x0, 0x0, 0x3800, 0xB800, 0x0, 0x3400 ]
40+
# 0.5, -0.5, 0, 0.25, 0, 0, 0.5 -0.5, 0, 0.25, 0, 0, 0.5, -0.5, 0, 0.25
41+
Results:
42+
- Result: Test0
43+
Rule: BufferFloatEpsilon
44+
Epsilon: 0.04
45+
Actual: Out0
46+
Expected: ExpectedOut0
47+
DescriptorSets:
48+
- Resources:
49+
- Name: In0
50+
Kind: StructuredBuffer
51+
DirectXBinding:
52+
Register: 0
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 0
56+
- Name: In1
57+
Kind: StructuredBuffer
58+
DirectXBinding:
59+
Register: 1
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 1
63+
- Name: Out0
64+
Kind: RWStructuredBuffer
65+
DirectXBinding:
66+
Register: 2
67+
Space: 0
68+
VulkanBinding:
69+
Binding: 2
70+
#--- end
71+
72+
# https://github.com/llvm/llvm-project/issues/149561
73+
# XFAIL: Clang-Vulkan
74+
75+
# REQUIRES: Half
76+
# RUN: split-file %s %t
77+
# RUN: %dxc_target -Gis -HV 202x -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
78+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/fmod.32.test

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#--- source.hlsl
2+
StructuredBuffer<float4> In0 : register(t0);
3+
StructuredBuffer<float4> In1 : register(t1);
4+
5+
RWStructuredBuffer<float4> Out0 : register(u2);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out0[0] = fmod(In0[0], In1[0]);
10+
Out0[1] = float4(fmod(In0[1].xyz, In1[1].xyz), fmod(In0[1].w, In1[1].w));
11+
Out0[2] = float4(fmod(In0[2].xy, In1[2].xy), fmod(In0[2].zw, In1[2].zw));
12+
Out0[3] = fmod(float4(10.10, -99.99, 5, 0.25), float4(1.1, -3, 0.25, 5));
13+
}
14+
//--- pipeline.yaml
15+
16+
---
17+
Shaders:
18+
- Stage: Compute
19+
Entry: main
20+
DispatchSize: [1, 1, 1]
21+
Buffers:
22+
- Name: In0
23+
Format: Float32
24+
Stride: 16
25+
Data: [10.10, -99.99, 5, 0.25, 0, 6555.555, 10.10, -99.99, 5, 0.25, 0, 6555.555]
26+
- Name: In1
27+
Format: Float32
28+
Stride: 16
29+
Data: [1.1, -3, 0.25, 5, 10, 2.22, 1.1, -3, 0.25, 5, 10, 2.22]
30+
- Name: Out0
31+
Format: Float32
32+
Stride: 16
33+
ZeroInitSize: 64
34+
- Name: ExpectedOut0
35+
Format: Float32
36+
Stride: 16
37+
Data: [ 0.2, -0.99, 0, 0.25, 0, 2.1154, 0.2, -0.99, 0, 0.25, 0, 2.1154, 0.2, -0.99, 0, 0.25 ]
38+
Results:
39+
- Result: Test0
40+
Rule: BufferFloatEpsilon
41+
Epsilon: 0.0008
42+
Actual: Out0
43+
Expected: ExpectedOut0
44+
DescriptorSets:
45+
- Resources:
46+
- Name: In0
47+
Kind: StructuredBuffer
48+
DirectXBinding:
49+
Register: 0
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 0
53+
- Name: In1
54+
Kind: StructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 1
60+
- Name: Out0
61+
Kind: RWStructuredBuffer
62+
DirectXBinding:
63+
Register: 2
64+
Space: 0
65+
VulkanBinding:
66+
Binding: 2
67+
#--- end
68+
69+
# https://github.com/llvm/llvm-project/issues/149561
70+
# XFAIL: Clang-Vulkan
71+
72+
# RUN: split-file %s %t
73+
# RUN: %dxc_target -Gis -T cs_6_5 -Fo %t.o %t/source.hlsl
74+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)