diff --git a/src/dxvk/dxvk_cmdlist.cpp b/src/dxvk/dxvk_cmdlist.cpp index de79d32f..46faf996 100644 --- a/src/dxvk/dxvk_cmdlist.cpp +++ b/src/dxvk/dxvk_cmdlist.cpp @@ -63,29 +63,23 @@ namespace dxvk { VkSemaphore wakeSemaphore) { const auto& graphics = m_device->queues().graphics; - std::array cmdBuffers; - uint32_t cmdBufferCount = 0; - + DxvkQueueSubmission info = { }; + if (m_cmdBuffersUsed.test(DxvkCmdBuffer::InitBuffer)) - cmdBuffers[cmdBufferCount++] = m_initBuffer; + info.cmdBuffers[info.cmdBufferCount++] = m_initBuffer; if (m_cmdBuffersUsed.test(DxvkCmdBuffer::ExecBuffer)) - cmdBuffers[cmdBufferCount++] = m_execBuffer; + info.cmdBuffers[info.cmdBufferCount++] = m_execBuffer; - const VkPipelineStageFlags waitStageMask - = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; + if (waitSemaphore) { + info.waitSync[info.waitCount] = waitSemaphore; + info.waitMask[info.waitCount] = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; + info.waitCount += 1; + } + + if (wakeSemaphore) + info.wakeSync[info.wakeCount++] = wakeSemaphore; - 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 = cmdBufferCount; - info.pCommandBuffers = cmdBuffers.data(); - info.signalSemaphoreCount = wakeSemaphore == VK_NULL_HANDLE ? 0 : 1; - info.pSignalSemaphores = &wakeSemaphore; - - return m_vkd->vkQueueSubmit(graphics.queueHandle, 1, &info, m_fence); + return submitToQueue(graphics.queueHandle, m_fence, info); } @@ -152,5 +146,24 @@ namespace dxvk { // Less important stuff m_statCounters.reset(); } + + + VkResult DxvkCommandList::submitToQueue( + VkQueue queue, + VkFence fence, + const DxvkQueueSubmission& info) { + VkSubmitInfo submitInfo; + submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + submitInfo.pNext = nullptr; + submitInfo.waitSemaphoreCount = info.waitCount; + submitInfo.pWaitSemaphores = info.waitSync; + submitInfo.pWaitDstStageMask = info.waitMask; + submitInfo.commandBufferCount = info.cmdBufferCount; + submitInfo.pCommandBuffers = info.cmdBuffers; + submitInfo.signalSemaphoreCount = info.wakeCount; + submitInfo.pSignalSemaphores = info.wakeSync; + + return m_vkd->vkQueueSubmit(queue, 1, &submitInfo, fence); + } } \ No newline at end of file diff --git a/src/dxvk/dxvk_cmdlist.h b/src/dxvk/dxvk_cmdlist.h index 0777fed7..e93717ad 100644 --- a/src/dxvk/dxvk_cmdlist.h +++ b/src/dxvk/dxvk_cmdlist.h @@ -29,6 +29,23 @@ namespace dxvk { using DxvkCmdBufferFlags = Flags; + /** + * \brief Queue submission info + * + * Convenience struct that holds data for + * actual command submissions. Internal use + * only, array sizes are based on need. + */ + struct DxvkQueueSubmission { + uint32_t waitCount; + VkSemaphore waitSync[2]; + VkPipelineStageFlags waitMask[2]; + uint32_t wakeCount; + VkSemaphore wakeSync[2]; + uint32_t cmdBufferCount; + VkCommandBuffer cmdBuffers[4]; + }; + /** * \brief DXVK command list * @@ -744,6 +761,11 @@ namespace dxvk { VkCommandBuffer getCmdBuffer(DxvkCmdBuffer cmdBuffer) const { return cmdBuffer == DxvkCmdBuffer::ExecBuffer ? m_execBuffer : m_initBuffer; } + + VkResult submitToQueue( + VkQueue queue, + VkFence fence, + const DxvkQueueSubmission& info); };