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
94 changes: 94 additions & 0 deletions test/M3/RootSignatures/Defaults.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#--- source.hlsl

cbuffer RootConstants : register(b0) {
float4 C;
};

struct Input {
float4 A;
float4 B;
};

struct Output {
float4 A;
};

StructuredBuffer<Input> In : register(t0);
RWStructuredBuffer<Output> Out1 : register(u1);
RWStructuredBuffer<Output> Out2 : register(u2);

// Root signature to sanity test the default values that are given to optional
// parameters (`space = 0`, `offset = DESCRIPTOR_RANGE_OFFSET_APPEND`, etc)

#define RootSig \
"RootConstants(num32BitConstants = 4, b0), " \
"DescriptorTable( " \
" SRV(t0), " \
" UAV(u1) " \
"), " \
"UAV(u2) "

[RootSignature(RootSig)]
[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
Out1[GI].A = In[GI].A * In[GI].B * C;
Out2[GI].A = In[GI].A * In[GI].B * C * 2;
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
RuntimeSettings:
DirectX:
RootParameters:
- Kind: Constant
Name: Root
- Kind: DescriptorTable
- Kind: RootDescriptor
Resource:
Name: Out2
Kind: RWStructuredBuffer
Buffers:
- Name: Root
Format: Float32
Data: [ 2, 4, 6, 8 ]
- Name: In
Format: Float32
Stride: 32
Data: [ 2, 4, 6, 8, 10, 12, 14, 16]
- Name: Out1
Format: Float32
Channels: 4
ZeroInitSize: 16
- Name: Out2
Format: Float32
Channels: 4
ZeroInitSize: 16
DescriptorSets:
- Resources:
- Name: In
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
- Name: Out1
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
...
#--- end

# UNSUPPORTED: 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 | FileCheck %s

# CHECK-LABEL: Name: Out1
# CHECK: Data: [ 40, 192, 504, 1024 ]
# CHECK-LABEL: Name: Out2
# CHECK: Data: [ 80, 384, 1008, 2048 ]
104 changes: 104 additions & 0 deletions test/M3/RootSignatures/Flags.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#--- source.hlsl

struct Input {
float4 A;
float4 B;
};

struct Output {
float4 A;
};

StructuredBuffer<Input> In : register(t0);
StructuredBuffer<Input> InExtra : register(t1);
RWStructuredBuffer<Output> Out1 : register(u1);
RWStructuredBuffer<Output> Out2 : register(u2);

// Root signature to test specifying various flags:
// - Edge-case value of '0'
// - Demonstrate setting of non-sampler root flags
// - Demonstrate setting of all descriptor flags
// - Demonstrate '|' of applicable flags

#define RootSig \
"RootFlags( " \
" ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \
" CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | " \
" ALLOW_STREAM_OUTPUT " \
"), " \
"DescriptorTable( " \
" SRV(t0, flags = DATA_STATIC), " \
" SRV(t1, flags = DATA_STATIC_WHILE_SET_AT_EXECUTE), " \
" UAV(u1, flags = DESCRIPTORS_VOLATILE | DATA_VOLATILE), " \
" UAV(u2, flags = 0)" \
")"

[RootSignature(RootSig)]
[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
Out1[GI].A = In[GI].A * InExtra[GI].B;
Out2[GI].A = In[GI].A * InExtra[GI].B * 2;
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
RuntimeSettings:
DirectX:
RootParameters:
- Kind: DescriptorTable
Buffers:
- Name: In
Format: Float32
Stride: 32
Data: [ 2, 4, 6, 8, 10, 12, 14, 16]
- Name: InExtra
Format: Float32
Stride: 32
Data: [ 2, 4, 6, 8, 10, 12, 14, 16]
- Name: Out1
Format: Float32
Channels: 4
ZeroInitSize: 16
- Name: Out2
Format: Float32
Channels: 4
ZeroInitSize: 16
DescriptorSets:
- Resources:
- Name: In
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
- Name: InExtra
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
- Name: Out1
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
- Name: Out2
Kind: RWStructuredBuffer
DirectXBinding:
Register: 2
Space: 0
...
#--- end

# UNSUPPORTED: 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 | FileCheck %s

# CHECK-LABEL: Name: Out1
# CHECK: Data: [ 20, 48, 84, 128 ]
# CHECK-LABEL: Name: Out2
# CHECK: Data: [ 40, 96, 168, 256 ]
100 changes: 100 additions & 0 deletions test/M3/RootSignatures/ManualDescriptors.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#--- source.hlsl

struct Input {
float4 A;
float4 B;
};

struct Output {
float4 A;
};

StructuredBuffer<Input> In : register(t0);
StructuredBuffer<Input> InExtra : register(t1);
RWStructuredBuffer<Output> Out1 : register(u1);
RWStructuredBuffer<Output> Out2 : register(u2);

// Root signature to test manual `offset` and `numDescriptor` specification:
// - Demonstrate manually describing the offsets and numDescriptors
// - Edge-case value of `offset` = `DESCRIPTOR_RANGE_OFFSET_APPEND`
// - Edge-case value of `numDescriptors` = `unbounded`

#define RootSig \
"DescriptorTable( " \
" UAV(u2, offset = 3, numDescriptors = unbounded), " \
" SRV(t0, offset = 0, numDescriptors = 2), " \
" UAV(u1, " \
" offset = DESCRIPTOR_RANGE_OFFSET_APPEND, " \
" numDescriptors = 1 " \
" ) " \
")"

[RootSignature(RootSig)]
[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
Out1[GI].A = In[GI].A * InExtra[GI].B;
Out2[GI].A = In[GI].A * InExtra[GI].B * 2;
}

//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
RuntimeSettings:
DirectX:
RootParameters:
- Kind: DescriptorTable
Buffers:
- Name: In
Format: Float32
Stride: 32
Data: [ 2, 4, 6, 8, 10, 12, 14, 16]
- Name: InExtra
Format: Float32
Stride: 32
Data: [ 2, 4, 6, 8, 10, 12, 14, 16]
- Name: Out1
Format: Float32
Channels: 4
ZeroInitSize: 16
- Name: Out2
Format: Float32
Channels: 4
ZeroInitSize: 16
DescriptorSets:
- Resources:
- Name: In
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
- Name: InExtra
Kind: StructuredBuffer
DirectXBinding:
Register: 1
Space: 0
- Name: Out1
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
- Name: Out2
Kind: RWStructuredBuffer
DirectXBinding:
Register: 2
Space: 0
...
#--- end

# UNSUPPORTED: 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 | FileCheck %s

# CHECK-LABEL: Name: Out1
# CHECK: Data: [ 20, 48, 84, 128 ]
# CHECK-LABEL: Name: Out2
# CHECK: Data: [ 40, 96, 168, 256 ]
Loading