Skip to content

Commit cf1570a

Browse files
authored
Introduce a simpler StructuredBuffer test (#17)
This moves the current structured buffer test to a new file and introduces a simpler one that doesn't need llvm/llvm-project#104503 and llvm/llvm-project#121010 to be in place in order to pass. Note: this would be better if it exercised both SRVs and UAVs, but SRV support isn't implemented in the test framework yet.
1 parent e4c9176 commit cf1570a

File tree

2 files changed

+78
-17
lines changed

2 files changed

+78
-17
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#--- source.hlsl
2+
struct Doggo {
3+
int3 Legs;
4+
int TailState;
5+
int2 Ears;
6+
};
7+
8+
RWStructuredBuffer<Doggo> Buf;
9+
10+
[numthreads(2,1,1)]
11+
void main(uint GI : SV_GroupIndex) {
12+
Doggo Fido = Buf[GI];
13+
if (Fido.TailState == 0) {
14+
Fido.TailState = Fido.Legs.x + Fido.Legs.y + Fido.Legs.z;
15+
}
16+
Buf[GI] = Fido;
17+
}
18+
//--- pipeline.yaml
19+
---
20+
DispatchSize: [1, 1, 1]
21+
DescriptorSets:
22+
- Resources:
23+
- Access: ReadWrite
24+
Format: Int32
25+
RawSize: 24
26+
Data: [ 0, 1, 2, 0, 4, 0, 1, 2, 3, 0, 4, 0]
27+
DirectXBinding:
28+
Register: 0
29+
Space: 0
30+
...
31+
#--- end
32+
33+
# UNSUPPORTED: Clang
34+
# RUN: split-file %s %t
35+
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
36+
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
37+
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout -Fo %t.spv %t/source.hlsl %}
38+
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}
39+
40+
# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
41+
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
42+
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
43+
44+
45+
# CHECK: Data: [ 0, 1, 2, 3, 4, 0, 1, 2, 3, 6, 4, 0 ]

test/Basic/StructuredBuffer.test

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
#--- source.hlsl
2-
struct Doggo {
3-
int3 Legs;
4-
int TailState;
5-
int2 Ears;
2+
struct S1 {
3+
int4 i;
4+
float4 f;
5+
};
6+
struct S2 {
7+
float4 f;
8+
int4 i;
69
};
710

8-
RWStructuredBuffer<Doggo> Buf;
11+
RWStructuredBuffer<S1> In : register(u0);
12+
RWStructuredBuffer<S2> Out : register(u1);
913

10-
[numthreads(2,1,1)]
14+
[numthreads(1,1,1)]
1115
void main(uint GI : SV_GroupIndex) {
12-
Doggo Fido = Buf[GI];
13-
if (Fido.TailState == 0) {
14-
Fido.TailState = Fido.Legs.x + Fido.Legs.y + Fido.Legs.z;
15-
}
16-
Buf[GI] = Fido;
16+
Out[GI].f = In[GI].f;
17+
Out[GI].i = In[GI].i;
1718
}
1819
//--- pipeline.yaml
1920
---
2021
DispatchSize: [1, 1, 1]
2122
DescriptorSets:
2223
- Resources:
2324
- Access: ReadWrite
24-
Format: Int32
25-
RawSize: 24
26-
Data: [ 0, 1, 2, 0, 4, 0, 1, 2, 3, 0, 4, 0]
25+
Format: Hex32
26+
RawSize: 32
27+
Data: [0x00000000, 0x00000001, 0x00000002, 0x00000003,
28+
0x00000000, 0x3f800000, 0x40000000, 0x40400000]
2729
DirectXBinding:
2830
Register: 0
2931
Space: 0
32+
- Access: ReadWrite
33+
Format: Hex32
34+
RawSize: 32
35+
ZeroInitSize: 32
36+
DirectXBinding:
37+
Register: 1
38+
Space: 0
3039
...
3140
#--- end
3241

33-
# UNSUPPORTED: Clang
3442
# RUN: split-file %s %t
3543
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
3644
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
@@ -41,5 +49,13 @@ DescriptorSets:
4149
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
4250
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}
4351

44-
45-
# CHECK: Data: [ 0, 1, 2, 3, 4, 0, 1, 2, 3, 6, 4, 0 ]
52+
# CHECK: Data: [
53+
# CHECK: 0x0,
54+
# CHECK: 0x3F800000,
55+
# CHECK: 0x40000000,
56+
# CHECK: 0x40400000,
57+
# CHECK: 0x0,
58+
# CHECK: 0x1,
59+
# CHECK: 0x2,
60+
# CHECK: 0x3
61+
# CHECK: ]

0 commit comments

Comments
 (0)