Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions test/Feature/ResourcesInStructs/array-of-structs-with-res.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#--- source.hlsl

// This test verifies handling of a array of structs with a resource.

struct A {
RWBuffer<int> Buf;
uint n;
};

A d[8] : register(u10);
A e[6];

RWBuffer<int> Out : register(u100);

[numthreads(4, 1, 1)]
void main(uint3 ID : SV_GroupThreadID) {
int x = d[2].Buf[ID.x];
int y = d[7].Buf[ID.x];

e[0].Buf[ID.x] = x + y;
e[1].Buf[ID.x] = x * y;
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: BufD2
Format: Int32
Data:
[ 1, 2, 3, 4 ]

- Name: BufD7
Format: Int32
Data:
[ 10, 20, 30, 40 ]

- Name: BufE1
Format: Int32
FillSize: 16

- Name: BufE3
Format: Int32
FillSize: 16

- Name: ExpectedBufE1
Format: Int32
Data:
[ 11, 22, 33, 44 ]

- Name: ExpectedBufE3
Format: Int32
Data:
[ 10, 40, 90, 160 ]

Results:
- Result: ExpectedResult1
Rule: BufferExact
Actual: BufE1
Expected: ExpectedBufE1

- Result: ExpectedResult2
Rule: BufferExact
Actual: BufE3
Expected: ExpectedBufE3

DescriptorSets:
- Resources:
- Name: BufD2
Kind: RWBuffer
DirectXBinding:
Register: 12
Space: 0
VulkanBinding:
Binding: 12
- Name: BufD7
Kind: RWBuffer
DirectXBinding:
Register: 17
Space: 0
VulkanBinding:
Binding: 17
- Name: BufE1
Kind: RWBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: BufE3
Kind: RWBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
...
#--- end

# Unimplemented https://github.com/llvm/wg-hlsl/issues/367
# XFAIL: Clang

# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
124 changes: 124 additions & 0 deletions test/Feature/ResourcesInStructs/res-in-struct-mix.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#--- source.hlsl

// This test verifies handling of a resource array in a struct.

class E {
RWBuffer<int> UavBuf1;
};

class F {
StructuredBuffer<int> SrvBuf1;
};

class G : F {
E e;
StructuredBuffer<int> SrvBuf2;
RWBuffer<int> UavBuf2;
};

RWStructuredBuffer<int4> Out : register(u0);

G g : register(u5) : register(t3);

[numthreads(4, 1, 1)]
void main(uint3 ID : SV_GroupThreadID) {
int x = g.e.UavBuf1[ID.x];
int y = g.SrvBuf1[ID.x];
int z = g.SrvBuf2[ID.x];
int w = g.UavBuf2[ID.x];

Out[ID.x] = int4(x, y, z, w);
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: Buf_g_F_SrvBuf1
Format: Int32
Data:
[ 1, 2, 3, 4 ]

- Name: Buf_g_SrvBuf2
Format: Int32
Data:
[ 10, 20, 30, 40 ]

- Name: Buf_g_e_UavBufs1
Format: Int32
Data:
[ 100, 200, 300, 400 ]

- Name: Buf_g_UavBufs2
Format: Int32
Data:
[ 1000, 2000, 3000, 4000 ]

- Name: BufOut
Format: Int32
FillSize: 64

- Name: ExpectedBufOut
Format: Int32
Data:
[ 100, 1, 10, 1000,
200, 2, 20, 2000,
300, 3, 30, 3000,
400, 4, 40, 4000 ]

Results:
- Result: ExpectedResult
Rule: BufferExact
Actual: BufOut
Expected: ExpectedBufOut

DescriptorSets:
- Resources:
- Name: Buf_g_F_SrvBuf1
Kind: StructuredBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
- Name: Buf_g_SrvBuf2
Kind: StructuredBuffer
DirectXBinding:
Register: 4
Space: 0
VulkanBinding:
Binding: 4
- Name: Buf_g_e_UavBufs1
Kind: RWBuffer
DirectXBinding:
Register: 5
Space: 0
VulkanBinding:
Binding: 5
- Name: Buf_g_UavBufs2
Kind: RWBuffer
DirectXBinding:
Register: 6
Space: 0
VulkanBinding:
Binding: 6
- Name: BufOut
Kind: RWBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0

...
#--- end

# Unimplemented https://github.com/llvm/wg-hlsl/issues/367
# XFAIL: Clang

# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
78 changes: 78 additions & 0 deletions test/Feature/ResourcesInStructs/res-in-struct-simple-array.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#--- source.hlsl

// This test verifies handling of a resource array in a struct.

struct B {
RWBuffer<int> Bufs[2];
};

[[vk::binding(3)]]
B b1 : register(u3);
B b2;

[numthreads(4,1,1)]
void main(uint3 ID : SV_GroupThreadID) {
float x = b1.Bufs[0][ID.x];
float y = b1.Bufs[1][ID.x];

b2.Bufs[0][ID.x] = x + y;
b2.Bufs[1][ID.x] = x * y;
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: BufB1
Format: Int32
ArraySize: 2
Data:
- [ 1, 2, 3, 4 ]
- [ 10, 20, 30, 40 ]

- Name: BufB2
Format: Int32
ArraySize: 2
FillSize: 16

- Name: ExpectedBufB2
Format: Int32
ArraySize: 2
Data:
- [ 11, 22, 33, 44 ]
- [ 10, 40, 90, 160 ]

Results:
- Result: ExpectedResult
Rule: BufferExact
Actual: BufB2
Expected: ExpectedBufB2

DescriptorSets:
- Resources:
- Name: BufB1
Kind: RWBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
- Name: BufB2
Kind: RWBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
...
#--- end

# Unimplemented https://github.com/llvm/wg-hlsl/issues/367
# XFAIL: Clang

# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
71 changes: 71 additions & 0 deletions test/Feature/ResourcesInStructs/res-in-struct-simple-one.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#--- source.hlsl

// This test verifies handling of a simple resource in a struct.

struct A {
RWBuffer<int> Buf;
};

[[vk::binding(5)]]
A a1 : register(u5);

A a2;

[numthreads(8, 1, 1)]
void main(uint3 ID : SV_GroupThreadID) {
a2.Buf[ID.x] += a1.Buf[ID.x];
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: BufA1
Format: Int32
Data:
[ 1, 2, 3, 4, 5, 6, 7, 8 ]

- Name: BufA2
Format: Int32
Data:
[ 10, 20, 30, 40, 50, 60, 70, 80 ]

- Name: ExpectedBufA2
Format: Int32
Data:
[ 11, 22, 33, 44, 55, 66, 77, 88 ]

Results:
- Result: ExpectedResult
Rule: BufferExact
Actual: BufA2
Expected: ExpectedBufA2

DescriptorSets:
- Resources:
- Name: BufA1
Kind: RWBuffer
DirectXBinding:
Register: 5
Space: 0
VulkanBinding:
Binding: 5
- Name: BufA2
Kind: RWBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
...
#--- end

# Unimplemented https://github.com/llvm/wg-hlsl/issues/367
# XFAIL: Clang

# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
Loading