From bd4d8ef385e8fdea6a85f9fa9699feec34db3c1a Mon Sep 17 00:00:00 2001
From: Mark Oliver Mints <mmints@uni-koblenz.de>
Date: Thu, 12 Aug 2021 08:00:52 +0200
Subject: [PATCH] [#71] Finalize comments and documentation for graphics
 pipeline

---
 src/vkcv/PipelineManager.cpp |  3 ++-
 src/vkcv/PipelineManager.hpp | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/vkcv/PipelineManager.cpp b/src/vkcv/PipelineManager.cpp
index 0271adca..ab9ad3f9 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 a95028c9..9cef6c26 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);
 
         /**
-- 
GitLab