From 319241b5979578da0ae61c56d5596ab7ff04e9fe Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 5 Feb 2024 04:27:04 +1100 Subject: [PATCH] [host] d12: use a GPU side fence instead of CPU side --- host/platform/Windows/capture/D12/d12.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/host/platform/Windows/capture/D12/d12.c b/host/platform/Windows/capture/D12/d12.c index c8427315..48feffe2 100644 --- a/host/platform/Windows/capture/D12/d12.c +++ b/host/platform/Windows/capture/D12/d12.c @@ -483,21 +483,28 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex, ID3D12GraphicsCommandList_CopyTextureRegion( *this->copyCommand.gfxList, &dstLoc, 0, 0, 0, &srcLoc, NULL); - // execute all the commands + // execute the compute commands d12_commandGroupExecute(*this->computeQueue, &this->computeCommand); - d12_commandGroupWait(&this->computeCommand); - if (!d12_commandGroupReset(&this->computeCommand)) - goto exit; - d12_commandGroupExecute(*this->copyQueue , &this->copyCommand ); + // insert a fence to wait for the compute commands to finish + ID3D12CommandQueue_Wait(*this->copyQueue, + *this->computeCommand.fence, this->computeCommand.fenceValue); + + // execute the copy commands + d12_commandGroupExecute(*this->copyQueue, &this->copyCommand); + + // wait for the copy to complete d12_commandGroupWait(&this->copyCommand); - if (!d12_commandGroupReset(&this->copyCommand)) - goto exit; // signal the frame is complete framebuffer_set_write_ptr(frameBuffer, this->dstFormat.Height * this->dstFormat.Width * 4); + // reset the command queues + if (!d12_commandGroupReset(&this->computeCommand) || + !d12_commandGroupReset(&this->copyCommand)) + goto exit; + result = CAPTURE_RESULT_OK; exit: