From 3638e7735be67c8f4dae3f4544134441aa1e029d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 21 Apr 2022 13:47:18 -0400 Subject: `export` support in HLSL (#2188) * #include an absolute path didn't work - because paths were taken to always be relative. * Compile to a dxil library. * Added CompileProduct. * Support handling of ModuleLibrary. * CacheBehavior -> Cache * Use CompileProduct for -r references. * CompileProduct -> Artifact. * Determining an artifact type on binding. * Determine binary linkability. * Added Artifact::exists. * Added ArtifactKeep. * Small fixes. * Small improvements to Artifact. * Add zip extension. * Fix some comments. * Fix multiple adding of PublicDecoration. Make public output export for DXIL/lib. Add checking for simpleDecorations such that only added once. * Use 'whole program' to identify library build. * Add -target dxil so test infrastructure knows it needs DXC. --- source/slang/slang-emit-hlsl.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/slang/slang-emit-hlsl.cpp') diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 09749546a..059a3f641 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -731,6 +731,28 @@ void HLSLSourceEmitter::emitFuncDecorationImpl(IRDecoration* decoration) { switch( decoration->getOp() ) { + case kIROp_PublicDecoration: + { + auto profile = m_effectiveProfile; + + const auto family = profile.getFamily(); + const auto stage = profile.getStage(); + const auto version = profile.getVersion(); + + // I would perhaps ideally know that this was being compiled for 'library' stage. + // Stage::Unknown is currently also used for lib profiles. + + // TODO(JS): Potentially can do export for fxc too, but for now we don't add. + + if (family == ProfileFamily::DX && + version >= ProfileVersion::DX_6_1 && + stage == Stage::Unknown) + { + m_writer->emit("export\n"); + } + break; + } + case kIROp_NoInlineDecoration: m_writer->emit("[noinline]\n"); break; -- cgit v1.2.3