Skip to content

Commit cfc3784

Browse files
authored
Move the setting of root signatures to after SetDescriptorHeaps (#463)
Fixes #462
1 parent a47948d commit cfc3784

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

lib/API/DX/Device.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -957,18 +957,17 @@ class DXDevice : public offloadtest::Device {
957957
}
958958

959959
llvm::Error createComputeCommands(Pipeline &P, InvocationState &IS) {
960-
IS.CmdList->SetPipelineState(IS.PSO.Get());
961-
IS.CmdList->SetComputeRootSignature(IS.RootSig.Get());
962-
963-
const uint32_t Inc = Device->GetDescriptorHandleIncrementSize(
964-
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
965960
CD3DX12_GPU_DESCRIPTOR_HANDLE Handle;
966-
967961
if (IS.DescHeap) {
968962
ID3D12DescriptorHeap *const Heaps[] = {IS.DescHeap.Get()};
969963
IS.CmdList->SetDescriptorHeaps(1, Heaps);
970964
Handle = IS.DescHeap->GetGPUDescriptorHandleForHeapStart();
971965
}
966+
IS.CmdList->SetComputeRootSignature(IS.RootSig.Get());
967+
IS.CmdList->SetPipelineState(IS.PSO.Get());
968+
969+
const uint32_t Inc = Device->GetDescriptorHandleIncrementSize(
970+
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
972971

973972
if (P.Settings.DX.RootParams.size() > 0) {
974973
uint32_t ConstantOffset = 0u;
@@ -1315,8 +1314,14 @@ class DXDevice : public offloadtest::Device {
13151314
IS.RTVHeap->GetCPUDescriptorHandleForHeapStart();
13161315
Device->CreateRenderTargetView(IS.RT.Get(), nullptr, RTVHandle);
13171316

1318-
IS.CmdList->SetPipelineState(IS.PSO.Get());
1317+
if (IS.DescHeap) {
1318+
ID3D12DescriptorHeap *const Heaps[] = {IS.DescHeap.Get()};
1319+
IS.CmdList->SetDescriptorHeaps(1, Heaps);
1320+
IS.CmdList->SetGraphicsRootDescriptorTable(
1321+
0, IS.DescHeap->GetGPUDescriptorHandleForHeapStart());
1322+
}
13191323
IS.CmdList->SetGraphicsRootSignature(IS.RootSig.Get());
1324+
IS.CmdList->SetPipelineState(IS.PSO.Get());
13201325

13211326
IS.CmdList->OMSetRenderTargets(1, &RTVHandle, false, nullptr);
13221327

@@ -1334,13 +1339,6 @@ class DXDevice : public offloadtest::Device {
13341339
static_cast<LONG>(VP.Height)};
13351340
IS.CmdList->RSSetScissorRects(1, &Scissor);
13361341

1337-
if (IS.DescHeap) {
1338-
ID3D12DescriptorHeap *const Heaps[] = {IS.DescHeap.Get()};
1339-
IS.CmdList->SetDescriptorHeaps(1, Heaps);
1340-
IS.CmdList->SetGraphicsRootDescriptorTable(
1341-
0, IS.DescHeap->GetGPUDescriptorHandleForHeapStart());
1342-
}
1343-
13441342
IS.CmdList->DrawInstanced(P.Bindings.getVertexCount(), 1, 0, 0);
13451343

13461344
// Transition the render target to copy source and copy to the readback

0 commit comments

Comments
 (0)