VulkanRenderer/QueueHandle: Add overloads able to take multiple wait/signal semaphores

This commit is contained in:
Lynix 2020-03-14 17:35:03 +01:00
parent 91c05abd19
commit 7cce08ecfd
2 changed files with 31 additions and 0 deletions

View File

@ -32,6 +32,8 @@ namespace Nz
inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const;
inline bool Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const;
inline bool Submit(VkCommandBuffer commandBuffer, std::initializer_list<VkSemaphore> waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list<VkSemaphore> signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const;
inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list<VkSemaphore> waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list<VkSemaphore> signalSemaphores, 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(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const;
inline bool Submit(const VkSubmitInfo& submit, VkFence signalFence = VK_NULL_HANDLE) const;

View File

@ -4,6 +4,7 @@
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/StackArray.hpp>
#include <Nazara/VulkanRenderer/Utils.hpp>
#include <Nazara/VulkanRenderer/Debug.hpp>
@ -68,6 +69,34 @@ namespace Nz
return Submit(1U, &commandBuffer, waitSemaphore, waitStage, signalSemaphore, signalFence);
}
inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, std::initializer_list<VkSemaphore> waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list<VkSemaphore> signalSemaphores, VkFence signalFence) const
{
return Submit(1U, &commandBuffer, waitSemaphores, waitStage, signalSemaphores, signalFence);
}
inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list<VkSemaphore> waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list<VkSemaphore> signalSemaphores, VkFence signalFence) const
{
// Make continuous array of semaphores (initializer_list doesn't have that guarantee)
StackArray<VkSemaphore> signalSemaphoresCont = NazaraStackArrayNoInit(VkSemaphore, signalSemaphores.size());
StackArray<VkSemaphore> waitSemaphoresCont = NazaraStackArrayNoInit(VkSemaphore, waitSemaphores.size());
std::size_t i;
i = 0;
for (VkSemaphore semaphore : signalSemaphores)
signalSemaphoresCont[i++] = semaphore;
i = 0;
for (VkSemaphore semaphore : waitSemaphores)
waitSemaphoresCont[i++] = semaphore;
return Submit(commandBufferCount, commandBuffers, UInt32(waitSemaphoresCont.size()), waitSemaphoresCont.data(), waitStage, UInt32(signalSemaphoresCont.size()), signalSemaphoresCont.data(), signalFence);
}
inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const
{
return Submit(commandBufferCount, commandBuffers, (waitSemaphore) ? 1U : 0U, &waitSemaphore, waitStage, (signalSemaphore) ? 1U : 0U, &signalSemaphore, signalFence);
}
inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence) const
{
VkSubmitInfo submitInfo = {