Skip to content

Commit df2689c

Browse files
authored
Test coverage for arrays in cbuffers (#505)
This adds for arrays of various shapes in cbuffers that were failing before llvm/llvm-project#147352 was implemented, and updates XFAILs appropriately for that change.
1 parent f32409f commit df2689c

File tree

7 files changed

+296
-12
lines changed

7 files changed

+296
-12
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> VOut : register(u1);
3+
RWStructuredBuffer<uint4> WOut : register(u2);
4+
cbuffer Constants : register(b0) {
5+
uint v[4];
6+
uint4 w[4];
7+
}
8+
[numthreads(4, 1, 1)]
9+
void main(uint GI : SV_GroupIndex) {
10+
VOut[GI] = v[GI];
11+
WOut[GI] = w[GI];
12+
}
13+
14+
//--- pipeline.yaml
15+
---
16+
Shaders:
17+
- Stage: Compute
18+
Entry: main
19+
DispatchSize: [1, 1, 1]
20+
Buffers:
21+
- Name: Constants
22+
Format: Hex32
23+
Data: [
24+
0x7, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
25+
0x6, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
26+
0x5, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
27+
0x4, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
28+
0x0, 0x1, 0x2, 0x3,
29+
0x4, 0x5, 0x6, 0x7,
30+
0x8, 0x9, 0xa, 0xb,
31+
0xc, 0xd, 0xe, 0xf,
32+
]
33+
- Name: VOut
34+
Format: UInt32
35+
FillSize: 16
36+
- Name: WOut
37+
Format: UInt32
38+
Channels: 4
39+
FillSize: 64
40+
- Name: ExpectedVOut
41+
Format: UInt32
42+
Data: [ 7, 6, 5, 4 ]
43+
- Name: ExpectedWOut
44+
Format: UInt32
45+
Data: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ]
46+
Results:
47+
- Result: CheckV
48+
Rule: BufferExact
49+
Actual: VOut
50+
Expected: ExpectedVOut
51+
- Result: CheckW
52+
Rule: BufferExact
53+
Actual: WOut
54+
Expected: ExpectedWOut
55+
DescriptorSets:
56+
- Resources:
57+
- Name: Constants
58+
Kind: ConstantBuffer
59+
DirectXBinding:
60+
Register: 0
61+
Space: 0
62+
VulkanBinding:
63+
Binding: 0
64+
- Name: VOut
65+
Kind: RWStructuredBuffer
66+
DirectXBinding:
67+
Register: 1
68+
Space: 0
69+
VulkanBinding:
70+
Binding: 1
71+
- Name: WOut
72+
Kind: RWStructuredBuffer
73+
DirectXBinding:
74+
Register: 2
75+
Space: 0
76+
VulkanBinding:
77+
Binding: 2
78+
...
79+
#--- end
80+
81+
# Unimplemented https://github.com/llvm/llvm-project/issues/159602
82+
# XFAIL: Clang && Vulkan
83+
84+
# RUN: split-file %s %t
85+
# RUN: %dxc_target -fvk-use-dx-layout -T cs_6_5 -Fo %t.o %t/source.hlsl
86+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> Out : register(u1);
3+
4+
struct S {
5+
uint x[2];
6+
uint q;
7+
};
8+
9+
cbuffer cb0 : register(b0) {
10+
uint32_t3 w[3];
11+
S v[3];
12+
}
13+
14+
[numthreads(4, 1, 1)]
15+
void main(uint GI : SV_GroupIndex) {
16+
Out[0] = w[1].y;
17+
Out[1] = w[2].z;
18+
Out[2] = v[1].q;
19+
Out[3] = v[2].q;
20+
Out[4] = v[0].x[0];
21+
Out[5] = v[2].x[1];
22+
}
23+
24+
//--- pipeline.yaml
25+
---
26+
Shaders:
27+
- Stage: Compute
28+
Entry: main
29+
DispatchSize: [1, 1, 1]
30+
Buffers:
31+
- Name: Constants
32+
Format: Hex32
33+
Data: [
34+
0x1, 0x2, 0x3, 0x5A5A5A5A,
35+
0x4, 0x5, 0x6, 0x5A5A5A5A,
36+
0x7, 0x8, 0x9, 0x5A5A5A5A,
37+
0xA, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
38+
0xB, 0x20, 0x5A5A5A5A, 0x5A5A5A5A,
39+
0xC, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
40+
0xD, 0x21, 0x5A5A5A5A, 0x5A5A5A5A,
41+
0xE, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
42+
0xF, 0x22, 0x5A5A5A5A, 0x5A5A5A5A,
43+
]
44+
- Name: VOut
45+
Format: UInt32
46+
FillSize: 4
47+
- Name: Out
48+
Format: UInt32
49+
FillSize: 24
50+
- Name: ExpectedOut
51+
Format: UInt32
52+
Data: [ 5, 9, 33, 34, 10, 15 ]
53+
Results:
54+
- Result: Check
55+
Rule: BufferExact
56+
Actual: Out
57+
Expected: ExpectedOut
58+
DescriptorSets:
59+
- Resources:
60+
- Name: Constants
61+
Kind: ConstantBuffer
62+
DirectXBinding:
63+
Register: 0
64+
Space: 0
65+
VulkanBinding:
66+
Binding: 0
67+
- Name: Out
68+
Kind: RWStructuredBuffer
69+
DirectXBinding:
70+
Register: 1
71+
Space: 0
72+
VulkanBinding:
73+
Binding: 1
74+
...
75+
#--- end
76+
77+
# Unimplemented https://github.com/llvm/llvm-project/issues/159602
78+
# XFAIL: Clang && Vulkan
79+
80+
# RUN: split-file %s %t
81+
# RUN: %dxc_target -fvk-use-dx-layout -T cs_6_5 -Fo %t.o %t/source.hlsl
82+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/CBuffer/array-vec-index.test

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,18 @@ DescriptorSets:
4343
DirectXBinding:
4444
Register: 0
4545
Space: 0
46+
VulkanBinding:
47+
Binding: 0
4648
- Name: Out
4749
Kind: RWStructuredBuffer
4850
DirectXBinding:
4951
Register: 1
5052
Space: 0
53+
VulkanBinding:
54+
Binding: 1
5155
...
5256
#--- end
5357

54-
# DXC's vulkan support does not layout cbuffers compatibly with DXIL
55-
# UNSUPPORTED: Vulkan
56-
57-
# Bug https://github.com/llvm/llvm-project/issues/156084
58-
# XFAIL: Clang
59-
6058
# RUN: split-file %s %t
61-
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
59+
# RUN: %dxc_target -fvk-use-dx-layout -T cs_6_5 -Fo %t.o %t/source.hlsl
6260
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/CBuffer/arrays-16bit.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ DescriptorSets:
8585

8686
# REQUIRES: Half, Int16
8787

88-
# Bug https://github.com/llvm/llvm-project/issues/138996
89-
# XFAIL: Clang
88+
# Unimplemented https://github.com/llvm/llvm-project/issues/159602
89+
# XFAIL: Clang && Vulkan
9090

9191
# RUN: split-file %s %t
9292
# RUN: %dxc_target -fvk-use-dx-layout -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl

test/Feature/CBuffer/arrays.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ DescriptorSets:
9494
#--- end
9595

9696
# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/7819
97-
# XFAIL: Vulkan
98-
# Unimplemented https://github.com/llvm/llvm-project/issues/147352
99-
# XFAIL: Clang
97+
# XFAIL: DXC && Vulkan
98+
# Unimplemented https://github.com/llvm/llvm-project/issues/159602
99+
# XFAIL: Clang && Vulkan
100100

101101
# RUN: split-file %s %t
102102
# RUN: %dxc_target -fvk-use-dx-layout -T cs_6_5 -Fo %t.o %t/source.hlsl
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#--- source.hlsl
2+
RWStructuredBuffer<uint> WOut : register(u1);
3+
RWStructuredBuffer<uint> QOut : register(u2);
4+
RWStructuredBuffer<float> XOut : register(u3);
5+
6+
struct S {
7+
float x[2];
8+
uint q;
9+
};
10+
11+
cbuffer cb0 : register(b0) {
12+
uint32_t3 w[4];
13+
S v[4];
14+
}
15+
16+
[numthreads(4, 1, 1)]
17+
void main(uint GI : SV_GroupIndex) {
18+
WOut[GI] = w[GI].z;
19+
QOut[GI] = v[GI].q;
20+
XOut[GI] = v[GI].x[1];
21+
}
22+
23+
//--- pipeline.yaml
24+
---
25+
Shaders:
26+
- Stage: Compute
27+
Entry: main
28+
DispatchSize: [1, 1, 1]
29+
Buffers:
30+
- Name: Constants
31+
Format: Hex32
32+
Data: [
33+
0x1, 0x2, 0x3, 0x5A5A5A5A,
34+
0x4, 0x5, 0x6, 0x5A5A5A5A,
35+
0x7, 0x8, 0x9, 0x5A5A5A5A,
36+
0xA, 0xB, 0xC, 0x5A5A5A5A,
37+
0x7f7fffff, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
38+
0x3f800000, 0x20, 0x5A5A5A5A, 0x5A5A5A5A,
39+
0xc0000000, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
40+
0x40000000, 0x21, 0x5A5A5A5A, 0x5A5A5A5A,
41+
0x40490fdb, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
42+
0x40400000, 0x22, 0x5A5A5A5A, 0x5A5A5A5A,
43+
0x3eaaaaab, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
44+
0x40800000, 0x23, 0x5A5A5A5A, 0x5A5A5A5A,
45+
]
46+
- Name: WOut
47+
Format: UInt32
48+
FillSize: 16
49+
- Name: QOut
50+
Format: UInt32
51+
FillSize: 16
52+
- Name: XOut
53+
Format: Float32
54+
FillSize: 16
55+
- Name: ExpectedWOut
56+
Format: UInt32
57+
Data: [ 3, 6, 9, 12 ]
58+
- Name: ExpectedQOut
59+
Format: UInt32
60+
Data: [ 32, 33, 34, 35 ]
61+
- Name: ExpectedXOut
62+
Format: Float32
63+
Data: [ 1.0, 2.0, 3.0, 4.0 ]
64+
Results:
65+
- Result: CheckW
66+
Rule: BufferExact
67+
Actual: WOut
68+
Expected: ExpectedWOut
69+
- Result: CheckQ
70+
Rule: BufferExact
71+
Actual: QOut
72+
Expected: ExpectedQOut
73+
- Result: CheckX
74+
Rule: BufferExact
75+
Actual: XOut
76+
Expected: ExpectedXOut
77+
DescriptorSets:
78+
- Resources:
79+
- Name: Constants
80+
Kind: ConstantBuffer
81+
DirectXBinding:
82+
Register: 0
83+
Space: 0
84+
VulkanBinding:
85+
Binding: 0
86+
- Name: WOut
87+
Kind: RWStructuredBuffer
88+
DirectXBinding:
89+
Register: 1
90+
Space: 0
91+
VulkanBinding:
92+
Binding: 1
93+
- Name: QOut
94+
Kind: RWStructuredBuffer
95+
DirectXBinding:
96+
Register: 2
97+
Space: 0
98+
VulkanBinding:
99+
Binding: 2
100+
- Name: XOut
101+
Kind: RWStructuredBuffer
102+
DirectXBinding:
103+
Register: 3
104+
Space: 0
105+
VulkanBinding:
106+
Binding: 3
107+
...
108+
#--- end
109+
110+
# Bug https://github.com/llvm/llvm-project/issues/164517
111+
# XFAIL: Clang
112+
113+
# RUN: split-file %s %t
114+
# RUN: %dxc_target -fvk-use-dx-layout -T cs_6_5 -Fo %t.o %t/source.hlsl
115+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/CBuffer/vectors-16bit.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ DescriptorSets:
5757
...
5858
#--- end
5959

60+
# Unimplemented https://github.com/llvm/llvm-project/issues/159602
61+
# XFAIL: Clang && Vulkan
62+
6063
# REQUIRES: Half, Int16
6164

6265
# RUN: split-file %s %t

0 commit comments

Comments
 (0)