Skip to content

Commit b1bef3d

Browse files
authored
Add GetDimensions tests for {RW}Buffer and {RW}ByteAddressBuffer (#464)
Add `GetDimensions` tests for `{RW}Buffer` and `{RW}ByteAddressBuffer`. Update existing `GetDimensions` tests for structured buffers to use `Results:` construct instead of `FileCheck` to verify the results, and move them into directory with other tests related to structured buffers. Rename `RawBuffers` directory to `ByteAddressBuffers`. The name was confusing because structured buffers are also raw buffers, and we usually have these separate. Closes #448
1 parent 915a188 commit b1bef3d

File tree

4 files changed

+213
-17
lines changed

4 files changed

+213
-17
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#--- source.hlsl
2+
3+
// This test checks that we will get the expected values from invoking
4+
// `GetDimension`s on typed buffers RWBuffer and Buffer.
5+
6+
ByteAddressBuffer A : register(t0);
7+
RWByteAddressBuffer B : register(u1);
8+
9+
[[vk::binding(10)]]
10+
RWBuffer<uint> Out : register(u10);
11+
12+
[numthreads(1,1,1)]
13+
void main() {
14+
uint dim;
15+
16+
A.GetDimensions(dim);
17+
Out[0] = dim;
18+
19+
B.GetDimensions(dim);
20+
Out[1] = dim;
21+
}
22+
23+
//--- pipeline.yaml
24+
25+
---
26+
Shaders:
27+
- Stage: Compute
28+
Entry: main
29+
DispatchSize: [4, 1, 1]
30+
31+
Buffers:
32+
- Name: A
33+
Format: Int32
34+
Data: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
35+
36+
- Name: B
37+
Format: Hex32
38+
Data: [ 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700 ]
39+
40+
- Name: Out
41+
Format: Int32
42+
ZeroInitSize: 8
43+
44+
- Name: ExpectedOut
45+
Format: Int32
46+
Data: [ 56, 28 ]
47+
48+
Results:
49+
- Result: Out
50+
Rule: BufferExact
51+
Actual: Out
52+
Expected: ExpectedOut
53+
54+
DescriptorSets:
55+
- Resources:
56+
- Name: A
57+
Kind: ByteAddressBuffer
58+
DirectXBinding:
59+
Register: 0
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 0
63+
64+
- Name: B
65+
Kind: RWByteAddressBuffer
66+
DirectXBinding:
67+
Register: 1
68+
Space: 0
69+
VulkanBinding:
70+
Binding: 1
71+
72+
- Name: Out
73+
Kind: RWBuffer
74+
DirectXBinding:
75+
Register: 10
76+
Space: 0
77+
VulkanBinding:
78+
Binding: 10
79+
...
80+
#--- end
81+
82+
# Unimplemented https://github.com/llvm/wg-hlsl/issues/126
83+
# XFAIL: Clang
84+
85+
# RUN: split-file %s %t
86+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
87+
# RUN: %offloader %t/pipeline.yaml %t.o

test/Feature/RawBuffers/GetDimensions-compute.test renamed to test/Feature/StructuredBuffer/GetDimensions.test

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ struct S {
1414
};
1515

1616
StructuredBuffer<R> A : register(t0);
17-
RWStructuredBuffer<S> B : register(u0);
18-
AppendStructuredBuffer<R> C : register(u1);
19-
ConsumeStructuredBuffer<S> D : register(u2);
17+
RWStructuredBuffer<S> B : register(u1);
18+
AppendStructuredBuffer<R> C : register(u2);
19+
ConsumeStructuredBuffer<S> D : register(u3);
2020

21-
RWBuffer<uint> Out : register(u0, space1);
21+
[[vk::binding(10)]]
22+
RWBuffer<uint> Out : register(u10);
2223

23-
[numthreads(4,1,1)]
24+
[numthreads(1,1,1)]
2425
void main() {
2526
uint numStructs, stride;
2627
int i = 0;
@@ -75,47 +76,64 @@ Buffers:
7576
Format: Int32
7677
ZeroInitSize: 32
7778

79+
- Name: ExpectedOut
80+
Format: Int32
81+
Data: [ 1, 16, 4, 8, 2, 16, 2, 8 ]
82+
83+
Results:
84+
- Result: Out
85+
Rule: BufferExact
86+
Actual: Out
87+
Expected: ExpectedOut
88+
7889
DescriptorSets:
7990
- Resources:
8091
- Name: A
8192
Kind: StructuredBuffer
8293
DirectXBinding:
8394
Register: 0
8495
Space: 0
96+
VulkanBinding:
97+
Binding: 0
8598

8699
- Name: B
87100
Kind: RWStructuredBuffer
88101
DirectXBinding:
89-
Register: 0
102+
Register: 1
90103
Space: 0
104+
VulkanBinding:
105+
Binding: 1
91106

92107
- Name: C
93108
Kind: RWStructuredBuffer
94109
DirectXBinding:
95-
Register: 1
110+
Register: 2
96111
Space: 0
112+
VulkanBinding:
113+
Binding: 2
97114

98115
- Name: D
99116
Kind: RWStructuredBuffer
100117
DirectXBinding:
101-
Register: 2
118+
Register: 3
102119
Space: 0
120+
VulkanBinding:
121+
Binding: 3
103122

104123
- Name: Out
105124
Kind: RWBuffer
106125
DirectXBinding:
107-
Register: 0
108-
Space: 1
126+
Register: 10
127+
Space: 0
128+
VulkanBinding:
129+
Binding: 10
130+
109131
...
110132
#--- end
111133

112-
# UNSUPPORTED: Clang
113-
# UNSUPPORTED: Vulkan
134+
# Unimplemented https://github.com/llvm/wg-hlsl/issues/126
135+
# XFAIL: Clang
114136

115137
# RUN: split-file %s %t
116138
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
117-
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s
118-
119-
# CHECK: - Name: Out
120-
# CHECK-NEXT: Format: Int32
121-
# CHECK-NEXT: Data: [ 1, 16, 4, 8, 2, 16, 2, 8 ]
139+
# RUN: %offloader %t/pipeline.yaml %t.o
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#--- source.hlsl
2+
3+
// This test checks that we will get the expected values from invoking
4+
// `GetDimension`s on typed buffers RWBuffer and Buffer.
5+
6+
Buffer<int4> A : register(t0);
7+
RWBuffer<float> B : register(u1);
8+
9+
[[vk::binding(10)]]
10+
RWBuffer<uint> Out : register(u10);
11+
12+
[numthreads(1,1,1)]
13+
void main() {
14+
uint dim;
15+
16+
A.GetDimensions(dim);
17+
Out[0] = dim;
18+
19+
B.GetDimensions(dim);
20+
Out[1] = dim;
21+
}
22+
23+
//--- pipeline.yaml
24+
25+
---
26+
Shaders:
27+
- Stage: Compute
28+
Entry: main
29+
DispatchSize: [4, 1, 1]
30+
31+
Buffers:
32+
- Name: A
33+
Format: Int32
34+
Data: [ 0, 1, 2, 3, 4, 5, 6, 7 ]
35+
36+
- Name: B
37+
Format: Float32
38+
Data: [ 0.1, 1.1, 2.2, 3.3, 4.4 ]
39+
40+
- Name: Out
41+
Format: Int32
42+
ZeroInitSize: 8
43+
44+
- Name: ExpectedOut
45+
Format: Int32
46+
Data: [ 8, 5 ]
47+
48+
Results:
49+
- Result: Out
50+
Rule: BufferExact
51+
Actual: Out
52+
Expected: ExpectedOut
53+
54+
DescriptorSets:
55+
- Resources:
56+
- Name: A
57+
Kind: Buffer
58+
DirectXBinding:
59+
Register: 0
60+
Space: 0
61+
VulkanBinding:
62+
Binding: 0
63+
64+
- Name: B
65+
Kind: RWBuffer
66+
DirectXBinding:
67+
Register: 1
68+
Space: 0
69+
VulkanBinding:
70+
Binding: 1
71+
72+
- Name: Out
73+
Kind: RWBuffer
74+
DirectXBinding:
75+
Register: 10
76+
Space: 0
77+
VulkanBinding:
78+
Binding: 10
79+
80+
...
81+
#--- end
82+
83+
# Bug https://github.com/llvm/offload-test-suite/issues/469
84+
# XFAIL: DXC && Vulkan
85+
86+
# Unimplemented https://github.com/llvm/wg-hlsl/issues/126
87+
# XFAIL: Clang
88+
89+
# RUN: split-file %s %t
90+
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
91+
# RUN: %offloader %t/pipeline.yaml %t.o

0 commit comments

Comments
 (0)