Skip to content
Merged
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
62 changes: 62 additions & 0 deletions test/Feature/CBuffer/array-vec-index.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#--- source.hlsl
// Regression test for https://github.com/llvm/llvm-project/issues/156084
RWStructuredBuffer<uint> output : register(u1);
cbuffer Constants : register(b0) {
uint4 s[3];
};

[numthreads(1,1,1)]
void main() {
output[0] = s[1][3];
output[1] = s[2].z;
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: Constants
Format: UInt32
Data: [
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
]
- Name: Out
Format: UInt32
ZeroInitSize: 8
- Name: ExpectedOut
Format: UInt32
Data: [ 8, 11 ]
Results:
- Result: Test1
Rule: BufferExact
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: Constants
Kind: ConstantBuffer
DirectXBinding:
Register: 0
Space: 0
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
...
#--- end

# DXC's vulkan support does not layout cbuffers compatibly with DXIL
# UNSUPPORTED: Vulkan

# Bug https://github.com/llvm/llvm-project/issues/156084
# XFAIL: Clang

# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
55 changes: 29 additions & 26 deletions test/Feature/CBuffer/arrays-16bit.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
cbuffer CBArrays : register(b0) {
uint16_t c1[2][2];
float16_t c2[1];
uint16_t4 c3[2];
}

struct Arrays {
uint16_t c1[2][2];
float16_t c2[1];
uint16_t4 c3[2];
};

RWStructuredBuffer<Arrays> Out : register(u1);
Expand All @@ -16,6 +18,7 @@ RWStructuredBuffer<Arrays> Out : register(u1);
void main() {
Out[0].c1 = c1;
Out[0].c2 = c2;
Out[0].c3 = c3;
}

//--- pipeline.yaml
Expand All @@ -33,13 +36,34 @@ Buffers:
0xffff, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A,
0x1234, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A,
0x0002, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A,
0x3c00, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A
0x3c00, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A,
0x0001, 0x0002, 0x0003, 0x0004, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A,
0x0005, 0x0006, 0x0007, 0x0008, 0x5A5A, 0x5A5A, 0x5A5A, 0x5A5A,
]
- Name: Out
Format: Hex16
# Warp doesn't seem to be able to handle a stride of 10 so we use 12 here
Stride: 12
ZeroInitSize: 12
# Warp doesn't seem to like buffers with non-multiple of 4 strides, so we
# add a small amount of buffer at the end here.
Stride: 28
ZeroInitSize: 28
- Name: ExpectedOut
Format: Hex16
Stride: 26
Data: [
0x0001,
0xffff,
0x1234,
0x0002,
0x3c00,
0x0001, 0x0002, 0x0003, 0x0004,
0x0005, 0x0006, 0x0007, 0x0008,
0x0,
]
Results:
- Result: Test1
Rule: BufferExact
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: CBArrays
Expand All @@ -64,25 +88,4 @@ DescriptorSets:

# RUN: split-file %s %t
# RUN: %dxc_target -enable-16bit-types -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# CHECK: - Name: CBArrays
# CHECK: Format: Hex16

# CHECK: - Name: Out
# CHECK: Format: Hex16
# CHECK: Data: [

# CHECK: 0x1,
# CHECK-NOT: 0x5A5A,
# CHECK: 0xFFFF,
# CHECK-NOT: 0x5A5A,
# CHECK: 0x1234,
# CHECK-NOT: 0x5A5A,
# CHECK: 0x2,
# CHECK-NOT: 0x5A5A,

# CHECK: 0x3C00,
# CHECK-NOT: 0x5A5A

# CHECK: ]
# RUN: %offloader %t/pipeline.yaml %t.o
64 changes: 33 additions & 31 deletions test/Feature/CBuffer/arrays-64bit.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ cbuffer CBArrays : register(b0) {
double2 c1[2];
uint64_t3 c2[2];
int64_t c3[2];
uint64_t c4[2][2];
}

struct Arrays {
double2 c1[2];
uint64_t3 c2[2];
int64_t c3[2];
uint64_t c4[2][2];
};

RWStructuredBuffer<Arrays> Out : register(u1);
Expand All @@ -19,6 +21,7 @@ void main() {
Out[0].c1 = c1;
Out[0].c2 = c2;
Out[0].c3 = c3;
Out[0].c4 = c4;
}

//--- pipeline.yaml
Expand All @@ -39,12 +42,38 @@ Buffers:
0x0000000000000001, 0x1234123412341234,
0x4321432143214321, 0x5A5A5A5A5A5A5A5A,
0x0000000000000001, 0x5A5A5A5A5A5A5A5A,
0x0000000000000002, 0x5A5A5A5A5A5A5A5A
0x0000000000000002, 0x5A5A5A5A5A5A5A5A,
0x000000000000000A, 0x5A5A5A5A5A5A5A5A,
0x000000000000000B, 0x5A5A5A5A5A5A5A5A,
0x000000000000000C, 0x5A5A5A5A5A5A5A5A,
0x000000000000000D, 0x5A5A5A5A5A5A5A5A,
]
- Name: Out
Format: Hex64
Stride: 96
ZeroInitSize: 96
Stride: 128
ZeroInitSize: 128
- Name: ExpectedOut
Format: Hex64
Stride: 128
Data: [
0x3ff0000000000000, 0x4008000000000000,
0x5ff0000000000000, 0x6008000000000000,
0x1234123412341234, 0x4321432143214321,
0x0000000000000001,
0x0000000000000001, 0x1234123412341234,
0x4321432143214321,
0x0000000000000001,
0x0000000000000002,
0x000000000000000A,
0x000000000000000B,
0x000000000000000C,
0x000000000000000D,
]
Results:
- Result: Test1
Rule: BufferExact
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: CBArrays
Expand All @@ -69,31 +98,4 @@ DescriptorSets:
# REQUIRES: Double, Int64
# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s

# CHECK: - Name: CBArrays
# CHECK: Format: Hex64

# CHECK: - Name: Out
# CHECK: Format: Hex64
# CHECK: Data: [

# CHECK: 0x3FF0000000000000,
# CHECK: 0x4008000000000000,
# CHECK: 0x5FF0000000000000,
# CHECK: 0x6008000000000000,

# CHECK: 0x1234123412341234,
# CHECK: 0x4321432143214321,
# CHECK: 0x1,
# CHECK-NOT: 0x5A5A5A5A5A5A5A5A,
# CHECK: 0x1,
# CHECK: 0x1234123412341234,
# CHECK: 0x4321432143214321,
# CHECK-NOT: 0x5A5A5A5A5A5A5A5A,

# CHECK: 0x1,
# CHECK: 0x2
# CHECK-NOT: 0x5A5A5A5A5A5A5A5A

# CHECK: ]
# RUN: %offloader %t/pipeline.yaml %t.o
71 changes: 32 additions & 39 deletions test/Feature/CBuffer/arrays.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ cbuffer CBArrays : register(b0) {
float c1[2];
int4 c2[2][2];
bool c3[2];
int3 c4[2][2];
}

struct Arrays {
float c1[2];
int4 c2[2][2];
bool c3[2];
int3 c4[2][2];
};

RWStructuredBuffer<Arrays> Out : register(u1);
Expand All @@ -19,6 +21,7 @@ void main() {
Out[0].c1 = c1;
Out[0].c2 = c2;
Out[0].c3 = c3;
Out[0].c4 = c4;
}

//--- pipeline.yaml
Expand All @@ -40,11 +43,37 @@ Buffers:
0x0000000D, 0x0000000E, 0x0000000F, 0x00000010,
0x00000000, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
0x00000001, 0x5A5A5A5A, 0x5A5A5A5A, 0x5A5A5A5A,
0x00000010, 0x00000011, 0x00000012, 0x5A5A5A5A,
0x00000013, 0x00000014, 0x00000015, 0x5A5A5A5A,
0x00000016, 0x00000017, 0x00000018, 0x5A5A5A5A,
0x00000019, 0x0000001A, 0x0000001B, 0x5A5A5A5A
]
- Name: Out
Format: Hex32
Stride: 80
ZeroInitSize: 80
Stride: 128
ZeroInitSize: 128
- Name: ExpectedOut
Format: Hex32
Stride: 128
Data: [
0x3f800000,
0x40800000,
0x00000001, 0x00000002, 0x00000003, 0x00000004,
0x00000005, 0x00000006, 0x00000007, 0x00000008,
0x00000009, 0x0000000A, 0x0000000B, 0x0000000C,
0x0000000D, 0x0000000E, 0x0000000F, 0x00000010,
0x00000000,
0x00000001,
0x00000010, 0x00000011, 0x00000012,
0x00000013, 0x00000014, 0x00000015,
0x00000016, 0x00000017, 0x00000018,
0x00000019, 0x0000001A, 0x0000001B,
]
Results:
- Result: Test1
Rule: BufferExact
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: CBArrays
Expand All @@ -68,40 +97,4 @@ DescriptorSets:

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

# CHECK: - Name: CBArrays
# CHECK: Format: Hex32

# CHECK: - Name: Out
# CHECK: Format: Hex32
# CHECK: Data: [

# CHECK: 0x3F800000,
# CHECK: 0x40800000,
# CHECK-NOT: 0x5A5A5A5A,

# CHECK: 0x1,
# CHECK: 0x2,
# CHECK: 0x3,
# CHECK: 0x4,
# CHECK: 0x5,
# CHECK: 0x6,
# CHECK: 0x7,
# CHECK: 0x8,
# CHECK: 0x9,
# CHECK: 0xA,
# CHECK: 0xB,
# CHECK: 0xC,
# CHECK: 0xD,
# CHECK: 0xE,
# CHECK: 0xF,
# CHECK: 0x10,

# CHECK: 0x0,
# CHECK-NOT: 0x5A5A5A5A,

# CHECK: 0x1
# CHECK-NOT: 0x5A5A5A5A

# CHECK: ]
# RUN: %offloader %t/pipeline.yaml %t.o
Loading