1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 13:24:10 +01:00

[dxvk] Refactor queue submission

This commit is contained in:
Philip Rebohle 2019-06-28 01:24:10 +02:00
parent 545cd52020
commit 4e0de6bc20
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 54 additions and 19 deletions

View File

@ -63,29 +63,23 @@ namespace dxvk {
VkSemaphore wakeSemaphore) {
const auto& graphics = m_device->queues().graphics;
std::array<VkCommandBuffer, 2> 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;
}
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;
if (wakeSemaphore)
info.wakeSync[info.wakeCount++] = wakeSemaphore;
return m_vkd->vkQueueSubmit(graphics.queueHandle, 1, &info, m_fence);
return submitToQueue(graphics.queueHandle, m_fence, info);
}
@ -153,4 +147,23 @@ namespace dxvk {
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);
}
}

View File

@ -29,6 +29,23 @@ namespace dxvk {
using DxvkCmdBufferFlags = Flags<DxvkCmdBuffer>;
/**
* \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
*
@ -745,6 +762,11 @@ namespace dxvk {
return cmdBuffer == DxvkCmdBuffer::ExecBuffer ? m_execBuffer : m_initBuffer;
}
VkResult submitToQueue(
VkQueue queue,
VkFence fence,
const DxvkQueueSubmission& info);
};
}