diff options
Diffstat (limited to 'source/slang/slang-emit-hlsl.cpp')
| -rw-r--r-- | source/slang/slang-emit-hlsl.cpp | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 650012b9f..945f00499 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -727,28 +727,40 @@ void HLSLSourceEmitter::emitLoopControlDecorationImpl(IRLoopControlDecoration* d } } -void HLSLSourceEmitter::emitFuncDecorationImpl(IRDecoration* decoration) +static bool _canEmitExport(const Profile& profile) { - switch( decoration->getOp() ) - { - case kIROp_PublicDecoration: + const auto family = profile.getFamily(); + const auto version = profile.getVersion(); + // Is ita late enough version of shader model to output with 'export' + return (family == ProfileFamily::DX && version >= ProfileVersion::DX_6_1); +} + +/* virtual */void HLSLSourceEmitter::emitFuncDecorationsImpl(IRFunc* func) +{ + // Specially handle export, as we don't want to emit it multiple times + if (getTargetReq()->isWholeProgramRequest() && + _canEmitExport(m_effectiveProfile)) { - auto profile = m_effectiveProfile; - - const auto family = profile.getFamily(); - const auto version = profile.getVersion(); - - // If it's whole program and it's for a late enough version of shader model - // output with 'export' - if (getTargetReq()->isWholeProgramRequest() && - family == ProfileFamily::DX && - version >= ProfileVersion::DX_6_1) + for (auto decoration : func->getDecorations()) { - m_writer->emit("export\n"); + const auto op = decoration->getOp(); + if (op == kIROp_PublicDecoration || + op == kIROp_HLSLExportDecoration) + { + m_writer->emit("export\n"); + break; + } } - break; } - + + // Use the default for others + Super::emitFuncDecorationsImpl(func); +} + +void HLSLSourceEmitter::emitFuncDecorationImpl(IRDecoration* decoration) +{ + switch( decoration->getOp() ) + { case kIROp_NoInlineDecoration: m_writer->emit("[noinline]\n"); break; |
