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
87 changes: 87 additions & 0 deletions test/Feature/ByteAddressBuffer/GetDimensions.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#--- source.hlsl

// This test checks that we will get the expected values from invoking
// `GetDimension`s on typed buffers RWBuffer and Buffer.

ByteAddressBuffer A : register(t0);
RWByteAddressBuffer B : register(u1);

[[vk::binding(10)]]
RWBuffer<uint> Out : register(u10);

[numthreads(1,1,1)]
void main() {
uint dim;

A.GetDimensions(dim);
Out[0] = dim;

B.GetDimensions(dim);
Out[1] = dim;
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [4, 1, 1]

Buffers:
- Name: A
Format: Int32
Data: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]

- Name: B
Format: Hex32
Data: [ 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700 ]

- Name: Out
Format: Int32
ZeroInitSize: 8

- Name: ExpectedOut
Format: Int32
Data: [ 56, 28 ]

Results:
- Result: Out
Rule: BufferExact
Actual: Out
Expected: ExpectedOut

DescriptorSets:
- Resources:
- Name: A
Kind: ByteAddressBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0

- Name: B
Kind: RWByteAddressBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1

- Name: Out
Kind: RWBuffer
DirectXBinding:
Register: 10
Space: 0
VulkanBinding:
Binding: 10
...
#--- end

# Unimplemented https://github.com/llvm/wg-hlsl/issues/126
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ struct S {
};

StructuredBuffer<R> A : register(t0);
RWStructuredBuffer<S> B : register(u0);
AppendStructuredBuffer<R> C : register(u1);
ConsumeStructuredBuffer<S> D : register(u2);
RWStructuredBuffer<S> B : register(u1);
AppendStructuredBuffer<R> C : register(u2);
ConsumeStructuredBuffer<S> D : register(u3);

RWBuffer<uint> Out : register(u0, space1);
[[vk::binding(10)]]
RWBuffer<uint> Out : register(u10);

[numthreads(4,1,1)]
[numthreads(1,1,1)]
void main() {
uint numStructs, stride;
int i = 0;
Expand Down Expand Up @@ -75,47 +76,64 @@ Buffers:
Format: Int32
ZeroInitSize: 32

- Name: ExpectedOut
Format: Int32
Data: [ 1, 16, 4, 8, 2, 16, 2, 8 ]

Results:
- Result: Out
Rule: BufferExact
Actual: Out
Expected: ExpectedOut

DescriptorSets:
- Resources:
- Name: A
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0

- Name: B
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Register: 1
Space: 0
VulkanBinding:
Binding: 1

- Name: C
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Register: 2
Space: 0
VulkanBinding:
Binding: 2

- Name: D
Kind: RWStructuredBuffer
DirectXBinding:
Register: 2
Register: 3
Space: 0
VulkanBinding:
Binding: 3

- Name: Out
Kind: RWBuffer
DirectXBinding:
Register: 0
Space: 1
Register: 10
Space: 0
VulkanBinding:
Binding: 10

...
#--- end

# UNSUPPORTED: Clang
# UNSUPPORTED: Vulkan
# Unimplemented https://github.com/llvm/wg-hlsl/issues/126
# 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 | FileCheck %s

# CHECK: - Name: Out
# CHECK-NEXT: Format: Int32
# CHECK-NEXT: Data: [ 1, 16, 4, 8, 2, 16, 2, 8 ]
# RUN: %offloader %t/pipeline.yaml %t.o
91 changes: 91 additions & 0 deletions test/Feature/TypedBuffer/GetDimensions.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#--- source.hlsl

// This test checks that we will get the expected values from invoking
// `GetDimension`s on typed buffers RWBuffer and Buffer.

Buffer<int4> A : register(t0);
RWBuffer<float> B : register(u1);

[[vk::binding(10)]]
RWBuffer<uint> Out : register(u10);

[numthreads(1,1,1)]
void main() {
uint dim;

A.GetDimensions(dim);
Out[0] = dim;

B.GetDimensions(dim);
Out[1] = dim;
}

//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [4, 1, 1]

Buffers:
- Name: A
Format: Int32
Data: [ 0, 1, 2, 3, 4, 5, 6, 7 ]

- Name: B
Format: Float32
Data: [ 0.1, 1.1, 2.2, 3.3, 4.4 ]

- Name: Out
Format: Int32
ZeroInitSize: 8

- Name: ExpectedOut
Format: Int32
Data: [ 8, 5 ]

Results:
- Result: Out
Rule: BufferExact
Actual: Out
Expected: ExpectedOut

DescriptorSets:
- Resources:
- Name: A
Kind: Buffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0

- Name: B
Kind: RWBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1

- Name: Out
Kind: RWBuffer
DirectXBinding:
Register: 10
Space: 0
VulkanBinding:
Binding: 10

...
#--- end

# Bug https://github.com/llvm/offload-test-suite/issues/469
# XFAIL: DXC && Vulkan

# Unimplemented https://github.com/llvm/wg-hlsl/issues/126
# 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
Loading