From 0e220da96b819f3a31635689f78ad20bd9a36d0b Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 10 Jul 2017 08:34:52 -0700 Subject: More cross-compilation fixes - Add GLSL mappings for more `Texture*` methods - The annoying one here is `Texture*.Load()` because it doesn't take a sampler, but the GLSL equivalent needs one (while the SPIR-V does *not*). I've hacked this pretty seriously for now. - Try to ensure that we add `uniform` to global declarations that need it in GLSL - When outputting an `in` or `out` variable that might have been created from an `inout` shader parameter, filter the layout qualifiers that we output to only cover the appropriate resource kind. --- source/slang/lower.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/slang/lower.cpp') diff --git a/source/slang/lower.cpp b/source/slang/lower.cpp index 6c54d18b6..023c63591 100644 --- a/source/slang/lower.cpp +++ b/source/slang/lower.cpp @@ -194,6 +194,8 @@ public: struct SharedLoweringContext { + CompileRequest* compileRequest; + ProgramLayout* programLayout; // The target we are going to generate code for. @@ -1372,6 +1374,23 @@ struct LoweringVisitor return loweredDecl; } + SourceLanguage getSourceLanguage(ProgramSyntaxNode* moduleDecl) + { + for (auto translationUnit : shared->compileRequest->translationUnits) + { + if (moduleDecl == translationUnit->SyntaxNode) + return translationUnit->sourceLanguage; + } + + for (auto loadedModuleDecl : shared->compileRequest->loadedModulesList) + { + if (moduleDecl == loadedModuleDecl) + return SourceLanguage::Slang; + } + + return SourceLanguage::Unknown; + } + RefPtr visitVariable( Variable* decl) { @@ -2022,6 +2041,7 @@ LoweredEntryPoint lowerEntryPoint( CodeGenTarget target) { SharedLoweringContext sharedContext; + sharedContext.compileRequest = entryPoint->compileRequest; sharedContext.programLayout = programLayout; sharedContext.target = target; -- cgit v1.2.3