#pragma once #include "Base/Utils.hpp" #include "Base/Wrapper.hpp" #include #include #include namespace OpenVulkano { class ShaderIncluder : public shaderc::CompileOptions::IncluderInterface { public: ShaderIncluder(const std::string& path); ~ShaderIncluder() override = default; shaderc_include_result* GetInclude(const char* requested_source, shaderc_include_type type, const char* requesting_source, uint64_t include_depth) override; void ReleaseInclude(shaderc_include_result* data) override; private: std::string ResolveInclude(const std::string requestedSource); const char* RecordInclude(const std::string& requestedSource); const char* GetActualPath(const std::string& requestedSource); private: std::vector m_includes; }; class ShaderCompiler { public: /** * @param absPath - absolute path of the shader that needs to be compiled * @param incPath - include path that will be used to resolve includes * @param entryPoint - the name of the void function in the shader * @param shaderStage - type of the shader that needs to be compiled * @param bHaveIncludes - if incPath is empty, make it false */ static Unique CompileGLSLToSpirv(const std::string& absPath, const std::string& incPath, const std::string& entryPoint, shaderc_shader_kind shaderStage, bool bHaveIncludes); }; }