Skip to content

Commit 3b32d72

Browse files
committed
add normalize tests
1 parent 08d9e93 commit 3b32d72

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#--- source.hlsl
2+
StructuredBuffer<half4> In : register(t0);
3+
4+
RWStructuredBuffer<half4> Out : register(u1);
5+
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = normalize(In[0]);
10+
Out[1] = half4(normalize(In[1].xyz), normalize(In[1].w));
11+
Out[2] = half4(normalize(In[2].xy), normalize(In[2].zw));
12+
Out[3] = normalize(half4(1, 2, -3, 4));
13+
}
14+
//--- pipeline.yaml
15+
16+
---
17+
Shaders:
18+
- Stage: Compute
19+
Entry: main
20+
DispatchSize: [1, 1, 1]
21+
Buffers:
22+
- Name: In
23+
Format: Float16
24+
Stride: 8
25+
Data: [ 0x3c00, 0x4000, 0xc200, 0x4400, 0x0000, 0x44b3, 0xc840, 0x491a, 0x4500, 0x4a00, 0x4200, 0xc400 ]
26+
# 1, 2, -3, 4, 0, 4.7, -8.5, 10.2, 5, 12, 3, -4
27+
- Name: Out
28+
Format: Float16
29+
Stride: 8
30+
ZeroInitSize: 32
31+
- Name: ExpectedOut
32+
Format: Float16
33+
Stride: 8
34+
Data: [ 0x31d8, 0x35d8, 0xb862, 0x39d8, 0, 0x37be, 0xbb00, 0x3c00, 0x3627, 0x3b62, 0x38cd, 0xba66, 0x31d8, 0x35d8, 0xb862, 0x39d8 ]
35+
# 0.18257, 0.36515, -0.54772, 0.73030, 0, 0.48389, -0.87513, 1, 0.38462, 0.92308, 0.6, -0.8, 0.18257, 0.36515, -0.54772, 0.73030
36+
Results:
37+
- Result: Test0
38+
Rule: BufferFloatULP
39+
ULPT: 2
40+
Actual: Out
41+
Expected: ExpectedOut
42+
DescriptorSets:
43+
- Resources:
44+
- Name: In
45+
Kind: StructuredBuffer
46+
DirectXBinding:
47+
Register: 0
48+
Space: 0
49+
VulkanBinding:
50+
Binding: 0
51+
- Name: Out
52+
Kind: RWStructuredBuffer
53+
DirectXBinding:
54+
Register: 1
55+
Space: 0
56+
VulkanBinding:
57+
Binding: 1
58+
#--- end
59+
60+
# REQUIRES: Half
61+
# RUN: split-file %s %t
62+
# RUN: %dxc_target -enable-16bit-types -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
63+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#--- source.hlsl
2+
StructuredBuffer<float4> In : register(t0);
3+
4+
RWStructuredBuffer<float4> Out : register(u1);
5+
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
Out[0] = normalize(In[0]);
10+
Out[1] = float4(normalize(In[1].xyz), normalize(In[1].w));
11+
Out[2] = float4(normalize(In[2].xy), normalize(In[2].zw));
12+
Out[3] = normalize(float4(1, 2, -3, 4));
13+
}
14+
//--- pipeline.yaml
15+
16+
---
17+
Shaders:
18+
- Stage: Compute
19+
Entry: main
20+
DispatchSize: [1, 1, 1]
21+
Buffers:
22+
- Name: In
23+
Format: Float32
24+
Stride: 16
25+
Data: [ 1, 2, -3, 4, 0, 4.7, -8.5, 10.2, 5, 12, 3, -4 ]
26+
- Name: Out
27+
Format: Float32
28+
Stride: 16
29+
ZeroInitSize: 64
30+
- Name: ExpectedOut
31+
Format: Float32
32+
Stride: 16
33+
Data: [ 0.18257, 0.36515, -0.54772, 0.73030, 0, 0.48389, -0.87513, 1, 0.38462, 0.92308, 0.6, -0.8, 0.18257, 0.36515, -0.54772, 0.73030 ]
34+
Results:
35+
- Result: Test0
36+
Rule: BufferFloatEpsilon
37+
Epsilon: 0.008
38+
Actual: Out
39+
Expected: ExpectedOut
40+
DescriptorSets:
41+
- Resources:
42+
- Name: In
43+
Kind: StructuredBuffer
44+
DirectXBinding:
45+
Register: 0
46+
Space: 0
47+
VulkanBinding:
48+
Binding: 0
49+
- Name: Out
50+
Kind: RWStructuredBuffer
51+
DirectXBinding:
52+
Register: 1
53+
Space: 0
54+
VulkanBinding:
55+
Binding: 1
56+
#--- end
57+
58+
# RUN: split-file %s %t
59+
# RUN: %dxc_target -HV 202x -T cs_6_5 -Fo %t.o %t/source.hlsl
60+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)