From 7a747df0aa4ad55c50ef89d8a9d3e5e8a4b741e3 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 26 Oct 2018 21:49:58 -0700 Subject: Updated glslang + improved glslang messages for HLSL --- Graphics/GLSLTools/src/SPIRVUtils.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GLSLTools/src/SPIRVUtils.cpp b/Graphics/GLSLTools/src/SPIRVUtils.cpp index 380aaf9d..c743fdfa 100644 --- a/Graphics/GLSLTools/src/SPIRVUtils.cpp +++ b/Graphics/GLSLTools/src/SPIRVUtils.cpp @@ -417,7 +417,7 @@ std::vector HLSLtoSPIRV(const ShaderCreationAttribs& Attribs, IDat glslang::TShader Shader(ShLang); TBuiltInResource Resources = InitResources(); - EShMessages messages = (EShMessages)(EShMsgReadHlsl | EShMsgHlslLegalization); + EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules | EShMsgReadHlsl | EShMsgHlslLegalization); VERIFY_EXPR(Attribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL); @@ -451,12 +451,13 @@ std::vector HLSLtoSPIRV(const ShaderCreationAttribs& Attribs, IDat int NumShaderStrings = 0; constexpr size_t MaxShaderStrings = 3; - std::array ShaderStrings; - std::array ShaderStringLenghts; + std::array ShaderStrings = {}; + std::array ShaderStringLenghts = {}; + std::array Names = {}; - std::string HLSLDefinitions(g_HLSLDefinitions); - ShaderStrings [NumShaderStrings] = HLSLDefinitions.c_str(); - ShaderStringLenghts[NumShaderStrings] = static_cast(HLSLDefinitions.length()); + ShaderStrings [NumShaderStrings] = g_HLSLDefinitions; + ShaderStringLenghts[NumShaderStrings] = static_cast(strlen(g_HLSLDefinitions)); + Names [NumShaderStrings] = "HLSL Definitions"; ++NumShaderStrings; std::string Defines; @@ -474,12 +475,14 @@ std::vector HLSLtoSPIRV(const ShaderCreationAttribs& Attribs, IDat } ShaderStrings [NumShaderStrings] = Defines.c_str(); ShaderStringLenghts[NumShaderStrings] = static_cast(Defines.length()); + Names [NumShaderStrings] = "Macros"; ++NumShaderStrings; } ShaderStrings [NumShaderStrings] = SourceCode; ShaderStringLenghts[NumShaderStrings] = SourceCodeLen; + Names [NumShaderStrings] = Attribs.FilePath != nullptr ? Attribs.FilePath : ""; ++NumShaderStrings; - Shader.setStringsWithLengths(ShaderStrings.data(), ShaderStringLenghts.data(), NumShaderStrings); + Shader.setStringsWithLengthsAndNames(ShaderStrings.data(), ShaderStringLenghts.data(), Names.data(), NumShaderStrings); IncluderImpl Includer(Attribs.pShaderSourceStreamFactory); return CompileShaderInternal(Shader, messages, &Includer, SourceCode, SourceCodeLen, ppCompilerOutput); @@ -490,7 +493,6 @@ std::vector GLSLtoSPIRV(const SHADER_TYPE ShaderType, const char* EShLanguage ShLang = ShaderTypeToShLanguage(ShaderType); glslang::TShader Shader(ShLang); - // Enable SPIR-V and Vulkan rules when parsing GLSL EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules); const char* ShaderStrings[] = {ShaderSource }; -- cgit v1.2.3