diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-17 10:51:18 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-17 10:54:05 -0700 |
| commit | dc0e9d7bca21d8a67ec9f044c0d390bda6ebfcbf (patch) | |
| tree | 2db423b4b6e8420e614cb49fe7534f2b7591078d /source/slang/emit.cpp | |
| parent | 0b4992fb69e359a7e566cca42331a196904556f5 (diff) | |
Pick correct GLSL version when `gl_Layer` used
`gl_Layer` as a fragment input requires at least version 4.30 of GLSL, so we try to track that information when we see the name used.
Note that this does *not* override a user-specified `#version` line.
This required re-ordering when lowering happens relative to emitting the `#version` directive, since this code works by actually modifying the chosen profile for the entry point.
Yes, that is kind of gross and we should do something cleaner in the long term.
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 8c6a46196..0eb371b88 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -3604,6 +3604,13 @@ String emitEntryPoint( auto translationUnitSyntax = translationUnit->SyntaxNode.Ptr(); + // We perform lowering of the program before emitting *anything*, + // because the lowering process might change how we emit some + // boilerplate at the start of the ouput for GLSL (e.g., what + // version we require). + auto lowered = lowerEntryPoint(entryPoint, programLayout, target); + sharedContext.program = lowered.program; + // There may be global-scope modifiers that we should emit now visitor.emitGLSLPreprocessorDirectives(translationUnitSyntax); @@ -3624,9 +3631,6 @@ String emitEntryPoint( break; } - auto lowered = lowerEntryPoint(entryPoint, programLayout, target); - - sharedContext.program = lowered.program; visitor.EmitDeclsInContainer(lowered.program.Ptr()); |
