diff --git a/include/vkcv/CommandResources.hpp b/include/vkcv/CommandResources.hpp index a5bdf7ac40c918c113f676ab4881db0daf73858f..946e9c539b988fc305f90a5fa48c6c978fb590a8 100644 --- a/include/vkcv/CommandResources.hpp +++ b/include/vkcv/CommandResources.hpp @@ -16,19 +16,94 @@ namespace vkcv { std::vector<vk::CommandPool> cmdPoolPerQueueFamily; }; - std::unordered_set<int> generateQueueFamilyIndexSet(const QueueManager& queueManager); - CommandResources createCommandResources(const vk::Device& device, const std::unordered_set<int> &familyIndexSet); - void destroyCommandResources(const vk::Device& device, const CommandResources& resources); - vk::CommandBuffer allocateCommandBuffer(const vk::Device& device, const vk::CommandPool &cmdPool); - vk::CommandPool chooseCmdPool(const Queue &queue, const CommandResources &cmdResources); - Queue getQueueForSubmit(QueueType type, const QueueManager &queueManager); - void beginCommandBuffer(const vk::CommandBuffer &cmdBuffer, vk::CommandBufferUsageFlags flags); + /** + * @brief Generates a set of the family indices for all different kinds of + * queues a given queue manager provides. + * + * @param[in] queueManager Queue manager + * @return Set of queue family indices + */ + std::unordered_set<int> generateQueueFamilyIndexSet(const QueueManager &queueManager); + + /** + * @brief Creates and returns a new command resources instance containing + * a vector of newly allocated command pools for each different queue family + * index in a given set. + * + * @param[in,out] device Vulkan device + * @param[in] familyIndexSet Set of queue family indices + * @return New command resources + */ + CommandResources createCommandResources(const vk::Device &device, + const std::unordered_set<int> &familyIndexSet); + + /** + * @brief Destroys a command resources instance and deallocates its command + * pools. The command resources will be invalid to use afterwards. + * + * @param[in,out] device Vulkan device + * @param[in,out] resources Command resources + */ + void destroyCommandResources(const vk::Device &device, + const CommandResources &resources); + + /** + * @brief Allocates and returns a new primary command buffer of a given + * command pool. + * + * @param[in,out] device Vulkan device + * @param[in,out] cmdPool Vulkan command pool + * @return New vulkan command buffer + */ + vk::CommandBuffer allocateCommandBuffer(const vk::Device &device, + const vk::CommandPool &cmdPool); + + /** + * @brief Returns the matching command pool of given command resources for + * a specific queue. + * + * @param[in] queue Queue + * @param[in] cmdResources Command resources + * @return Command pool for a given queue + */ + vk::CommandPool chooseCmdPool(const Queue &queue, + const CommandResources &cmdResources); + + /** + * @brief Returns a queue of a given type from a queue manager. + * + * @param[in] type Type of queue + * @param[in] queueManager Queue manager + * @return Queue of a given type + */ + Queue getQueueForSubmit(QueueType type, + const QueueManager &queueManager); + + /** + * @brief Begins the usage of a command buffer with given command buffer + * usage flags. + * + * @param[in] cmdBuffer Vulkan command buffer + * @param[in] flags Command buffer usage flags + */ + void beginCommandBuffer(const vk::CommandBuffer &cmdBuffer, + vk::CommandBufferUsageFlags flags); - void submitCommandBufferToQueue( - vk::Queue queue, - vk::CommandBuffer cmdBuffer, - vk::Fence fence, - const std::vector<vk::Semaphore>& waitSemaphores, - const std::vector<vk::Semaphore>& signalSemaphores); + /** + * @brief Submits a command buffer into a queue with given fence and + * semaphores to wait for or to signal after processing the command + * buffer. + * + * @param[in,out] queue Vulkan queue + * @param[in] cmdBuffer Vulkan command buffer + * @param[in] fence Vulkan fence to wait for + * @param[in] waitSemaphores Vector of semaphores to wait for + * @param[in] signalSemaphores Vector of semaphores to signal + */ + void submitCommandBufferToQueue(vk::Queue queue, + const vk::CommandBuffer &cmdBuffer, + const vk::Fence &fence, + const std::vector<vk::Semaphore>& waitSemaphores, + const std::vector<vk::Semaphore>& signalSemaphores); } \ No newline at end of file diff --git a/src/vkcv/CommandResources.cpp b/src/vkcv/CommandResources.cpp index 87be5998b2592d52ae134f0b3f6ec3bb183eddb3..d5c97946aa97ba897710dda412b6f71bd2ed54c8 100644 --- a/src/vkcv/CommandResources.cpp +++ b/src/vkcv/CommandResources.cpp @@ -75,10 +75,10 @@ namespace vkcv { void submitCommandBufferToQueue( vk::Queue queue, - vk::CommandBuffer cmdBuffer, - vk::Fence fence, - const std::vector<vk::Semaphore>& waitSemaphores, - const std::vector<vk::Semaphore>& signalSemaphores) { + const vk::CommandBuffer &cmdBuffer, + const vk::Fence &fence, + const std::vector<vk::Semaphore> &waitSemaphores, + const std::vector<vk::Semaphore> &signalSemaphores) { const std::vector<vk::PipelineStageFlags> waitDstStageMasks(waitSemaphores.size(), vk::PipelineStageFlagBits::eAllCommands); const vk::SubmitInfo queueSubmitInfo(waitSemaphores, waitDstStageMasks, cmdBuffer, signalSemaphores);