From f48035ff26381d8bc22a7e484eda53fc087ae7b7 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 13 Jul 2017 08:31:18 -0700 Subject: 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 --- source/slang/emit.cpp | 18 ++++++++++++++---- 1 file 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; -- cgit v1.2.3