Skip to content

Commit e667741

Browse files
authored
Add more test for resource arrays without NonUniformResourceIndex (#456)
Adds more tests for multi-dimensional and unbounded resource arrays with constant indices that do not use `NonUniformResourceIndex`.
1 parent d0d5258 commit e667741

File tree

3 files changed

+207
-0
lines changed

3 files changed

+207
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#--- source.hlsl
2+
3+
// Verify handling of subsets of multi-dimensional resource arrays
4+
// used in a function argument.
5+
6+
RWStructuredBuffer<int> In[4][2] : register(u0);
7+
RWStructuredBuffer<int> Out : register(u0, space1);
8+
9+
int foo(RWStructuredBuffer<int> A[2], uint Index) {
10+
return A[0][Index] + A[1][Index];
11+
}
12+
13+
[numthreads(4,1,1)]
14+
void main() {
15+
for (int i = 0; i < 4; i++) {
16+
Out[i] = foo(In[i], i);
17+
}
18+
}
19+
20+
//--- pipeline.yaml
21+
---
22+
Shaders:
23+
- Stage: Compute
24+
Entry: main
25+
DispatchSize: [1, 1, 1]
26+
Buffers:
27+
- Name: BufIn
28+
Format: Int32
29+
ArraySize: 8
30+
Data:
31+
- [ 10, 20, 30, 40 ]
32+
- [ 1, 2, 3, 4 ]
33+
- [ 50, 60, 70, 80 ]
34+
- [ 5, 6, 7, 8 ]
35+
- [ 100, 110, 120, 130 ]
36+
- [ 10, 11, 12, 13 ]
37+
- [ 140, 150, 160, 170 ]
38+
- [ 14, 15, 16, 17 ]
39+
40+
- Name: BufOut
41+
Format: Int32
42+
FillSize: 16
43+
44+
- Name: ExpectedOut
45+
Format: Int32
46+
Data: [ 11, 66, 132, 187 ]
47+
48+
Results:
49+
- Result: BufOut
50+
Rule: BufferExact
51+
Actual: BufOut
52+
Expected: ExpectedOut
53+
54+
DescriptorSets:
55+
- Resources:
56+
- Name: BufIn
57+
Kind: RWStructuredBuffer
58+
DirectXBinding:
59+
Register: 0
60+
Space: 0
61+
- Name: BufOut
62+
Kind: RWStructuredBuffer
63+
DirectXBinding:
64+
Register: 0
65+
Space: 1
66+
...
67+
#--- end
68+
69+
# DXC + Vulkan does not support multi-dimensional resource arrays
70+
# UNSUPPORTED: DXC && Vulkan
71+
72+
# Unimplemented https://github.com/llvm/llvm-project/issues/164908
73+
# XFAIL: Clang && Vulkan
74+
75+
# Unimplemented https://github.com/llvm/offload-test-suite/issues/305
76+
# XFAIL: Metal
77+
78+
# RUN: split-file %s %t
79+
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
80+
# 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+
// Verify handling of unbounded multi-dimensional resource array.
4+
5+
RWStructuredBuffer<int> Buf[][2] : register(u0);
6+
7+
[numthreads(1,1,1)]
8+
void main() {
9+
for (int i = 0; i < 4; i++) {
10+
Buf[1][0][i] = Buf[0][0][i] + Buf[0][1][i];
11+
Buf[1][1][i] = Buf[0][0][i] * Buf[0][1][i];
12+
Buf[0][0][i] += Buf[0][1][i];
13+
}
14+
}
15+
16+
//--- pipeline.yaml
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: Buf
24+
Format: Int32
25+
ArraySize: 4
26+
Data:
27+
- [ 0, 1, 2, 3 ]
28+
- [ 1, 2, 3, 4 ]
29+
- [ 0, 0, 0, 0 ]
30+
- [ 0, 0, 0, 0 ]
31+
32+
- Name: ExpectedBuf
33+
Format: Int32
34+
ArraySize: 4
35+
Data:
36+
- [ 1, 3, 5, 7 ]
37+
- [ 1, 2, 3, 4 ]
38+
- [ 1, 3, 5, 7 ]
39+
- [ 0, 2, 6, 12 ]
40+
41+
Results:
42+
- Result: Buf
43+
Rule: BufferExact
44+
Actual: Buf
45+
Expected: ExpectedBuf
46+
47+
DescriptorSets:
48+
- Resources:
49+
- Name: Buf
50+
Kind: RWStructuredBuffer
51+
DirectXBinding:
52+
Register: 0
53+
Space: 0
54+
...
55+
#--- end
56+
57+
# Unimplemented https://github.com/llvm/offload-test-suite/issues/305
58+
# XFAIL: Metal
59+
60+
# Vulkan does not support multi-dimensional resource arrays
61+
# UNSUPPORTED: Vulkan
62+
63+
# RUN: split-file %s %t
64+
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
65+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#--- source.hlsl
2+
3+
// Verify handling of unbounded resource array.
4+
5+
[[vk::binding(0)]]
6+
RWBuffer<int> Buf[] : register(u0);
7+
8+
[numthreads(4,2,1)]
9+
void main() {
10+
for (int i = 0; i < 4; i++) {
11+
Buf[1][i] = Buf[0][i] * 2;
12+
Buf[2][i] = Buf[0][i] + Buf[1][i];
13+
}
14+
}
15+
16+
//--- pipeline.yaml
17+
---
18+
Shaders:
19+
- Stage: Compute
20+
Entry: main
21+
DispatchSize: [1, 1, 1]
22+
Buffers:
23+
- Name: Buf
24+
Format: Int32
25+
ArraySize: 3
26+
Data:
27+
- [ 1, 2, 3, 4 ]
28+
- [ 0, 0, 0, 0 ]
29+
- [ 0, 0, 0, 0 ]
30+
31+
- Name: ExpectedBuf
32+
Format: Int32
33+
ArraySize: 3
34+
Data:
35+
- [ 1, 2, 3, 4 ]
36+
- [ 2, 4, 6, 8 ]
37+
- [ 3, 6, 9, 12 ]
38+
39+
Results:
40+
- Result: Buf
41+
Rule: BufferExact
42+
Actual: Buf
43+
Expected: ExpectedBuf
44+
45+
DescriptorSets:
46+
- Resources:
47+
- Name: Buf
48+
Kind: RWBuffer
49+
DirectXBinding:
50+
Register: 0
51+
Space: 0
52+
VulkanBinding:
53+
Binding: 0
54+
...
55+
#--- end
56+
57+
# Unimplemented https://github.com/llvm/offload-test-suite/issues/305
58+
# XFAIL: Metal
59+
60+
# RUN: split-file %s %t
61+
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
62+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)