Skip to content

Commit c9576bc

Browse files
committed
Adds tests for isnan().
1 parent 0842810 commit c9576bc

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed

test/Feature/HLSLLib/isnan.16.test

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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] = isnan(In[0]);
9+
bool4 Tmp = {isnan(In[0].xyz), isnan(In[0].w)};
10+
Out[1] = Tmp;
11+
Out[2].xy = isnan(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+
FillSize: 48
30+
- Name: ExpectedOut # The result we expect
31+
Format: Bool
32+
Stride: 16
33+
Data: [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]
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+
# Bug https://github.com/llvm/llvm-project/issues/170241
59+
# XFAIL: Clang && Vulkan
60+
61+
# A bug in the Metal Shader Converter caused it to mis-translate this operation.
62+
# Version 3 fixes this issue.
63+
# UNSUPPORTED: Clang && Metal && !metal-shaderconverter-3.0.0-or-later
64+
65+
# REQUIRES: Half
66+
# RUN: split-file %s %t
67+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
68+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/HLSLLib/isnan.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] = isnan(In[0]);
9+
bool4 Tmp = {isnan(In[0].xyz), isnan(In[0].w)};
10+
Out[1] = Tmp;
11+
Out[2].xy = isnan(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+
FillSize: 48
30+
- Name: ExpectedOut # The result we expect
31+
Format: Bool
32+
Stride: 16
33+
Data: [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]
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+
# Bug https://github.com/llvm/llvm-project/issues/170241
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)