From b985b1bdada76b02b51b4f2ea3cbd985c9b8a210 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 6 Jan 2023 17:20:42 -0500 Subject: Fix small issue around emitInterpolationModifiersImpl when layout is nullptr. (#2583) * #include an absolute path didn't work - because paths were taken to always be relative. * Fix output when layout is nullptr in emitInterpolatioModifiersImpl --- source/slang/slang-emit-glsl.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index e3bd771df..b1b92e7e7 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -2262,8 +2262,14 @@ void GLSLSourceEmitter::emitInterpolationModifiersImpl(IRInst* varInst, IRType* { bool anyModifiers = false; - auto stage = layout->getStage(); - auto isInput = layout->findOffsetAttr(LayoutResourceKind::VaryingInput) != nullptr; + Stage stage = Stage::Unknown; + bool isInput = false; + + if (layout) + { + stage = layout->getStage(); + isInput = layout->findOffsetAttr(LayoutResourceKind::VaryingInput) != nullptr; + } for (auto dd : varInst->getDecorations()) { @@ -2314,7 +2320,8 @@ void GLSLSourceEmitter::emitInterpolationModifiersImpl(IRInst* varInst, IRType* // output everything with `flat` except for // fragment *outputs* (and maybe vertex inputs). // - if (layout && layout->getStage() == Stage::Fragment + if (layout + && layout->getStage() == Stage::Fragment && layout->usesResourceKind(LayoutResourceKind::VaryingInput)) { _maybeEmitGLSLFlatModifier(valueType); -- cgit v1.2.3