Skip to content

Commit

Permalink
Introduce a simpler StructuredBuffer test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bogner committed Dec 23, 2024
1 parent e4c9176 commit 9056067
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 17 deletions.
45 changes: 45 additions & 0 deletions test/Basic/StructuredBuffer-packed.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#--- source.hlsl
struct Doggo {
int3 Legs;
int TailState;
int2 Ears;
};

RWStructuredBuffer<Doggo> Buf;

[numthreads(2,1,1)]
void main(uint GI : SV_GroupIndex) {
Doggo Fido = Buf[GI];
if (Fido.TailState == 0) {
Fido.TailState = Fido.Legs.x + Fido.Legs.y + Fido.Legs.z;
}
Buf[GI] = Fido;
}
//--- pipeline.yaml
---
DispatchSize: [1, 1, 1]
DescriptorSets:
- Resources:
- Access: ReadWrite
Format: Int32
RawSize: 24
Data: [ 0, 1, 2, 0, 4, 0, 1, 2, 3, 0, 4, 0]
DirectXBinding:
Register: 0
Space: 0
...
#--- end

# UNSUPPORTED: Clang
# RUN: split-file %s %t
# RUN: %if DirectX %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if DirectX %{ %offloader %t/pipeline.yaml %t.dxil | FileCheck %s %}
# RUN: %if Vulkan %{ dxc -T cs_6_0 -spirv -fspv-target-env=vulkan1.3 -fvk-use-scalar-layout -Fo %t.spv %t/source.hlsl %}
# RUN: %if Vulkan %{ %offloader %t/pipeline.yaml %t.spv | FileCheck %s %}

# RUN: %if Metal %{ dxc -T cs_6_0 -Fo %t.dxil %t/source.hlsl %}
# RUN: %if Metal %{ metal-shaderconverter %t.dxil -o=%t.metallib %}
# RUN: %if Metal %{ %offloader %t/pipeline.yaml %t.metallib | FileCheck %s %}


# CHECK: Data: [ 0, 1, 2, 3, 4, 0, 1, 2, 3, 6, 4, 0 ]
50 changes: 33 additions & 17 deletions test/Basic/StructuredBuffer.test
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
#--- source.hlsl
struct Doggo {
int3 Legs;
int TailState;
int2 Ears;
struct S1 {
int4 i;
float4 f;
};
struct S2 {
float4 f;
int4 i;
};

RWStructuredBuffer<Doggo> Buf;
RWStructuredBuffer<S1> In : register(u0);
RWStructuredBuffer<S2> Out : register(u1);

[numthreads(2,1,1)]
[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
Doggo Fido = Buf[GI];
if (Fido.TailState == 0) {
Fido.TailState = Fido.Legs.x + Fido.Legs.y + Fido.Legs.z;
}
Buf[GI] = Fido;
Out[GI].f = In[GI].f;
Out[GI].i = In[GI].i;
}
//--- pipeline.yaml
---
DispatchSize: [1, 1, 1]
DescriptorSets:
- Resources:
- Access: ReadWrite
Format: Int32
RawSize: 24
Data: [ 0, 1, 2, 0, 4, 0, 1, 2, 3, 0, 4, 0]
Format: Hex32
RawSize: 32
Data: [0x00000000, 0x00000001, 0x00000002, 0x00000003,
0x00000000, 0x3f800000, 0x40000000, 0x40400000]
DirectXBinding:
Register: 0
Space: 0
- Access: ReadWrite
Format: Hex32
RawSize: 32
ZeroInitSize: 32
DirectXBinding:
Register: 1
Space: 0
...
#--- end

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


# CHECK: Data: [ 0, 1, 2, 3, 4, 0, 1, 2, 3, 6, 4, 0 ]
# CHECK: Data: [
# CHECK: 0x0,
# CHECK: 0x3F800000,
# CHECK: 0x40000000,
# CHECK: 0x40400000,
# CHECK: 0x0,
# CHECK: 0x1,
# CHECK: 0x2,
# CHECK: 0x3
# CHECK: ]

0 comments on commit 9056067

Please sign in to comment.