From 8151bc6df37372eb91011edede9ffbb258ebeab6 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 22 May 2020 16:19:39 -0700 Subject: Unified VULKAN shader define in VK and GL backends --- Graphics/GLSLTools/include/SPIRVUtils.hpp | 10 ++++++++-- Graphics/GLSLTools/src/SPIRVUtils.cpp | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'Graphics/GLSLTools') diff --git a/Graphics/GLSLTools/include/SPIRVUtils.hpp b/Graphics/GLSLTools/include/SPIRVUtils.hpp index 50889f17..50025303 100644 --- a/Graphics/GLSLTools/include/SPIRVUtils.hpp +++ b/Graphics/GLSLTools/include/SPIRVUtils.hpp @@ -37,7 +37,13 @@ namespace Diligent void InitializeGlslang(); void FinalizeGlslang(); -std::vector GLSLtoSPIRV(SHADER_TYPE ShaderType, const char* ShaderSource, int SourceCodeLen, IDataBlob** ppCompilerOutput); -std::vector HLSLtoSPIRV(const ShaderCreateInfo& Attribs, IDataBlob** ppCompilerOutput); +std::vector GLSLtoSPIRV(SHADER_TYPE ShaderType, + const char* ShaderSource, + int SourceCodeLen, + IDataBlob** ppCompilerOutput); + +std::vector HLSLtoSPIRV(const ShaderCreateInfo& Attribs, + const char* ExtraDefinitions, + IDataBlob** ppCompilerOutput); } // namespace Diligent \ No newline at end of file diff --git a/Graphics/GLSLTools/src/SPIRVUtils.cpp b/Graphics/GLSLTools/src/SPIRVUtils.cpp index 4da444e4..e02bc34e 100644 --- a/Graphics/GLSLTools/src/SPIRVUtils.cpp +++ b/Graphics/GLSLTools/src/SPIRVUtils.cpp @@ -85,7 +85,7 @@ EShLanguage ShaderTypeToShLanguage(SHADER_TYPE ShaderType) } } -TBuiltInResource InitResources() +static TBuiltInResource InitResources() { TBuiltInResource Resources; @@ -435,7 +435,9 @@ private: std::unordered_map> m_DataBlobs; }; -std::vector HLSLtoSPIRV(const ShaderCreateInfo& Attribs, IDataBlob** ppCompilerOutput) +std::vector HLSLtoSPIRV(const ShaderCreateInfo& Attribs, + const char* ExtraDefinitions, + IDataBlob** ppCompilerOutput) { EShLanguage ShLang = ShaderTypeToShLanguage(Attribs.Desc.ShaderType); glslang::TShader Shader{ShLang}; @@ -476,9 +478,11 @@ std::vector HLSLtoSPIRV(const ShaderCreateInfo& Attribs, IDataBlob if (const auto* ShaderTypeDefine = GetShaderTypeDefines(Attribs.Desc.ShaderType)) Defines += ShaderTypeDefine; + if (ExtraDefinitions != nullptr) + Defines += ExtraDefinitions; + if (Attribs.Macros != nullptr) { - Defines = g_HLSLDefinitions; Defines += '\n'; auto* pMacro = Attribs.Macros; while (pMacro->Name != nullptr && pMacro->Definition != nullptr) -- cgit v1.2.3