diff --git a/src/dxvk/dxvk_cmdlist.cpp b/src/dxvk/dxvk_cmdlist.cpp index 2c082247..b3ff05b7 100644 --- a/src/dxvk/dxvk_cmdlist.cpp +++ b/src/dxvk/dxvk_cmdlist.cpp @@ -35,6 +35,30 @@ namespace dxvk { } + void DxvkCommandList::submit( + VkQueue queue, + VkSemaphore waitSemaphore, + VkSemaphore wakeSemaphore, + VkFence fence) { + const VkPipelineStageFlags waitStageMask + = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; + + VkSubmitInfo info; + info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + info.pNext = nullptr; + info.waitSemaphoreCount = waitSemaphore == VK_NULL_HANDLE ? 0 : 1; + info.pWaitSemaphores = &waitSemaphore; + info.pWaitDstStageMask = &waitStageMask; + info.commandBufferCount = 1; + info.pCommandBuffers = &m_buffer; + info.signalSemaphoreCount = wakeSemaphore == VK_NULL_HANDLE ? 0 : 1; + info.pSignalSemaphores = &wakeSemaphore; + + if (m_vkd->vkQueueSubmit(queue, 1, &info, fence) != VK_SUCCESS) + throw DxvkError("DxvkDevice::submitCommandList: Command submission failed"); + } + + void DxvkCommandList::beginRecording() { VkCommandBufferBeginInfo info; info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index 5895cdc2..0e107b7b 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -26,12 +26,18 @@ namespace dxvk { ~DxvkCommandList(); /** - * \brief Command buffer handle - * \returns Command buffer handle + * \brief Submits command list + * + * \param [in] queue Device queue + * \param [in] waitSemaphore Semaphore to wait on + * \param [in] wakeSemaphore Semaphore to signal + * \param [in] fence Fence to signal */ - VkCommandBuffer handle() const { - return m_buffer; - } + void submit( + VkQueue queue, + VkSemaphore waitSemaphore, + VkSemaphore wakeSemaphore, + VkFence fence); /** * \brief Begins recording diff --git a/src/dxvk/dxvk_device.cpp b/src/dxvk/dxvk_device.cpp index ed606fa2..604cb1ea 100644 --- a/src/dxvk/dxvk_device.cpp +++ b/src/dxvk/dxvk_device.cpp @@ -105,9 +105,8 @@ namespace dxvk { const Rc& wakeSync) { Rc fence = new DxvkFence(m_vkd); - VkCommandBuffer commandBuffer = commandList->handle(); - VkSemaphore waitSemaphore = VK_NULL_HANDLE; - VkSemaphore wakeSemaphore = VK_NULL_HANDLE; + VkSemaphore waitSemaphore = VK_NULL_HANDLE; + VkSemaphore wakeSemaphore = VK_NULL_HANDLE; if (waitSync != nullptr) { waitSemaphore = waitSync->handle(); @@ -119,22 +118,8 @@ namespace dxvk { commandList->trackResource(wakeSync); } - const VkPipelineStageFlags waitStageMask - = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; - - VkSubmitInfo info; - info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - info.pNext = nullptr; - info.waitSemaphoreCount = waitSemaphore == VK_NULL_HANDLE ? 0 : 1; - info.pWaitSemaphores = &waitSemaphore; - info.pWaitDstStageMask = &waitStageMask; - info.commandBufferCount = commandBuffer == VK_NULL_HANDLE ? 0 : 1; - info.pCommandBuffers = &commandBuffer; - info.signalSemaphoreCount = wakeSemaphore == VK_NULL_HANDLE ? 0 : 1; - info.pSignalSemaphores = &wakeSemaphore; - - if (m_vkd->vkQueueSubmit(m_graphicsQueue, 1, &info, fence->handle()) != VK_SUCCESS) - throw DxvkError("DxvkDevice::submitCommandList: Command submission failed"); + commandList->submit(m_graphicsQueue, + waitSemaphore, wakeSemaphore, fence->handle()); // TODO Delay synchronization by putting these into a ring buffer fence->wait(std::numeric_limits::max());