summaryrefslogtreecommitdiffstats
path: root/Graphics/GLSLTools
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-05-22 23:19:39 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-05-22 23:19:39 +0000
commit8151bc6df37372eb91011edede9ffbb258ebeab6 (patch)
treec26b3f1cb425ff5069b04c02b8e36b106bea4549 /Graphics/GLSLTools
parentRemoved workarounds for GS, HS and DS in Vulkan tests (diff)
downloadDiligentCore-8151bc6df37372eb91011edede9ffbb258ebeab6.tar.gz
DiligentCore-8151bc6df37372eb91011edede9ffbb258ebeab6.zip
Unified VULKAN shader define in VK and GL backends
Diffstat (limited to 'Graphics/GLSLTools')
-rw-r--r--Graphics/GLSLTools/include/SPIRVUtils.hpp10
-rw-r--r--Graphics/GLSLTools/src/SPIRVUtils.cpp10
2 files changed, 15 insertions, 5 deletions
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<unsigned int> GLSLtoSPIRV(SHADER_TYPE ShaderType, const char* ShaderSource, int SourceCodeLen, IDataBlob** ppCompilerOutput);
-std::vector<unsigned int> HLSLtoSPIRV(const ShaderCreateInfo& Attribs, IDataBlob** ppCompilerOutput);
+std::vector<unsigned int> GLSLtoSPIRV(SHADER_TYPE ShaderType,
+ const char* ShaderSource,
+ int SourceCodeLen,
+ IDataBlob** ppCompilerOutput);
+
+std::vector<unsigned int> 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<IncludeResult*, RefCntAutoPtr<IDataBlob>> m_DataBlobs;
};
-std::vector<unsigned int> HLSLtoSPIRV(const ShaderCreateInfo& Attribs, IDataBlob** ppCompilerOutput)
+std::vector<unsigned int> 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<unsigned int> 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)