From dd0d611d4d88daae7f3cab2dc34bd9b6e36e6c36 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 22 Aug 2022 05:52:28 +0200 Subject: [PATCH] [dxvk] Reintroduce binary semaphore for transfer <-> graphics sync The global timeline semaphore does not work here since we could be signaling it from two different queues at the same time, or out of order. --- src/dxvk/dxvk_cmdlist.cpp | 11 +++++++---- src/dxvk/dxvk_cmdlist.h | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dxvk/dxvk_cmdlist.cpp b/src/dxvk/dxvk_cmdlist.cpp index fd185b387..0d63dd5c6 100644 --- a/src/dxvk/dxvk_cmdlist.cpp +++ b/src/dxvk/dxvk_cmdlist.cpp @@ -11,6 +11,9 @@ namespace dxvk { const auto& graphicsQueue = m_device->queues().graphics; const auto& transferQueue = m_device->queues().transfer; + VkSemaphoreCreateInfo semaphoreInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; + m_vkd->vkCreateSemaphore(m_vkd->device(), &semaphoreInfo, nullptr, &m_sdmaSemaphore); + VkCommandPoolCreateInfo poolInfo; poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; poolInfo.pNext = nullptr; @@ -53,6 +56,8 @@ namespace dxvk { m_vkd->vkDestroyCommandPool(m_vkd->device(), m_graphicsPool, nullptr); m_vkd->vkDestroyCommandPool(m_vkd->device(), m_transferPool, nullptr); + + m_vkd->vkDestroySemaphore(m_vkd->device(), m_sdmaSemaphore, nullptr); } @@ -71,8 +76,7 @@ namespace dxvk { if (m_device->hasDedicatedTransferQueue()) { VkSemaphoreSubmitInfo signalInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO }; - signalInfo.semaphore = semaphore; - signalInfo.value = ++semaphoreValue; + signalInfo.semaphore = m_sdmaSemaphore; signalInfo.stageMask = VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT; m_submission.signalInfos.push_back(signalInfo); @@ -84,8 +88,7 @@ namespace dxvk { m_submission.reset(); VkSemaphoreSubmitInfo waitInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO }; - waitInfo.semaphore = semaphore; - waitInfo.value = semaphoreValue; + waitInfo.semaphore = m_sdmaSemaphore; waitInfo.stageMask = VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT; m_submission.waitInfos.push_back(waitInfo); } diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index 297b2be67..ca04d13f1 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -818,6 +818,8 @@ namespace dxvk { VkCommandBuffer m_initBuffer = VK_NULL_HANDLE; VkCommandBuffer m_sdmaBuffer = VK_NULL_HANDLE; + VkSemaphore m_sdmaSemaphore = VK_NULL_HANDLE; + vk::PresenterSync m_wsiSemaphores = { }; DxvkCmdBufferFlags m_cmdBuffersUsed;