summaryrefslogtreecommitdiffstats
path: root/source/slang/emit.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-13 08:31:18 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-13 08:31:18 -0700
commitf48035ff26381d8bc22a7e484eda53fc087ae7b7 (patch)
tree386850410dd54db47ed61188cbfb5ce882653c7a /source/slang/emit.cpp
parentc2fca572d76160c7211a33b781335e649611b1d2 (diff)
Don't emit C-style `#line` directives when directly generating GLSL
- This fixes the render tests, which aren't tested by the continuous integration setup - This was broken in the commit that decided to use C-style directives all the time. - This works for stuff that eventually passes through glslang (or at least our build of it) - It *doensn't* work if we take the GLSL and pass it off to an OpenGL driver (which is what I do for testing) - A longer-term fix is still required to deal with line directives properly
Diffstat (limited to 'source/slang/emit.cpp')
-rw-r--r--source/slang/emit.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 6905a8a76..68c84a277 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -21,6 +21,11 @@ struct SharedEmitContext
// The target language we want to generate code for
CodeGenTarget target;
+ // The final code generation target
+ //
+ // For example, `target` might be `GLSL`, while `finalTarget` might be `SPIRV`
+ CodeGenTarget finalTarget;
+
// The string of code we've built so far
StringBuilder sb;
@@ -456,13 +461,17 @@ struct EmitVisitor
bool shouldUseGLSLStyleLineDirective = false;
- // Let's not do this
-#if 0
- if (context->shared->target == CodeGenTarget::GLSL)
+ // TODO: Eventually we should give he user a proper API
+ // and command-line mechanism to control what kind of line
+ // directives we output (and to turn the feature off
+ // completely), but for now we always emit C-style line
+ // directives *unless* the final target language is raw
+ // GLSL code (all other targets will eventually pass
+ // through glslang, which supports C-style line directives).
+ if (context->shared->finalTarget == CodeGenTarget::GLSL)
{
shouldUseGLSLStyleLineDirective = true;
}
-#endif
if(shouldUseGLSLStyleLineDirective)
{
@@ -3479,6 +3488,7 @@ String emitEntryPoint(
SharedEmitContext sharedContext;
sharedContext.target = target;
+ sharedContext.finalTarget = entryPoint->compileRequest->Target;
sharedContext.programLayout = programLayout;