diff --git a/modules/shader_compiler/include/vkcv/shader/Compiler.hpp b/modules/shader_compiler/include/vkcv/shader/Compiler.hpp index 32590e164c834bd1ed92e99c19651750a0becf1c..3ffa251694ba408e3cd0ee3aba8c83fa97a6a0cb 100644 --- a/modules/shader_compiler/include/vkcv/shader/Compiler.hpp +++ b/modules/shader_compiler/include/vkcv/shader/Compiler.hpp @@ -14,25 +14,63 @@ namespace vkcv::shader { * A module to use runtime shader compilation. * @{ */ - + + /** + * An event function type to react on shader compilation. + */ typedef typename event_function<ShaderStage, const std::filesystem::path&>::type ShaderCompiledFunction; - + + /** + * An abstract class to handle runtime shader compilation. + */ class Compiler { private: protected: + /** + * A map containing macros for shader compilation. + */ std::unordered_map<std::string, std::string> m_defines; public: + /** + * Compile a shader from source for a target stage with a custom shader + * include path and an event function called if the compilation completes. + * @param[in] shaderStage Shader pipeline stage + * @param[in] shaderSource Source of shader + * @param[in] compiled Shader compilation event + * @param[in] includePath Include path for shaders + * @return Result if the compilation succeeds + */ virtual bool compileSource(ShaderStage shaderStage, const char* shaderSource, const ShaderCompiledFunction& compiled, const std::filesystem::path& includePath) = 0; - + + /** + * Compile a shader from a specific file path for a target stage with + * a custom shader include path and an event function called if the + * compilation completes. + * @param[in] shaderStage Shader pipeline stage + * @param[in] shaderPath Filepath of shader + * @param[in] compiled Shader compilation event + * @param[in] includePath Include path for shaders + * @param[in] update Flag to update shaders during runtime + */ virtual void compile(ShaderStage shaderStage, const std::filesystem::path& shaderPath, const ShaderCompiledFunction& compiled, const std::filesystem::path& includePath, bool update) = 0; - + + /** + * Return the definition value of a macro for shader compilation. + * @param[in] name Macro definition name + * @return Macro definition value + */ std::string getDefine(const std::string& name) const; - + + /** + * Set a macro for shader compilation. + * @param[in] name Macro definition name + * @param[in] value Macro definition value + */ void setDefine(const std::string& name, const std::string& value); }; diff --git a/modules/shader_compiler/include/vkcv/shader/GLSLCompiler.hpp b/modules/shader_compiler/include/vkcv/shader/GLSLCompiler.hpp index a50c5ae0a103592d167f88b2c1db3f190f973948..66e2b1fbd7a61625b00902a0171c78875430d0ed 100644 --- a/modules/shader_compiler/include/vkcv/shader/GLSLCompiler.hpp +++ b/modules/shader_compiler/include/vkcv/shader/GLSLCompiler.hpp @@ -11,24 +11,61 @@ namespace vkcv::shader { * @addtogroup vkcv_shader * @{ */ - + + /** + * A class to handle GLSL runtime shader compilation. + */ class GLSLCompiler : public Compiler { private: public: + /** + * The constructor of a runtime GLSL shader compiler instance. + */ GLSLCompiler(); - + + /** + * The copy-constructor of a runtime GLSL shader compiler instance. + * @param other Other instance of a GLSL shader compiler instance + */ GLSLCompiler(const GLSLCompiler& other); GLSLCompiler(GLSLCompiler&& other) = default; - + + /** + * The destructor of a runtime GLSL shader compiler instance. + */ ~GLSLCompiler(); - + + /** + * The copy-operator of a runtime GLSL shader compiler instance. + * @param other Other instance of a GLSL shader compiler instance + * @return Reference to this instance + */ GLSLCompiler& operator=(const GLSLCompiler& other); GLSLCompiler& operator=(GLSLCompiler&& other) = default; - + + /** + * Compile a GLSL shader from source for a target stage with a custom shader + * include path and an event function called if the compilation completes. + * @param[in] shaderStage Shader pipeline stage + * @param[in] shaderSource Source of shader + * @param[in] compiled Shader compilation event + * @param[in] includePath Include path for shaders + * @return Result if the compilation succeeds + */ bool compileSource(ShaderStage shaderStage, const char* shaderSource, const ShaderCompiledFunction& compiled, - const std::filesystem::path& includePath); - + const std::filesystem::path& includePath) override; + + /** + * Compile a GLSL shader from a specific file path for a target stage with + * a custom shader include path and an event function called if the + * compilation completes. + * @param[in] shaderStage Shader pipeline stage + * @param[in] shaderPath Filepath of shader + * @param[in] compiled Shader compilation event + * @param[in] includePath Include path for shaders + * @param[in] update Flag to update shaders during runtime + */ void compile(ShaderStage shaderStage, const std::filesystem::path& shaderPath, const ShaderCompiledFunction& compiled, const std::filesystem::path& includePath = "", bool update = false) override;