Skip to content

Commit a795d70

Browse files
authored
Add lerp tests (#374)
Closes #134. Adds tests for `lerp` testing `half` and `float`.
1 parent 0b10752 commit a795d70

File tree

2 files changed

+176
-0
lines changed

2 files changed

+176
-0
lines changed

test/Feature/HLSLLib/lerp.16.test

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#--- source.hlsl
2+
StructuredBuffer<half4> X : register(t0);
3+
StructuredBuffer<half4> Y : register(t1);
4+
StructuredBuffer<half4> S : register(t2);
5+
6+
RWStructuredBuffer<half4> Out : register(u3);
7+
8+
9+
[numthreads(1,1,1)]
10+
void main() {
11+
Out[0] = lerp(X[0], Y[0], S[0]);
12+
Out[1] = half4(lerp(X[1].xyz, Y[1].xyz, S[1].xyz), lerp(X[1].w, Y[1].w, S[1].w));
13+
Out[2] = half4(lerp(X[2].xy, Y[2].xy, S[2].xy), lerp(X[2].zw, Y[2].zw, S[2].zw));
14+
Out[3] = lerp(half4(1, 2, -3, 4), half4(8, -7, 6, 5), half4(0.25, 0.5, 0.75, 0));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: X
25+
Format: Float16
26+
Stride: 8
27+
Data: [ 0x3c00, 0x4000, 0xc200, 0x4400, 0x0000, 0x4d13, 0x4fa0, 0x4500, 0xc500, 0xcc00, 0x3c00, 0x4000 ]
28+
# 1, 2, -3, 4, 0, 20.3, 30.5, 5, -5, -16, 1, 2
29+
- Name: Y
30+
Format: Float16
31+
Stride: 8
32+
Data: [ 0x4800, 0xc700, 0x4600, 0x4500, 0x0000, 0x538a, 0x4fa0, 0x4b80, 0xcb80, 0xc800, 0x5640, 0x5a40 ]
33+
# 8, -7, 6, 5, 0, 60.3, 30.5, 15, -15, -8, 100, 200
34+
- Name: S
35+
Format: Float16
36+
Stride: 8
37+
Data: [ 0x3400, 0x3800, 0x3a00, 0x0000, 0x3800, 0x3666, 0x3a66, 0x3a66, 0x3666, 0x38cd, 0x2e66, 0x3b33 ]
38+
# 0.25, 0.5, 0.75, 0, 0.5, 0.4, 0.8, 0.8, 0.4, 0.6, 0.1, 0.9
39+
- Name: Out
40+
Format: Float16
41+
Stride: 8
42+
ZeroInitSize: 32
43+
- Name: ExpectedOut
44+
Format: Float16
45+
Stride: 8
46+
Data: [ 0x4180, 0xc100, 0x4380, 0x4400, 0x0000, 0x508a, 0x4fa0, 0x4a80, 0xc880, 0xc99a, 0x4973, 0x59a2, 0x4180, 0xc100, 0x4380, 0x4400 ]
47+
# 2.75, -2.5, 3.75, 4, 0, 36.3, 30.5, 13, -9, -11.2, 10.9, 180.2, 2.75, -2.5, 3.75, 4
48+
Results:
49+
- Result: Test0
50+
Rule: BufferFloatULP
51+
ULPT: 1
52+
Actual: Out
53+
Expected: ExpectedOut
54+
DescriptorSets:
55+
- Resources:
56+
- Name: X
57+
Kind: StructuredBuffer
58+
DirectXBinding:
59+
Register: 0
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 0
63+
- Name: Y
64+
Kind: StructuredBuffer
65+
DirectXBinding:
66+
Register: 1
67+
Space: 0
68+
VulkanBinding:
69+
Binding: 1
70+
- Name: S
71+
Kind: StructuredBuffer
72+
DirectXBinding:
73+
Register: 2
74+
Space: 0
75+
VulkanBinding:
76+
Binding: 2
77+
- Name: Out
78+
Kind: RWStructuredBuffer
79+
DirectXBinding:
80+
Register: 3
81+
Space: 0
82+
VulkanBinding:
83+
Binding: 3
84+
#--- end
85+
86+
# Bug https://github.com/microsoft/DirectXShaderCompiler/issues/7710
87+
# XFAIL: DXC-Vulkan
88+
89+
# REQUIRES: Half
90+
# RUN: split-file %s %t
91+
# RUN: %dxc_target -enable-16bit-types -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
92+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/lerp.32.test

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#--- source.hlsl
2+
StructuredBuffer<float4> X : register(t0);
3+
StructuredBuffer<float4> Y : register(t1);
4+
StructuredBuffer<float4> S : register(t2);
5+
6+
RWStructuredBuffer<float4> Out : register(u3);
7+
8+
9+
[numthreads(1,1,1)]
10+
void main() {
11+
Out[0] = lerp(X[0], Y[0], S[0]);
12+
Out[1] = float4(lerp(X[1].xyz, Y[1].xyz, S[1].xyz), lerp(X[1].w, Y[1].w, S[1].w));
13+
Out[2] = float4(lerp(X[2].xy, Y[2].xy, S[2].xy), lerp(X[2].zw, Y[2].zw, S[2].zw));
14+
Out[3] = lerp(float4(1, 2, -3, 4), float4(8, -7, 6, 5), float4(0.25, 0.5, 0.75, 0));
15+
}
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: X
25+
Format: Float32
26+
Stride: 16
27+
Data: [ 1, 2, -3, 4, 0, 20.3, 30.5, 5, -5, -16, 1, 2 ]
28+
- Name: Y
29+
Format: Float32
30+
Stride: 16
31+
Data: [ 8, -7, 6, 5, 0, 60.3, 30.5, 15, -15, -8, 100, 200 ]
32+
- Name: S
33+
Format: Float32
34+
Stride: 16
35+
Data: [ 0.25, 0.5, 0.75, 0, 0.5, 0.4, 0.8, 0.8, 0.4, 0.6, 0.1, 0.9 ]
36+
- Name: Out
37+
Format: Float32
38+
Stride: 16
39+
ZeroInitSize: 64
40+
- Name: ExpectedOut
41+
Format: Float32
42+
Stride: 16
43+
Data: [ 2.75, -2.5, 3.75, 4, 0, 36.3, 30.5, 13, -9, -11.2, 10.9, 180.2, 2.75, -2.5, 3.75, 4 ]
44+
Results:
45+
- Result: Test0
46+
Rule: BufferFloatULP
47+
ULPT: 1
48+
Actual: Out
49+
Expected: ExpectedOut
50+
DescriptorSets:
51+
- Resources:
52+
- Name: X
53+
Kind: StructuredBuffer
54+
DirectXBinding:
55+
Register: 0
56+
Space: 0
57+
VulkanBinding:
58+
Binding: 0
59+
- Name: Y
60+
Kind: StructuredBuffer
61+
DirectXBinding:
62+
Register: 1
63+
Space: 0
64+
VulkanBinding:
65+
Binding: 1
66+
- Name: S
67+
Kind: StructuredBuffer
68+
DirectXBinding:
69+
Register: 2
70+
Space: 0
71+
VulkanBinding:
72+
Binding: 2
73+
- Name: Out
74+
Kind: RWStructuredBuffer
75+
DirectXBinding:
76+
Register: 3
77+
Space: 0
78+
VulkanBinding:
79+
Binding: 3
80+
#--- end
81+
82+
# RUN: split-file %s %t
83+
# RUN: %dxc_target -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
84+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)