mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 19:24:12 +01:00
[dxvk] Refactor queue submission
This commit is contained in:
parent
545cd52020
commit
4e0de6bc20
@ -63,29 +63,23 @@ namespace dxvk {
|
|||||||
VkSemaphore wakeSemaphore) {
|
VkSemaphore wakeSemaphore) {
|
||||||
const auto& graphics = m_device->queues().graphics;
|
const auto& graphics = m_device->queues().graphics;
|
||||||
|
|
||||||
std::array<VkCommandBuffer, 2> cmdBuffers;
|
DxvkQueueSubmission info = { };
|
||||||
uint32_t cmdBufferCount = 0;
|
|
||||||
|
|
||||||
if (m_cmdBuffersUsed.test(DxvkCmdBuffer::InitBuffer))
|
if (m_cmdBuffersUsed.test(DxvkCmdBuffer::InitBuffer))
|
||||||
cmdBuffers[cmdBufferCount++] = m_initBuffer;
|
info.cmdBuffers[info.cmdBufferCount++] = m_initBuffer;
|
||||||
if (m_cmdBuffersUsed.test(DxvkCmdBuffer::ExecBuffer))
|
if (m_cmdBuffersUsed.test(DxvkCmdBuffer::ExecBuffer))
|
||||||
cmdBuffers[cmdBufferCount++] = m_execBuffer;
|
info.cmdBuffers[info.cmdBufferCount++] = m_execBuffer;
|
||||||
|
|
||||||
const VkPipelineStageFlags waitStageMask
|
if (waitSemaphore) {
|
||||||
= VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
info.waitSync[info.waitCount] = waitSemaphore;
|
||||||
|
info.waitMask[info.waitCount] = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||||
|
info.waitCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
VkSubmitInfo info;
|
if (wakeSemaphore)
|
||||||
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
info.wakeSync[info.wakeCount++] = wakeSemaphore;
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,4 +147,23 @@ namespace dxvk {
|
|||||||
m_statCounters.reset();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -29,6 +29,23 @@ namespace dxvk {
|
|||||||
|
|
||||||
using DxvkCmdBufferFlags = Flags<DxvkCmdBuffer>;
|
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
|
* \brief DXVK command list
|
||||||
*
|
*
|
||||||
@ -745,6 +762,11 @@ namespace dxvk {
|
|||||||
return cmdBuffer == DxvkCmdBuffer::ExecBuffer ? m_execBuffer : m_initBuffer;
|
return cmdBuffer == DxvkCmdBuffer::ExecBuffer ? m_execBuffer : m_initBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult submitToQueue(
|
||||||
|
VkQueue queue,
|
||||||
|
VkFence fence,
|
||||||
|
const DxvkQueueSubmission& info);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user