Improve synchronization based on vulkan-tutorial

https://vulkan-tutorial.com/Drawing_a_triangle/Drawing/Rendering_and_presentation
This commit is contained in:
Lynix
2020-03-04 20:13:37 +01:00
parent 771355ec87
commit 9515f1c807
9 changed files with 94 additions and 79 deletions

View File

@@ -30,8 +30,10 @@ namespace Nz
inline bool Present(const VkPresentInfoKHR& presentInfo) const;
inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const;
inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE) const;
inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE) const;
inline bool Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const;
inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const;
inline bool Submit(const VkSubmitInfo& submit, VkFence signalFence = VK_NULL_HANDLE) const;
inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence = VK_NULL_HANDLE) const;
inline bool WaitIdle() const;

View File

@@ -76,14 +76,36 @@ namespace Nz
return Present(presentInfo);
}
inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) const
inline bool Queue::Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const
{
return Submit(1, &submit, fence);
return Submit(1U, &commandBuffer, waitSemaphore, waitStage, signalSemaphore, signalFence);
}
inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) const
inline bool Queue::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const
{
m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, fence);
VkSubmitInfo submitInfo = {
VK_STRUCTURE_TYPE_SUBMIT_INFO,
nullptr,
(waitSemaphore) ? 1U : 0U,
&waitSemaphore,
&waitStage,
commandBufferCount,
commandBuffers,
(signalSemaphore) ? 1U : 0U,
&signalSemaphore
};
return Submit(submitInfo, signalFence);
}
inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence signalFence) const
{
return Submit(1, &submit, signalFence);
}
inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence) const
{
m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, signalFence);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to submit queue: " + TranslateVulkanError(m_lastErrorCode));