fence support in commandbuffer

This commit is contained in:
PancakeTAS 2025-06-29 17:20:38 +02:00
parent d3f5d87d61
commit 20fcab9a88
No known key found for this signature in database
2 changed files with 5 additions and 3 deletions

View file

@ -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> fence,
const std::vector<Semaphore>& waitSemaphores = {},
std::optional<std::vector<uint64_t>> waitSemaphoreValues = std::nullopt,
const std::vector<Semaphore>& signalSemaphores = {},

View file

@ -55,7 +55,7 @@ void CommandBuffer::end() {
*this->state = CommandBufferState::Full;
}
void CommandBuffer::submit(VkQueue queue,
void CommandBuffer::submit(VkQueue queue, std::optional<Fence> fence,
const std::vector<Semaphore>& waitSemaphores,
std::optional<std::vector<uint64_t>> waitSemaphoreValues,
const std::vector<Semaphore>& signalSemaphores,
@ -106,7 +106,7 @@ void CommandBuffer::submit(VkQueue queue,
.signalSemaphoreCount = static_cast<uint32_t>(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");