From d939773a9127bccbbd22903eb5b5620ad7127d37 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 15 Apr 2022 15:46:45 -0400 Subject: DXIL library support and Artifact type (#2186) * #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. --- source/slang/slang-compiler.cpp | 54 ++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'source/slang/slang-compiler.cpp') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 1b20a869d..80899e69e 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1193,24 +1193,46 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val) // Disable exceptions and security checks options.flags &= ~(CompileOptions::Flag::EnableExceptionHandling | CompileOptions::Flag::EnableSecurityChecks); + Profile profile; + if (compilerType == PassThroughMode::Fxc || compilerType == PassThroughMode::Dxc || compilerType == PassThroughMode::Glslang) { - auto entryPointIndex = getSingleEntryPointIndex(); + const auto entryPointIndices = getEntryPointIndices(); + auto targetReq = getTargetReq(); - auto entryPoint = getEntryPoint(entryPointIndex); - auto profile = getEffectiveProfile(entryPoint, getTargetReq()); + const auto entryPointIndicesCount = entryPointIndices.getCount(); + + if (entryPointIndicesCount == 0 && compilerType == PassThroughMode::Dxc) + { + // Can support no entry points on DXC because we can build libraries + profile = targetReq->getTargetProfile(); + } + else if (entryPointIndicesCount == 1) + { + // All support a single entry point + const Index entryPointIndex = entryPointIndices[0]; - options.stage = SlangStage(profile.getStage()); + auto entryPoint = getEntryPoint(entryPointIndex); + profile = getEffectiveProfile(entryPoint, targetReq); - // Set the entry point name - options.entryPointName = getText(entryPoint->getName()); - auto entryPointNameOverride = getProgram()->getEntryPointNameOverride(entryPointIndex); - if (entryPointNameOverride.getLength() != 0) + options.entryPointName = getText(entryPoint->getName()); + auto entryPointNameOverride = getProgram()->getEntryPointNameOverride(entryPointIndex); + if (entryPointNameOverride.getLength() != 0) + { + options.entryPointName = entryPointNameOverride; + } + } + else { - options.entryPointName = entryPointNameOverride; + // We only support a single entry point on this target + SLANG_ASSERT(!"Can only compile with a single entry point on this target"); + return SLANG_FAIL; } + + options.stage = SlangStage(profile.getStage()); + if (compilerType == PassThroughMode::Dxc) { // We will enable the flag to generate proper code for 16 - bit types @@ -1229,20 +1251,12 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val) options.flags |= CompileOptions::Flag::EnableFloat16; } - // Only set the profile if the stage is set - if (options.stage != SLANG_STAGE_NONE) - { - options.profileName = GetHLSLProfileName(profile); - } - // Set the matrix layout options.matrixLayout = getTargetReq()->getDefaultMatrixLayoutMode(); } - else if (compilerType == PassThroughMode::Fxc) - { - // Set the profile - options.profileName = GetHLSLProfileName(profile); - } + + // Set the profile + options.profileName = GetHLSLProfileName(profile); } // If we aren't using LLVM 'host callable', we want downstream compile to produce a shared library -- cgit v1.2.3