From c031e3f4c52c7efca7135ba406dc8163fe0c6c97 Mon Sep 17 00:00:00 2001 From: markus Date: Wed, 12 Aug 2020 22:20:36 +0200 Subject: [PATCH 1/2] Solve std140 layout violations by adding the fvk-use-gl-layout option for Dxcompiler when targeting GLSL or ESSL --- Source/Core/ShaderConductor.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/Core/ShaderConductor.cpp b/Source/Core/ShaderConductor.cpp index 247547a6..da27edaf 100644 --- a/Source/Core/ShaderConductor.cpp +++ b/Source/Core/ShaderConductor.cpp @@ -396,7 +396,7 @@ namespace } Compiler::ResultDesc CompileToBinary(const Compiler::SourceDesc& source, const Compiler::Options& options, - ShadingLanguage targetLanguage, bool asModule) + ShadingLanguage targetLanguage, bool asModule, bool glFriendlyLayout) { assert((targetLanguage == ShadingLanguage::Dxil) || (targetLanguage == ShadingLanguage::SpirV)); @@ -550,6 +550,9 @@ namespace llvm_unreachable("Invalid shading language."); } + if (glFriendlyLayout) + dxcArgStrings.push_back(L"-fvk-use-gl-layout"); + std::vector dxcArgs; dxcArgs.reserve(dxcArgStrings.size()); for (const auto& arg : dxcArgStrings) @@ -898,6 +901,7 @@ namespace ShaderConductor bool hasDxil = false; bool hasDxilModule = false; bool hasSpirV = false; + bool hasGL = false; for (uint32_t i = 0; i < numTargets; ++i) { if (targets[i].language == ShadingLanguage::Dxil) @@ -912,24 +916,27 @@ namespace ShaderConductor { hasSpirV = true; } + + if (targets[i].language == ShadingLanguage::Glsl || targets[i].language == ShadingLanguage::Essl) + hasGL = true; } ResultDesc dxilBinaryResult{}; if (hasDxil) { - dxilBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, false); + dxilBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, false, false); } ResultDesc dxilModuleBinaryResult{}; if (hasDxilModule) { - dxilModuleBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, true); + dxilModuleBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::Dxil, true, false); } ResultDesc spirvBinaryResult{}; if (hasSpirV) { - spirvBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::SpirV, false); + spirvBinaryResult = CompileToBinary(sourceOverride, options, ShadingLanguage::SpirV, false, hasGL); } for (uint32_t i = 0; i < numTargets; ++i) From d32de512f57cdb2689314f1d5eb25992e4a338f7 Mon Sep 17 00:00:00 2001 From: markus Date: Thu, 24 Sep 2020 13:20:51 +0200 Subject: [PATCH 2/2] Add curly braces for single statement if-blocks. --- Source/Core/ShaderConductor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/ShaderConductor.cpp b/Source/Core/ShaderConductor.cpp index da27edaf..7b851453 100644 --- a/Source/Core/ShaderConductor.cpp +++ b/Source/Core/ShaderConductor.cpp @@ -551,7 +551,9 @@ namespace } if (glFriendlyLayout) - dxcArgStrings.push_back(L"-fvk-use-gl-layout"); + { + dxcArgStrings.push_back(L"-fvk-use-gl-layout"); + } std::vector dxcArgs; dxcArgs.reserve(dxcArgStrings.size()); @@ -918,7 +920,9 @@ namespace ShaderConductor } if (targets[i].language == ShadingLanguage::Glsl || targets[i].language == ShadingLanguage::Essl) + { hasGL = true; + } } ResultDesc dxilBinaryResult{};