Skip to content

Commit

Permalink
[host] d12: use a GPU side fence instead of CPU side
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Feb 4, 2024
1 parent b0b851d commit 319241b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions host/platform/Windows/capture/D12/d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 319241b

Please sign in to comment.