diff --git a/include/core/commandbuffer.hpp b/include/core/commandbuffer.hpp index 20a8105..4c73ff6 100644 --- a/include/core/commandbuffer.hpp +++ b/include/core/commandbuffer.hpp @@ -2,6 +2,7 @@ #define COMMANDBUFFER_HPP #include "core/commandpool.hpp" +#include "core/fence.hpp" #include "core/semaphore.hpp" #include "device.hpp" @@ -65,6 +66,7 @@ namespace Vulkan::Core { /// Submit the command buffer to a queue. /// /// @param queue Vulkan queue to submit to + /// @param fence Optional fence to signal when the command buffer has finished executing /// @param waitSemaphores Semaphores to wait on before executing the command buffer /// @param waitSemaphoreValues Values for the semaphores to wait on /// @param signalSemaphores Semaphores to signal after executing the command buffer @@ -74,7 +76,7 @@ namespace Vulkan::Core { /// @throws std::logic_error if the command buffer is not in Full state. /// @throws ls::vulkan_error if submission fails. /// - void submit(VkQueue queue, // TODO: fence + void submit(VkQueue queue, std::optional fence, const std::vector& waitSemaphores = {}, std::optional> waitSemaphoreValues = std::nullopt, const std::vector& signalSemaphores = {}, diff --git a/src/core/commandbuffer.cpp b/src/core/commandbuffer.cpp index 173b15a..6a03d99 100644 --- a/src/core/commandbuffer.cpp +++ b/src/core/commandbuffer.cpp @@ -55,7 +55,7 @@ void CommandBuffer::end() { *this->state = CommandBufferState::Full; } -void CommandBuffer::submit(VkQueue queue, +void CommandBuffer::submit(VkQueue queue, std::optional fence, const std::vector& waitSemaphores, std::optional> waitSemaphoreValues, const std::vector& signalSemaphores, @@ -106,7 +106,7 @@ void CommandBuffer::submit(VkQueue queue, .signalSemaphoreCount = static_cast(signalSemaphores.size()), .pSignalSemaphores = signalSemaphoresHandles.data() }; - auto res = vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE); + auto res = vkQueueSubmit(queue, 1, &submitInfo, fence ? fence->handle() : VK_NULL_HANDLE); if (res != VK_SUCCESS) throw ls::vulkan_error(res, "Unable to submit command buffer");