Skip to content

Commit 14fd423

Browse files
authored
Implement tests for isinf (#194)
Implement test for isinf half and isinf float. Closes #165
1 parent 24b29c8 commit 14fd423

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

test/Feature/HLSLLib/isinf.16.test

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<half4> In : register(t0);
4+
RWStructuredBuffer<bool4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Out[0] = isinf(In[0]);
9+
bool4 Tmp = {isinf(In[0].xyz), isinf(In[0].w)};
10+
Out[1] = Tmp;
11+
Out[2].xy = isinf(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: Float16
24+
Stride: 8
25+
Data: [0x7c00, 0xfc00, 0x3c00, 0x7e00] # Inf, -Inf, 1, Nan
26+
- Name: Out
27+
Format: Bool
28+
Stride: 16
29+
ZeroInitSize: 48
30+
- Name: ExpectedOut # The result we expect
31+
Format: Bool
32+
Stride: 16
33+
Data: [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]
34+
Results:
35+
- Result: Test1
36+
Rule: BufferExact
37+
Actual: Out
38+
Expected: ExpectedOut
39+
DescriptorSets:
40+
- Resources:
41+
- Name: In
42+
Kind: StructuredBuffer
43+
DirectXBinding:
44+
Register: 0
45+
Space: 0
46+
VulkanBinding:
47+
Binding: 0
48+
- Name: Out
49+
Kind: RWStructuredBuffer
50+
DirectXBinding:
51+
Register: 1
52+
Space: 0
53+
VulkanBinding:
54+
Binding: 1
55+
...
56+
#--- end
57+
58+
# llvm/llvm-project#141089
59+
# XFAIL: Clang-Vulkan
60+
# issue with 16 bit ops; no hlk tests
61+
# XFAIL: Clang-Metal
62+
63+
# REQUIRES: Half
64+
# RUN: split-file %s %t
65+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
66+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/isinf.32.test

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<float4> In : register(t0);
4+
RWStructuredBuffer<bool4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Out[0] = isinf(In[0]);
9+
bool4 Tmp = {isinf(In[0].xyz), isinf(In[0].w)};
10+
Out[1] = Tmp;
11+
Out[2].xy = isinf(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: [inf, -inf, 1.0, nan] # Inf, -Inf, 1, Nan
26+
- Name: Out
27+
Format: Bool
28+
Stride: 16
29+
ZeroInitSize: 48
30+
- Name: ExpectedOut # The result we expect
31+
Format: Bool
32+
Stride: 16
33+
Data: [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]
34+
Results:
35+
- Result: Test1
36+
Rule: BufferExact
37+
Actual: Out
38+
Expected: ExpectedOut
39+
DescriptorSets:
40+
- Resources:
41+
- Name: In
42+
Kind: StructuredBuffer
43+
DirectXBinding:
44+
Register: 0
45+
Space: 0
46+
VulkanBinding:
47+
Binding: 0
48+
- Name: Out
49+
Kind: RWStructuredBuffer
50+
DirectXBinding:
51+
Register: 1
52+
Space: 0
53+
VulkanBinding:
54+
Binding: 1
55+
...
56+
#--- end
57+
58+
# llvm/llvm-project#141089
59+
# XFAIL: Clang-Vulkan
60+
61+
# RUN: split-file %s %t
62+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
63+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)