From af28426d000ee96917a3f1f7ba870528502a25b8 Mon Sep 17 00:00:00 2001 From: Tobias Frisch <tfrisch@uni-koblenz.de> Date: Sat, 13 Jan 2024 18:42:54 +0100 Subject: [PATCH] Remove workarounds Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de> --- .../include/vkcv/shader/HLSLCompiler.hpp | 3 -- .../src/vkcv/shader/HLSLCompiler.cpp | 45 +------------------ 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/modules/shader_compiler/include/vkcv/shader/HLSLCompiler.hpp b/modules/shader_compiler/include/vkcv/shader/HLSLCompiler.hpp index 7a0319a2..6962e09f 100644 --- a/modules/shader_compiler/include/vkcv/shader/HLSLCompiler.hpp +++ b/modules/shader_compiler/include/vkcv/shader/HLSLCompiler.hpp @@ -23,9 +23,6 @@ namespace vkcv::shader { private: HLSLCompileTarget m_target; - protected: - std::string processShaderSource(const std::string& shaderSource) override; - public: /** * The constructor of a runtime HLSL shader compiler instance. diff --git a/modules/shader_compiler/src/vkcv/shader/HLSLCompiler.cpp b/modules/shader_compiler/src/vkcv/shader/HLSLCompiler.cpp index 4e8a2341..934993a7 100644 --- a/modules/shader_compiler/src/vkcv/shader/HLSLCompiler.cpp +++ b/modules/shader_compiler/src/vkcv/shader/HLSLCompiler.cpp @@ -152,47 +152,6 @@ namespace vkcv::shader { resources.limits.generalConstantMatrixVectorIndexing = true; } - // This is a workaround for multiple compatibility issues! - static std::string& fixShaderSource(std::string& source) { - size_t pos = 0; - while ((pos = source.find("float16_t", pos)) < std::string::npos) { - source = source.erase(pos + 5, 4); - } - - pos = 0; - while ((pos = source.find("float const", pos)) < std::string::npos) { - source = source.replace(pos, 11, "const float"); - } - - pos = 0; - while ((pos = source.find("0b", pos)) < std::string::npos) { - size_t len = 0; - - while (source[pos + 2 + len] == '0' || source[pos + 2 + len] == '1') { - len++; - } - - uint64_t value = 0; - for (size_t i = 0; i < len; i++) { - if (source[pos + 2 + i] == '1') { - value |= static_cast<uint64_t>(1) << static_cast<uint64_t>(len - i - 1); - } - } - - const size_t cut_len = 2 + len + (source[pos + 2 + len] == 'u'? 1 : 0); - - source = source.replace(pos, cut_len, std::to_string(value)); - } - - return source; - } - - std::string HLSLCompiler::processShaderSource(const std::string &shaderSource) { - std::string source = Compiler::processShaderSource(shaderSource); - source = fixShaderSource(source); // TODO: do it properly! - return shaderSource; - } - bool HLSLCompiler::compileSource(ShaderStage shaderStage, const std::string& shaderSource, const ShaderCompiledFunction &compiled, @@ -203,7 +162,7 @@ namespace vkcv::shader { vkcv_log(LogLevel::ERROR, "Shader stage not supported"); return false; } - + glslang::TShader shader (language); shader.setEntryPoint("main"); @@ -259,7 +218,7 @@ namespace vkcv::shader { EShMsgVulkanRules | EShMsgReadHlsl | EShMsgHlslOffsets | - //EShMsgHlslEnable16BitTypes | // TODO: not supported yet + EShMsgHlslEnable16BitTypes | EShMsgHlslLegalization | EShMsgHlslDX9Compatible ); -- GitLab