Skip to content

Commit d5ba397

Browse files
authored
Simple test for the "saturate" operation (#62)
1 parent b47eeab commit d5ba397

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

test/Feature/HLSLLib/saturate.test

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<float4> In : register(t0);
4+
RWStructuredBuffer<float4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Out[0] = saturate(In[0]);
9+
Out[1].x = saturate(In[1].x);
10+
Out[1].yzw = saturate(In[1].yzw);
11+
Out[2].xy = saturate(In[0].xy);
12+
}
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: [ 0, 1.0, -1.0, -2.0, 84.0, -inf, nan, inf ]
26+
- Name: Out
27+
Format: Float32
28+
Stride: 16
29+
ZeroInitSize: 48
30+
DescriptorSets:
31+
- Resources:
32+
- Name: In
33+
Kind: StructuredBuffer
34+
DirectXBinding:
35+
Register: 0
36+
Space: 0
37+
VulkanBinding:
38+
Binding: 0
39+
- Name: Out
40+
Kind: RWStructuredBuffer
41+
DirectXBinding:
42+
Register: 1
43+
Space: 0
44+
VulkanBinding:
45+
Binding: 1
46+
...
47+
#--- end
48+
49+
# UNSUPPORTED: Clang-Vulkan
50+
# RUN: split-file %s %t
51+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
52+
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s
53+
54+
# CHECK: - Name: In
55+
# CHECK: Format: Float32
56+
57+
# CHECK: - Name: Out
58+
# CHECK: Format: Float32
59+
# CHECK: Data: [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0 ]

0 commit comments

Comments
 (0)