Skip to content

Commit 7a682c8

Browse files
authored
Merge pull request #5 from damyanp/cleanup
D3D12: Remove unnecessary waits and command list executions
2 parents 627e922 + 3679836 commit 7a682c8

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

lib/API/DX/Device.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class DXDevice : public hlsltest::Device {
286286
CComPtr<ID3D12Resource> Source) {
287287
addUploadBeginBarrier(IS, Destination);
288288
IS.CmdList->CopyBufferRegion(Destination, 0, Source, 0, R.Size);
289-
addUploadEndBarrier(IS, Destination, R.Access == DataAccess::ReadOnly);
289+
addUploadEndBarrier(IS, Destination, R.Access == DataAccess::ReadWrite);
290290
}
291291

292292
llvm::Error createSRV(Resource &R, InvocationState &IS,
@@ -504,14 +504,8 @@ class DXDevice : public hlsltest::Device {
504504
return waitForSignal(IS);
505505
}
506506

507-
llvm::Error createComputeCommands(Pipeline &P, InvocationState &IS) {
508-
if (auto Err =
509-
HR::toError(IS.Allocator->Reset(), "Failed to reset allocator."))
510-
return Err;
511-
if (auto Err = HR::toError(IS.CmdList->Reset(IS.Allocator, IS.PSO),
512-
"Failed to reset command list."))
513-
return Err;
514-
507+
void createComputeCommands(Pipeline &P, InvocationState &IS) {
508+
IS.CmdList->SetPipelineState(IS.PSO);
515509
IS.CmdList->SetComputeRootSignature(IS.RootSig);
516510

517511
ID3D12DescriptorHeap *const Heaps[] = {IS.DescHeap};
@@ -535,8 +529,6 @@ class DXDevice : public hlsltest::Device {
535529
IS.CmdList->CopyResource(Out.second.Readback, Out.second.Buffer);
536530
addReadbackEndBarrier(IS, Out.second.Buffer);
537531
}
538-
539-
return llvm::Error::success();
540532
}
541533

542534
llvm::Error readBack(Pipeline &P, InvocationState &IS) {
@@ -559,7 +551,7 @@ class DXDevice : public hlsltest::Device {
559551
ResourcePair->second.Readback->Unmap(0, nullptr);
560552
}
561553
}
562-
return waitForSignal(IS);
554+
return llvm::Error::success();
563555
}
564556

565557
llvm::Error executeProgram(llvm::StringRef Program, Pipeline &P) override {
@@ -585,21 +577,14 @@ class DXDevice : public hlsltest::Device {
585577
if (auto Err = createEvent(State))
586578
return Err;
587579
llvm::outs() << "Event prepared.\n";
588-
if (auto Err = executeCommandList(State))
589-
return Err;
590-
llvm::outs() << "Preparation commands executed.\n";
591-
if (auto Err = createComputeCommands(P, State))
592-
return Err;
580+
createComputeCommands(P, State);
593581
llvm::outs() << "Compute command list created.\n";
594582
if (auto Err = executeCommandList(State))
595583
return Err;
596584
llvm::outs() << "Compute commands executed.\n";
597585
if (auto Err = readBack(P, State))
598586
return Err;
599587
llvm::outs() << "Read data back.\n";
600-
if (auto Err = waitForSignal(State))
601-
return Err;
602-
llvm::outs() << "Wait and Sync...\n";
603588

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

0 commit comments

Comments
 (0)