diff --git a/src/vkcv/PipelineManager.cpp b/src/vkcv/PipelineManager.cpp index 0271adca3aafbfc6afc19a418259b96e55ac8377..ab9ad3f9e497bd43dd539bf40f395e073877423c 100644 --- a/src/vkcv/PipelineManager.cpp +++ b/src/vkcv/PipelineManager.cpp @@ -318,10 +318,11 @@ namespace vkcv 0 ); - // Catch runtime error if the creation of the pipeline fails. vk::Pipeline vkPipeline{}; if (m_Device.createGraphicsPipelines(nullptr, 1, &graphicsPipelineCreateInfo, nullptr, &vkPipeline) != vk::Result::eSuccess) { + // Catch runtime error if the creation of the pipeline fails. + // Destroy everything to keep the memory clean. destroyShaderModules(); return PipelineHandle(); } diff --git a/src/vkcv/PipelineManager.hpp b/src/vkcv/PipelineManager.hpp index a95028c9a3b5a17018a0a95ff9263a1e2b030bea..9cef6c26c5d6fee67ace76bdc42f1410320e84c2 100644 --- a/src/vkcv/PipelineManager.hpp +++ b/src/vkcv/PipelineManager.hpp @@ -1,5 +1,13 @@ #pragma once +/** + * * @authors Mark Mints + * @file src/vkcv/PipelineManager.hpp + * @brief Creation and handling of pipelines + */ +// TODO: Edit @brief: add graphics pipeline, but only then when the compute part is in an own class. +// TODO: More authors? Do we need authors (general question)? + #include <vulkan/vulkan.hpp> #include <vector> #include "vkcv/Handles.hpp" @@ -21,18 +29,43 @@ namespace vkcv PipelineManager & operator=(const PipelineManager &other) = delete; // copy-assign op PipelineManager & operator=(PipelineManager &&other) = delete; // move-assign op + /** + * Creates a Graphics Pipeline based on the set shader stages in the Config Struct. + * This function is wrapped in /src/vkcv/Core.cpp by Core::createGraphicsPipeline(const PipelineConfig &config). + * Therefore the passManager is filled already by the overall context of an application. + * On application level it is necessary first to fill a PipelineConfig Struct. + * @param config Hands over all needed information for pipeline creation. + * @param passManager Hands over the corresponding render pass. + * @return A Handler to the created Pipeline Object. + */ PipelineHandle createPipeline(const PipelineConfig &config, PassManager& passManager); + // TODO: Move to ComputePipelineManager PipelineHandle createComputePipeline( const ShaderProgram& shaderProgram, const std::vector<vk::DescriptorSetLayout>& descriptorSetLayouts); + /** + * Returns a vk::Pipeline object by handle. + * @param handle Directing to the requested pipeline. + * @return vk::Pipeline. + */ [[nodiscard]] vk::Pipeline getVkPipeline(const PipelineHandle &handle) const; + /** + * Returns a vk::PipelineLayout object by handle. + * @param handle Directing to the requested pipeline. + * @return vk::PipelineLayout. + */ [[nodiscard]] vk::PipelineLayout getVkPipelineLayout(const PipelineHandle &handle) const; + /** + * Returns the corresponding Pipeline Config Struct of a pipeline object directed by the given Handler. + * @param handle Directing to the requested pipeline. + * @return Pipeline Config Struct + */ [[nodiscard]] const PipelineConfig &getPipelineConfig(const PipelineHandle &handle) const; @@ -48,6 +81,7 @@ namespace vkcv void destroyPipelineById(uint64_t id); + // TODO: Move to ComputePipelineManager vk::Result createShaderModule(vk::ShaderModule &module, const ShaderProgram &shaderProgram, ShaderStage stage); /**