diff --git a/openVulkanoCpp/Shader/ShaderCompiler.cpp b/openVulkanoCpp/Shader/ShaderCompiler.cpp index e8ccec7..e70a3f2 100644 --- a/openVulkanoCpp/Shader/ShaderCompiler.cpp +++ b/openVulkanoCpp/Shader/ShaderCompiler.cpp @@ -1,13 +1,16 @@ +#if defined(HAS_SHADERC) + #include "ShaderCompiler.hpp" #include "Base/Logger.hpp" +#include #include #include namespace OpenVulkano { -#if defined(HAS_SHADERC) + class ShaderIncluder : public shaderc::CompileOptions::IncluderInterface { struct IncludeData @@ -34,7 +37,7 @@ namespace OpenVulkano shaderc_shader_kind CheckStage(const std::string& extensionName) { - std::map stageMap = { + static std::map stageMap = { { "vert", shaderc_glsl_vertex_shader }, { "frag", shaderc_glsl_fragment_shader }, { "comp", shaderc_glsl_compute_shader }, { "geom", shaderc_glsl_geometry_shader }, { "tesc", shaderc_glsl_tess_control_shader }, { "tese", shaderc_glsl_tess_evaluation_shader }, @@ -50,7 +53,7 @@ namespace OpenVulkano } Array ShaderCompiler::CompileGLSLToSpirv(const std::string& absPath, bool hasIncludes, - const std::string& incPath, const std::string& entryPoint) + const std::string& incPath, const std::string& entryPoint) { Array file = Utils::ReadFile(absPath, false, true); @@ -66,11 +69,11 @@ namespace OpenVulkano shaderc::PreprocessedSourceCompilationResult preResult = shaderCompiler.PreprocessGlsl(file.Data(), CheckStage(extensionSplit.second), entryPoint.c_str(), options); - #if defined(_DEBUG) + #if defined(_DEBUG) std::string test = static_cast(preResult.begin(), preResult.end()); - // printf("Preprocessed shader: %s\n\n\n", test.c_str()); // Works fine - // Logger::APP->info("Preprocessed shader: {0}", test); gives error - #endif + // printf("Preprocessed shader: %s\n\n\n", test.c_str()); // Works fine + // Logger::APP->info("Preprocessed shader: {0}", test); gives error + #endif if (preResult.GetCompilationStatus() != shaderc_compilation_status_success) { @@ -124,5 +127,5 @@ namespace OpenVulkano if (std::filesystem::exists(path)) return path; else throw std::runtime_error("Failed to resolve include '" + requestedSource + "'!"); } -#endif } +#endif diff --git a/openVulkanoCpp/Shader/ShaderCompiler.hpp b/openVulkanoCpp/Shader/ShaderCompiler.hpp index ae3d561..4f42997 100644 --- a/openVulkanoCpp/Shader/ShaderCompiler.hpp +++ b/openVulkanoCpp/Shader/ShaderCompiler.hpp @@ -3,8 +3,6 @@ #include "Base/Utils.hpp" #include "Base/Wrapper.hpp" -#include - namespace OpenVulkano { class ShaderCompiler