Skip to content

Commit 5f0f73d

Browse files
authored
Add reversebits tests (#311)
Closes #135. Adds tests for `reversebits` testing `UInt16`, `UInt32`, `UInt64` types. Some values for 16 bit and 32 bit pulled from [HLK tests](https://github.com/microsoft/DirectXShaderCompiler/blob/57177f77a4dc6996400ac97a0d618799c82374e8/tools/clang/unittests/HLSLExec/ShaderOpArithTable.xml#L2647), but those tested signed ints so ended up not really being the same. No HLK test for 64 bit. Need to remove XFAILs after [#7680](microsoft/DirectXShaderCompiler#7680) and [#152049](llvm/llvm-project#152049) are fixed.
1 parent 83622cc commit 5f0f73d

File tree

3 files changed

+203
-0
lines changed

3 files changed

+203
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<uint16_t4> In : register(t0);
4+
RWStructuredBuffer<uint16_t4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Out[0] = reversebits(In[0]);
9+
uint16_t4 Tmp = {reversebits(In[1].xyz), reversebits(In[1].w)};
10+
Out[1] = Tmp;
11+
uint16_t4 Tmp2 = {reversebits(In[2].xy), reversebits(uint16_t2(0, 256))};
12+
Out[2] = Tmp2;
13+
}
14+
15+
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: UInt16
26+
Stride: 8
27+
Data: [ 0, 1, 8, 0x0100, 0x7FFF, 0xFFFF, 0x5555, 0xF0F0, 0x0F88, 0xC003, 0, 0 ] # Last two are filler
28+
- Name: Out
29+
Format: UInt16
30+
Stride: 8
31+
ZeroInitSize: 24
32+
- Name: ExpectedOut # The result we expect
33+
Format: UInt16
34+
Stride: 8
35+
Data: [ 0, 32768, 4096, 0x0080, 0xFFFE, 0xFFFF, 0xAAAA, 0x0F0F, 0x11F0, 0xC003, 0, 128 ]
36+
Results:
37+
- Result: Test1
38+
Rule: BufferExact
39+
Actual: Out
40+
Expected: ExpectedOut
41+
DescriptorSets:
42+
- Resources:
43+
- Name: In
44+
Kind: StructuredBuffer
45+
DirectXBinding:
46+
Register: 0
47+
Space: 0
48+
VulkanBinding:
49+
Binding: 0
50+
- Name: Out
51+
Kind: RWStructuredBuffer
52+
DirectXBinding:
53+
Register: 1
54+
Space: 0
55+
VulkanBinding:
56+
Binding: 1
57+
...
58+
#--- end
59+
60+
# https://github.com/microsoft/DirectXShaderCompiler/issues/7680
61+
# XFAIL: DXC-Vulkan
62+
63+
# https://github.com/llvm/llvm-project/issues/152049
64+
# XFAIL: Clang-Vulkan
65+
66+
# REQUIRES: Int16
67+
# RUN: split-file %s %t
68+
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
69+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<uint32_t4> In : register(t0);
4+
RWStructuredBuffer<uint32_t4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Out[0] = reversebits(In[0]);
9+
uint32_t4 Tmp = {reversebits(In[1].xyz), reversebits(In[1].w)};
10+
Out[1] = Tmp;
11+
uint32_t4 Tmp2 = {reversebits(In[2].xy), reversebits(uint32_t2(0, 65536))};
12+
Out[2] = Tmp2;
13+
}
14+
15+
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: UInt32
26+
Stride: 16
27+
Data: [ 0, 1, 8, 0x00010000, 0x7FFFFFFF, 0xFFFFFFFF, 0x55555555, 0xF0F0F0F0, 0x0F880F88, 0xC003C003, 0, 0 ] # Last two are filler
28+
- Name: Out
29+
Format: UInt32
30+
Stride: 16
31+
ZeroInitSize: 48
32+
- Name: ExpectedOut # The result we expect
33+
Format: UInt32
34+
Stride: 16
35+
Data: [ 0, 2147483648, 268435456, 0x00008000, 0xFFFFFFFE, 0xFFFFFFFF, 0xAAAAAAAA, 0x0F0F0F0F, 0x11F011F0, 0xC003C003, 0, 32768 ]
36+
Results:
37+
- Result: Test1
38+
Rule: BufferExact
39+
Actual: Out
40+
Expected: ExpectedOut
41+
DescriptorSets:
42+
- Resources:
43+
- Name: In
44+
Kind: StructuredBuffer
45+
DirectXBinding:
46+
Register: 0
47+
Space: 0
48+
VulkanBinding:
49+
Binding: 0
50+
- Name: Out
51+
Kind: RWStructuredBuffer
52+
DirectXBinding:
53+
Register: 1
54+
Space: 0
55+
VulkanBinding:
56+
Binding: 1
57+
...
58+
#--- end
59+
60+
# https://github.com/llvm/llvm-project/issues/152049
61+
# XFAIL: Clang-Vulkan
62+
63+
# RUN: split-file %s %t
64+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
65+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#--- source.hlsl
2+
3+
StructuredBuffer<uint64_t4> In : register(t0);
4+
RWStructuredBuffer<uint64_t4> Out : register(u1);
5+
6+
[numthreads(1,1,1)]
7+
void main() {
8+
Out[0] = reversebits(In[0]);
9+
uint64_t4 Tmp = {reversebits(In[1].xyz), reversebits(In[1].w)};
10+
Out[1] = Tmp;
11+
uint64_t4 Tmp2 = {reversebits(In[2].xy), reversebits(uint64_t2(0, 4294967296))};
12+
Out[2] = Tmp2;
13+
}
14+
15+
16+
//--- pipeline.yaml
17+
18+
---
19+
Shaders:
20+
- Stage: Compute
21+
Entry: main
22+
DispatchSize: [1, 1, 1]
23+
Buffers:
24+
- Name: In
25+
Format: UInt64
26+
Stride: 32
27+
Data: [ 0, 1, 8, 0x0000000100000000, 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0x5555555555555555, 0xF0F0F0F0F0F0F0F0, 0x0F880F880F880F88, 0xC003C003C003C003, 0, 0 ] # Last two are filler
28+
- Name: Out
29+
Format: UInt64
30+
Stride: 32
31+
ZeroInitSize: 96
32+
- Name: ExpectedOut # The result we expect
33+
Format: UInt64
34+
Stride: 32
35+
Data: [ 0, 9223372036854775808, 1152921504606846976, 0x0000000080000000, 0xFFFFFFFFFFFFFFFE, 0xFFFFFFFFFFFFFFFF, 0xAAAAAAAAAAAAAAAA, 0x0F0F0F0F0F0F0F0F, 0x11F011F011F011F0, 0xC003C003C003C003, 0, 2147483648 ]
36+
Results:
37+
- Result: Test1
38+
Rule: BufferExact
39+
Actual: Out
40+
Expected: ExpectedOut
41+
DescriptorSets:
42+
- Resources:
43+
- Name: In
44+
Kind: StructuredBuffer
45+
DirectXBinding:
46+
Register: 0
47+
Space: 0
48+
VulkanBinding:
49+
Binding: 0
50+
- Name: Out
51+
Kind: RWStructuredBuffer
52+
DirectXBinding:
53+
Register: 1
54+
Space: 0
55+
VulkanBinding:
56+
Binding: 1
57+
...
58+
#--- end
59+
60+
# https://github.com/microsoft/DirectXShaderCompiler/issues/7680
61+
# XFAIL: DXC-Vulkan
62+
63+
# https://github.com/llvm/llvm-project/issues/152049
64+
# XFAIL: Clang-Vulkan
65+
66+
# REQUIRES: Int64
67+
# RUN: split-file %s %t
68+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
69+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)