Skip to content

Commit 6aae421

Browse files
authored
Add step tests (#354)
Closes #154. Adds tests for `step` testing `half` and `float`.
1 parent 4aeeadd commit 6aae421

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

test/Feature/HLSLLib/step.16.test

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#--- source.hlsl
2+
StructuredBuffer<half4> Y : register(t0);
3+
StructuredBuffer<half4> X : register(t1);
4+
5+
RWStructuredBuffer<half4> Out : register(u2);
6+
7+
8+
[numthreads(1,1,1)]
9+
void main() {
10+
Out[0] = step(Y[0], X[0]);
11+
Out[1] = half4(step(Y[1].xyz, X[1].xyz), step(Y[1].w, X[1].w));
12+
Out[2] = half4(step(Y[2].xy, X[2].xy), step(Y[2].zw, X[2].zw));
13+
Out[3] = step(half4(0.0, 1.0, 2.0, -2.0), half4(0.0, 1.0, 1.999, -1.999));
14+
}
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: Y
24+
Format: Float16
25+
Stride: 8
26+
Data: [ 0x0000, 0x3c00, 0x4000, 0xc000, 0x429a, 0x489a, 0x7207, 0xd971, 0xc44d, 0x4248, 0x0011, 0x7bff ]
27+
# 0.0, 1.0, 2.0, -2.0, 3.3, 9.2, 12344, -174.12, -4.3, 3.14159, 0.000001, 65504
28+
- Name: X
29+
Format: Float16
30+
Stride: 8
31+
Data: [ 0x0000, 0x3c00, 0x3fff, 0xbfff, 0x474d, 0x419a, 0x7207, 0xe00a, 0x444d, 0x4170, 0x0022, 0x7bff ]
32+
# 0.0, 1.0, 1.999, -1.999, 7.3, 2.8, 12345, -517.23, 4.3, 2.71828, 0.000002, 65504
33+
- Name: Out
34+
Format: Float16
35+
Stride: 8
36+
ZeroInitSize: 32
37+
- Name: ExpectedOut
38+
Format: Float16
39+
Stride: 8
40+
Data: [ 0x3c00, 0x3c00, 0, 0x3c00, 0x3c00, 0, 0x3c00, 0, 0x3c00, 0, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0, 0x3c00 ]
41+
# 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1
42+
Results:
43+
- Result: Test
44+
Rule: BufferExact
45+
Actual: Out
46+
Expected: ExpectedOut
47+
DescriptorSets:
48+
- Resources:
49+
- Name: Y
50+
Kind: StructuredBuffer
51+
DirectXBinding:
52+
Register: 0
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 0
56+
- Name: X
57+
Kind: StructuredBuffer
58+
DirectXBinding:
59+
Register: 1
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 1
63+
- Name: Out
64+
Kind: RWStructuredBuffer
65+
DirectXBinding:
66+
Register: 2
67+
Space: 0
68+
VulkanBinding:
69+
Binding: 2
70+
#--- end
71+
72+
# REQUIRES: Half
73+
# RUN: split-file %s %t
74+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
75+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/step.32.test

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#--- source.hlsl
2+
StructuredBuffer<float4> Y : register(t0);
3+
StructuredBuffer<float4> X : register(t1);
4+
5+
RWStructuredBuffer<float4> Out : register(u2);
6+
7+
8+
[numthreads(1,1,1)]
9+
void main() {
10+
Out[0] = step(Y[0], X[0]);
11+
Out[1] = float4(step(Y[1].xyz, X[1].xyz), step(Y[1].w, X[1].w));
12+
Out[2] = float4(step(Y[2].xy, X[2].xy), step(Y[2].zw, X[2].zw));
13+
Out[3] = step(float4(0.0, 1.0, 2.0, -2.0), float4(0.0, 1.0, 1.999, -1.999));
14+
}
15+
//--- pipeline.yaml
16+
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: Y
24+
Format: Float32
25+
Stride: 16
26+
Data: [ 0.0, 1.0, 2.0, -2.0, 3.3, 9.2, 12344, -174.12, -4.3, 3.14159, 0.000001, 3e+38 ]
27+
- Name: X
28+
Format: Float32
29+
Stride: 16
30+
Data: [ 0.0, 1.0, 1.999, -1.999, 7.3, 2.8, 12345, -517.23, 4.3, 2.71828, 0.000002, 3e+38 ]
31+
- Name: Out
32+
Format: Float32
33+
Stride: 16
34+
ZeroInitSize: 64
35+
- Name: ExpectedOut
36+
Format: Float32
37+
Stride: 16
38+
Data: [ 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1 ]
39+
Results:
40+
- Result: Test
41+
Rule: BufferExact
42+
Actual: Out
43+
Expected: ExpectedOut
44+
DescriptorSets:
45+
- Resources:
46+
- Name: Y
47+
Kind: StructuredBuffer
48+
DirectXBinding:
49+
Register: 0
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 0
53+
- Name: X
54+
Kind: StructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 1
60+
- Name: Out
61+
Kind: RWStructuredBuffer
62+
DirectXBinding:
63+
Register: 2
64+
Space: 0
65+
VulkanBinding:
66+
Binding: 2
67+
#--- end
68+
69+
70+
# RUN: split-file %s %t
71+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
72+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)