Skip to content

Commit 2750884

Browse files
authored
add tests for rcp (#269)
add 16, 32, and 64 bit float tests for rcp closes #127
1 parent ff1567c commit 2750884

File tree

3 files changed

+208
-0
lines changed

3 files changed

+208
-0
lines changed

test/Feature/HLSLLib/rcp.16.test

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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] = rcp(In[0]);
10+
half4 Tmp = {rcp(In[1].xyz), rcp(In[1].w)};
11+
Out[1] = Tmp;
12+
half4 Tmp2 = {rcp(In[2].xy), rcp(In[2].zw)};
13+
Out[2] = Tmp2;
14+
Out[3] = rcp(half4(1, 10, 0.2, -4));
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: [ 0x4200, 0x4900, 0x3c00, 0xbc00, 0x4100, 0xb400, 0x4000, 0x3800, 0x4100, 0xb400, 0x4000, 0x3800]
30+
# 3, 10, 1, -1, 2.5, -0.25, 2, 0.5, 2.5, -0.25, 2, 0.5
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: [0x3555, 0x2e66, 0x3c00, 0xbc00, 0x3666, 0xc400, 0x3800, 0x4000, 0x3666, 0xc400, 0x3800, 0x4000, 0x3c00, 0x2e66, 0x4500, 0xb400]
39+
# 0.333, 0.1, 1, -1, 0.4, -4, 0.5, 2, 0.4, -4, 0.5, 2, 1, 0.1, 5, -0.25
40+
Results:
41+
- Result: Test1
42+
Rule: BufferFloatEpsilon
43+
Epsilon: 0.0008
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+
# https://github.com/llvm/llvm-project/issues/149561
66+
# XFAIL: Clang-Vulkan
67+
68+
# REQUIRES: Half
69+
# RUN: split-file %s %t
70+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
71+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/rcp.32.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<float4> In : register(t0);
4+
5+
RWStructuredBuffer<float4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = rcp(In[0]);
10+
float4 Tmp = {rcp(In[1].xyz), rcp(In[1].w)};
11+
Out[1] = Tmp;
12+
float4 Tmp2 = {rcp(In[2].xy), rcp(In[2].zw)};
13+
Out[2] = Tmp2;
14+
Out[3] = rcp(float4(1, 10, 0.2, -4));
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: [3, 10, 1, -1, 2.5, -0.25, 2, 0.5, 2.5, -0.25, 2, 0.432]
30+
- Name: Out
31+
Format: Float32
32+
Stride: 16
33+
ZeroInitSize: 64
34+
- Name: ExpectedOut # The result we expect
35+
Format: Float32
36+
Stride: 16
37+
Data: [0.333333, 0.1, 1, -1, 0.4, -4 , 0.5, 2, 0.4, -4 , 0.5, 2.31481481481, 1, 0.1, 5, -0.25]
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+
# https://github.com/llvm/llvm-project/issues/149561
64+
# XFAIL: Clang-Vulkan
65+
66+
# RUN: split-file %s %t
67+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
68+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/rcp.64.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<double4> In : register(t0);
4+
5+
RWStructuredBuffer<double4> Out : register(u1);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = rcp(In[0]);
10+
double4 Tmp = {rcp(In[1].xyz), rcp(In[1].w)};
11+
Out[1] = Tmp;
12+
double4 Tmp2 = {rcp(In[2].xy), rcp(In[2].zw)};
13+
Out[2] = Tmp2;
14+
Out[3] = rcp(double4(1, 10, 0.2, -4));
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: Float64
28+
Stride: 32
29+
Data: [ 3, 10, 1, -1, 2.5, -0.25, 2, 0.5, 2.5, -0.25, 2, 0.432]
30+
- Name: Out
31+
Format: Float64
32+
Stride: 32
33+
ZeroInitSize: 128
34+
- Name: ExpectedOut # The result we expect
35+
Format: Float64
36+
Stride: 32
37+
Data: [ 0.333333, 0.1, 1, -1, 0.4, -4, 0.5, 2, 0.4, -4, 0.5, 2.31481, 1, 0.1, 5, -0.25 ]
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+
# https://github.com/llvm/llvm-project/issues/149561
64+
# XFAIL: Clang-Vulkan
65+
66+
# REQUIRES: Double
67+
# RUN: split-file %s %t
68+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
69+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)