From 0723250c12188e571d412d88e9a9771b22a6a180 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 18 Oct 2024 10:14:22 +0200 Subject: [PATCH] [dxvk] Introduce flag to synchronize transfer queue Also, get rid of superfluous binary semaphores since we have a straight per-submission timeline anyway. --- src/dxvk/dxvk_cmdlist.cpp | 14 +++++++++++++- src/dxvk/dxvk_cmdlist.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/dxvk/dxvk_cmdlist.cpp b/src/dxvk/dxvk_cmdlist.cpp index 9838273e..e864368f 100644 --- a/src/dxvk/dxvk_cmdlist.cpp +++ b/src/dxvk/dxvk_cmdlist.cpp @@ -232,7 +232,7 @@ namespace dxvk { timelines.graphics, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT); } - // Submit transfer commands as necessary + // Execute transfer command buffer, if any if (cmd.usedFlags.test(DxvkCmdBuffer::SdmaBuffer)) m_commandSubmission.executeCommandBuffer(cmd.sdmaBuffer); @@ -294,6 +294,16 @@ namespace dxvk { if ((status = m_commandSubmission.submit(m_device, graphics.queueHandle))) return status; } + + // Finally, submit semaphore wait on the transfer queue. If this + // is not the final iteration, fold the wait into the next one. + if (cmd.syncSdma) { + m_commandSubmission.waitSemaphore(semaphores.graphics, + timelines.graphics, VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT); + + if (isLast && (status = m_commandSubmission.submit(m_device, transfer.queueHandle))) + return status; + } } return VK_SUCCESS; @@ -349,7 +359,9 @@ namespace dxvk { m_cmd.sdmaBuffer = m_transferPool->getCommandBuffer(); } + m_cmd.syncSdma = VK_FALSE; m_cmd.usedFlags = 0; + m_cmd.sparseBind = VK_FALSE; } diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index 673555b2..da59fc95 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -145,6 +145,7 @@ namespace dxvk { */ struct DxvkCommandSubmissionInfo { DxvkCmdBufferFlags usedFlags = 0; + VkBool32 syncSdma = VK_FALSE; VkCommandBuffer execBuffer = VK_NULL_HANDLE; VkCommandBuffer initBuffer = VK_NULL_HANDLE; VkCommandBuffer sdmaBuffer = VK_NULL_HANDLE; @@ -366,6 +367,17 @@ namespace dxvk { m_wsiSemaphores = wsiSemaphores; } + /** + * \brief Sets flag to stall transfer queue + * + * If set, the current submission will submit a semaphore + * wait to the transfer queue in order to stall subsequent + * submissions. Necessary in case of resource relocations. + */ + void setSubmissionBarrier() { + m_cmd.syncSdma = VK_TRUE; + } + /** * \brief Resets the command list *