From ceccf4be5f2d7f59966fa85bcc60b799ed4bdab1 Mon Sep 17 00:00:00 2001 From: MrTroble Date: Fri, 22 Sep 2023 19:37:53 +0200 Subject: [PATCH] fix: system for shader generation --- TGEngine/private/graphics/Vulkan/VulkanShaderModule.cpp | 7 +++++++ TGEngine/public/Error.hpp | 1 + TGEngine/public/headerlibs/ShaderPermute.hpp | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TGEngine/private/graphics/Vulkan/VulkanShaderModule.cpp b/TGEngine/private/graphics/Vulkan/VulkanShaderModule.cpp index 244aa9a..30f2151 100644 --- a/TGEngine/private/graphics/Vulkan/VulkanShaderModule.cpp +++ b/TGEngine/private/graphics/Vulkan/VulkanShaderModule.cpp @@ -14,8 +14,15 @@ #undef ERROR #define SPR_NO_DEBUG_OUTPUT 1 #define SPR_NO_GLSL_INCLUDE 1 +#define SPR_NO_STATIC 1 +#define SPR_STATIC extern #include "../../../public/headerlibs/ShaderPermute.hpp" +namespace permute { +std::map lookupCounter; +permute::lookup glslLookup = {{"next", next}}; +} // namespace permute + namespace tge::shader { using namespace vk; diff --git a/TGEngine/public/Error.hpp b/TGEngine/public/Error.hpp index 753e7ba..2d55048 100644 --- a/TGEngine/public/Error.hpp +++ b/TGEngine/public/Error.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/TGEngine/public/headerlibs/ShaderPermute.hpp b/TGEngine/public/headerlibs/ShaderPermute.hpp index 8961df4..1ae45e6 100644 --- a/TGEngine/public/headerlibs/ShaderPermute.hpp +++ b/TGEngine/public/headerlibs/ShaderPermute.hpp @@ -265,7 +265,7 @@ struct GlslSettings { SPR_STATIC std::map lookupCounter; -SPR_STATIC std::string next(const std::string &input) { +inline std::string next(const std::string &input) { const auto id = lookupCounter[input]; lookupCounter[input]++; #ifdef SPR_USE_FORMAT_LIB @@ -285,7 +285,9 @@ SPR_STATIC std::string next(const std::string &input) { SPR_STATIC lookup glslLookup #ifndef SPR_NO_STATIC - = {{"next", next}} + = {{"next", next}}; +#else + ; #endif // SPR_STATIC ;