Skip to content

Commit 73d942b

Browse files
authored
[Matrix] Add structured buffer in struct tests (llvm#1025)
resolves llvm#1008
1 parent 60b8173 commit 73d942b

2 files changed

Lines changed: 159 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#--- source.hlsl
2+
3+
// This test verifies handling of matrix types in RWStructuredBuffer arrays within structs.
4+
5+
struct B {
6+
RWStructuredBuffer<float3x4> Bufs[2];
7+
};
8+
9+
B b1;
10+
B b2;
11+
12+
[numthreads(1,1,1)]
13+
void main() {
14+
float3x4 x = b1.Bufs[0][0];
15+
float3x4 y = b1.Bufs[1][0];
16+
b2.Bufs[0][0] = x + y;
17+
b2.Bufs[1][0] = x - y;
18+
}
19+
20+
//--- pipeline.yaml
21+
---
22+
Shaders:
23+
- Stage: Compute
24+
Entry: main
25+
DispatchSize: [1, 1, 1]
26+
Buffers:
27+
- Name: BufB1
28+
Format: Float32
29+
Stride: 48
30+
ArraySize: 2
31+
Data:
32+
- [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ]
33+
- [ 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0 ]
34+
35+
- Name: BufB2
36+
Format: Float32
37+
Stride: 48
38+
ArraySize: 2
39+
FillSize: 48
40+
41+
- Name: ExpectedBufB2
42+
Format: Float32
43+
Stride: 48
44+
ArraySize: 2
45+
Data:
46+
- [ 1.5, 3.0, 4.5, 6.0, 7.5, 9.0, 10.5, 12.0, 13.5, 15.0, 16.5, 18.0 ]
47+
- [ 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0 ]
48+
49+
Results:
50+
- Result: ExpectedResultB
51+
Rule: BufferFloatULP
52+
ULPT: 0
53+
Actual: BufB2
54+
Expected: ExpectedBufB2
55+
56+
DescriptorSets:
57+
- Resources:
58+
- Name: BufB1
59+
Kind: RWStructuredBuffer
60+
DirectXBinding:
61+
Register: 0
62+
Space: 0
63+
VulkanBinding:
64+
Binding: 0
65+
- Name: BufB2
66+
Kind: RWStructuredBuffer
67+
DirectXBinding:
68+
Register: 2
69+
Space: 0
70+
VulkanBinding:
71+
Binding: 2
72+
...
73+
#--- end
74+
75+
# Unimplemented https://github.com/llvm/wg-hlsl/issues/367
76+
# XFAIL: Clang
77+
78+
# Unimplemented https://github.com/microsoft/DirectXShaderCompiler/issues/8301
79+
# XFAIL: Vulkan && DXC
80+
81+
# Unimplemented https://github.com/llvm/offload-test-suite/issues/305
82+
# XFAIL: Metal
83+
84+
# RUN: split-file %s %t
85+
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
86+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#--- source.hlsl
2+
3+
// This test verifies handling of matrix types in RWStructuredBuffer within structs.
4+
5+
struct A {
6+
RWStructuredBuffer<int3x2> Buf;
7+
};
8+
9+
A a1;
10+
A a2;
11+
12+
[numthreads(1,1,1)]
13+
void main() {
14+
int3x2 m = a1.Buf[0];
15+
a2.Buf[0] = m * 2;
16+
}
17+
18+
//--- pipeline.yaml
19+
---
20+
Shaders:
21+
- Stage: Compute
22+
Entry: main
23+
DispatchSize: [1, 1, 1]
24+
Buffers:
25+
- Name: BufA1
26+
Format: Int32
27+
Stride: 24
28+
Data: [ 1, 2, 3, 4, 5, 6 ]
29+
30+
- Name: BufA2
31+
Format: Int32
32+
Stride: 24
33+
FillSize: 24
34+
35+
- Name: ExpectedBufA2
36+
Format: Int32
37+
Stride: 24
38+
Data: [ 2, 4, 6, 8, 10, 12 ]
39+
Results:
40+
- Result: ExpectedResultA
41+
Rule: BufferExact
42+
Actual: BufA2
43+
Expected: ExpectedBufA2
44+
DescriptorSets:
45+
- Resources:
46+
- Name: BufA1
47+
Kind: RWStructuredBuffer
48+
DirectXBinding:
49+
Register: 0
50+
Space: 0
51+
VulkanBinding:
52+
Binding: 0
53+
- Name: BufA2
54+
Kind: RWStructuredBuffer
55+
DirectXBinding:
56+
Register: 1
57+
Space: 0
58+
VulkanBinding:
59+
Binding: 1
60+
...
61+
#--- end
62+
63+
# Unimplemented https://github.com/llvm/wg-hlsl/issues/367
64+
# XFAIL: Clang
65+
66+
# Unimplemented https://github.com/microsoft/DirectXShaderCompiler/issues/8302
67+
# XFAIL: Vulkan && DXC
68+
69+
70+
# RUN: split-file %s %t
71+
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
72+
# RUN: %offloader %t/pipeline.yaml %t.o
73+

0 commit comments

Comments
 (0)