Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b6d7cb0
Add multiple tests for semantics
Keenuts Jan 12, 2026
7d76204
fix XFAIL values
Keenuts Jan 12, 2026
5b02dd1
improve test
Keenuts Jan 15, 2026
0f84d63
test all values across all dims
Keenuts Feb 11, 2026
a728aae
make test robust to scheduling change
Keenuts Feb 12, 2026
ea693f9
add xfail for metal
Keenuts Feb 12, 2026
dadbf55
try setting the root signature before the desc table
Keenuts Feb 16, 2026
91f33c6
Revert "try setting the root signature before the desc table"
Keenuts Feb 16, 2026
7be3405
xfail on dx
Keenuts Feb 16, 2026
41adbe6
marking xfail for clang+dx
Keenuts Feb 16, 2026
324b599
add issue for DX XFAIL and remove SV_POS
Keenuts Feb 16, 2026
87e4b9c
fix user semantic
Keenuts Feb 16, 2026
22999d0
add issue to FIXME
Keenuts Feb 16, 2026
81de9de
change framebuffer size
Keenuts Feb 17, 2026
efb1610
change array test for metal
Keenuts Feb 17, 2026
7794453
remove descriptors
Keenuts Feb 17, 2026
12ddf09
remove XFAIL for d3d
Keenuts Feb 17, 2026
6b9187b
add readback barrier to D3D12 graphics
Keenuts Feb 17, 2026
78c8b5c
Revert "remove descriptors"
Keenuts Feb 17, 2026
6d5b301
set root signature before
Keenuts Feb 17, 2026
254a4b8
remove XFAIL d3d12
Keenuts Feb 17, 2026
18cdc1b
XFAIL metal
Keenuts Feb 17, 2026
0327427
remove XFAIL for clang
Keenuts Feb 17, 2026
b59098a
pr-feedback
Keenuts Feb 18, 2026
87ad712
move to semantic folder
Keenuts Feb 18, 2026
5c96762
remove compute shader test
Keenuts Feb 18, 2026
393ab4c
Merge branch 'main' into graphics
Keenuts Feb 18, 2026
58776e4
make sure the correct buffer is checked
Keenuts Feb 18, 2026
727bd67
fix bad comment
Keenuts Feb 18, 2026
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
39 changes: 38 additions & 1 deletion lib/API/DX/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,13 +1465,13 @@ class DXDevice : public offloadtest::Device {
IS.RTVHeap->GetCPUDescriptorHandleForHeapStart();
Device->CreateRenderTargetView(IS.RT.Get(), nullptr, RTVHandle);

IS.CmdList->SetGraphicsRootSignature(IS.RootSig.Get());
if (IS.DescHeap) {
ID3D12DescriptorHeap *const Heaps[] = {IS.DescHeap.Get()};
IS.CmdList->SetDescriptorHeaps(1, Heaps);
IS.CmdList->SetGraphicsRootDescriptorTable(
0, IS.DescHeap->GetGPUDescriptorHandleForHeapStart());
}
IS.CmdList->SetGraphicsRootSignature(IS.RootSig.Get());
IS.CmdList->SetPipelineState(IS.PSO.Get());

IS.CmdList->OMSetRenderTargets(1, &RTVHandle, false, nullptr);
Expand Down Expand Up @@ -1509,6 +1509,43 @@ class DXDevice : public offloadtest::Device {
const CD3DX12_TEXTURE_COPY_LOCATION SrcLoc(IS.RT.Get(), 0);

IS.CmdList->CopyTextureRegion(&DstLoc, 0, 0, 0, &SrcLoc, nullptr);

auto CopyBackResource = [&IS, this](ResourcePair &R) {
if (R.first->isTexture()) {
const offloadtest::Buffer &B = *R.first->BufferPtr;
const D3D12_PLACED_SUBRESOURCE_FOOTPRINT Footprint{
0, CD3DX12_SUBRESOURCE_FOOTPRINT(
getDXFormat(B.Format, B.Channels), B.OutputProps.Width,
B.OutputProps.Height, 1,
B.OutputProps.Width * B.getElementSize())};
for (const ResourceSet &RS : R.second) {
if (RS.Readback == nullptr)
continue;
addReadbackBeginBarrier(IS, RS.Buffer);
const CD3DX12_TEXTURE_COPY_LOCATION DstLoc(RS.Readback.Get(),
Footprint);
const CD3DX12_TEXTURE_COPY_LOCATION SrcLoc(RS.Buffer.Get(), 0);
IS.CmdList->CopyTextureRegion(&DstLoc, 0, 0, 0, &SrcLoc, nullptr);
addReadbackEndBarrier(IS, RS.Buffer);
}
return;
}
for (const ResourceSet &RS : R.second) {
if (RS.Readback == nullptr)
continue;
addReadbackBeginBarrier(IS, RS.Buffer);
IS.CmdList->CopyResource(RS.Readback.Get(), RS.Buffer.Get());
addReadbackEndBarrier(IS, RS.Buffer);
}
};

for (auto &Table : IS.DescTables)
for (auto &R : Table.Resources)
CopyBackResource(R);

for (auto &R : IS.RootResources)
CopyBackResource(R);

return llvm::Error::success();
}

Expand Down
76 changes: 76 additions & 0 deletions test/Feature/Semantics/ArraySemantics.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#--- vertex.hlsl
struct VSInput {
float4 position : POSITION;
};

struct VSOutput {
float4 position : SV_POSITION;
float arr[4] : MY_ARRAY;
};

VSOutput main(VSInput input) {
VSOutput output;
output.position = input.position;
output.arr[0] = 0.5;
output.arr[1] = 1.0;
output.arr[2] = 0.0;
output.arr[3] = 1.0;
return output;
}

#--- pixel.hlsl
struct PSInput {
float4 position : SV_POSITION;
float arr[4] : MY_ARRAY;
};

float4 main(PSInput input) : SV_TARGET {
return float4(input.arr[0], input.arr[1], input.arr[2], input.arr[3]);
}

#--- pipeline.yaml
---
Shaders:
- Stage: Vertex
Entry: main
- Stage: Pixel
Entry: main
Buffers:
- Name: VertexData
Format: Float32
Stride: 16
Data: [ 0.0, 3.0, 0.0, 1.0,
3.0, -3.0, 0.0, 1.0,
-3.0, -3.0, 0.0, 1.0 ]
- Name: Output
Format: Float32
Channels: 4
FillSize: 16 # 1x1 @ 16 bytes per pixel
OutputProps:
Height: 1
Width: 1
Depth: 16
Bindings:
VertexBuffer: VertexData
VertexAttributes:
- Format: Float32
Channels: 4
Offset: 0
Name: POSITION
RenderTarget: Output
DescriptorSets: []
...
#--- end

# Semantics are not implemented in the DXIL backend.
# XFAIL: Clang && !Vulkan

# RUN: split-file %s %t
# RUN: %dxc_target -T vs_6_0 -Fo %t-vertex.o %t/vertex.hlsl
# RUN: %dxc_target -T ps_6_0 -Fo %t-pixel.o %t/pixel.hlsl
# RUN: %offloader %t/pipeline.yaml %t-vertex.o %t-pixel.o | FileCheck %s

# CHECK: Name: Output
# CHECK-NEXT: Format: Float32
# CHECK-NEXT: Channels: 4
# CHECK-NEXT: Data: [ 0.5, 1, 0, 1 ]
108 changes: 108 additions & 0 deletions test/Feature/Semantics/MatrixSemantics.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#--- vertex.hlsl
struct VSInput {
float4 position : POSITION;
};

struct VSOutput {
float4 position : SV_POSITION;
float4x4 mat : MY_MATRIX;
};

VSOutput main(VSInput input) {
VSOutput output;
output.position = input.position;

output.mat = float4x4(
1.0, 2.0, 3.0, 4.0,
0.0, 5.0, 0.0, 0.0,
0.0, 0.0, 6.0, 0.0,
0.0, 0.0, 0.0, 7.0
);

return output;
}

#--- pixel.hlsl
struct PSInput {
float4 position : SV_POSITION;
float4x4 mat : MY_MATRIX;
};

RWStructuredBuffer<float> Out : register(u0);

float4 main(PSInput input) : SV_TARGET {
Out[0] = input.mat[0][0];
Out[1] = input.mat[0][1];
Out[2] = input.mat[0][2];
Out[3] = input.mat[0][3];
Out[4] = input.mat[1][1];
Out[5] = input.mat[2][2];
Out[6] = input.mat[3][3];

return float4(1.0, 0.0, 0.0, 1.0);
}

#--- pipeline.yaml
---
Shaders:
- Stage: Vertex
Entry: main
- Stage: Pixel
Entry: main
Buffers:
- Name: VertexData
Format: Float32
Stride: 16
Data: [ 0.0, 3.0, 0.0, 1.0,
3.0, -3.0, 0.0, 1.0,
-3.0, -3.0, 0.0, 1.0 ]
- Name: Output
Format: Float32
Channels: 4
FillSize: 16 # 1x1 @ 16 bytes per pixel
OutputProps:
Height: 1
Width: 1
Depth: 16
- Name: ResultBuffer
Format: Float32
FillSize: 28
FillValue: 0.0
- Name: ResultBuffer_Expected
Format: Float32
Data: [ 1, 2, 3, 4, 5, 6, 7 ]
Bindings:
VertexBuffer: VertexData
VertexAttributes:
- Format: Float32
Channels: 4
Offset: 0
Name: POSITION
RenderTarget: Output
DescriptorSets:
- Resources:
- Name: ResultBuffer
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
Results:
- Result: Results
Rule: BufferExact
Actual: ResultBuffer
Expected: ResultBuffer_Expected
...
#--- end

# Semantics are not implemented in the DXIL backend.
# XFAIL: Clang && !Vulkan

# See https://github.com/llvm/offload-test-suite/issues/744
# XFAIL: Metal

# RUN: split-file %s %t
# RUN: %dxc_target -T vs_6_0 -Fo %t-vertex.o %t/vertex.hlsl
# RUN: %dxc_target -T ps_6_0 -Fo %t-pixel.o %t/pixel.hlsl
# RUN: %offloader %t/pipeline.yaml %t-vertex.o %t-pixel.o
111 changes: 111 additions & 0 deletions test/Feature/Semantics/NestedStructSemantics.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#--- vertex.hlsl
struct Inner {
uint b : B;
};

struct VSInput {
float4 position : POSITION;
};

struct VSOutput {
float4 position : SV_POSITION;
uint a : A;
Inner inner;
uint c : C;
};

VSOutput main(VSInput input) {
VSOutput output;
output.position = input.position;
output.a = 1;
output.inner.b = 2;
output.c = 3;
return output;
}

#--- pixel.hlsl
struct Inner {
uint b : B;
};

struct PSInput {
float4 position : SV_POSITION;
uint a : A;
Inner inner;
uint c : C;
};

RWStructuredBuffer<uint> Out : register(u0);

float4 main(PSInput input) : SV_TARGET {
Out[0] = input.a;
Out[1] = input.inner.b;
Out[2] = input.c;

return float4(1, 0, 0, 0);
}

#--- pipeline.yaml
---
Shaders:
- Stage: Vertex
Entry: main
- Stage: Pixel
Entry: main
Buffers:
- Name: VertexData
Format: Float32
Stride: 16
Data: [ 0.0, 3.0, 0.0, 1.0,
3.0, -3.0, 0.0, 1.0,
-3.0, -3.0, 0.0, 1.0 ]
- Name: Output
Format: Float32
Channels: 4
FillSize: 16 # 1x1 @ 16 bytes per pixel
OutputProps:
Height: 1
Width: 1
Depth: 16
- Name: ResultBuffer
Format: Int32
FillSize: 12
FillValue: 0
- Name: ResultBuffer_Expected
Format: Int32
Data: [ 1, 2, 3 ]
Bindings:
VertexBuffer: VertexData
VertexAttributes:
- Format: Float32
Channels: 4
Offset: 0
Name: POSITION
RenderTarget: Output
DescriptorSets:
- Resources:
- Name: ResultBuffer
Kind: RWStructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
Results:
- Result: Results
Rule: BufferExact
Actual: ResultBuffer
Expected: ResultBuffer_Expected
...
#--- end

# Semantics are not implemented in the DXIL backend.
# XFAIL: Clang && !Vulkan

# See https://github.com/llvm/offload-test-suite/issues/744
# XFAIL: Metal

# RUN: split-file %s %t
# RUN: %dxc_target -T vs_6_0 -Fo %t-vertex.o %t/vertex.hlsl
# RUN: %dxc_target -T ps_6_0 -Fo %t-pixel.o %t/pixel.hlsl
# RUN: %offloader %t/pipeline.yaml %t-vertex.o %t-pixel.o
Loading