summaryrefslogtreecommitdiff
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp59
1 files changed, 53 insertions, 6 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 912e42572..1ef17df1d 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -762,6 +762,11 @@ namespace Slang
# pragma warning(pop)
#endif
+ SlangResult CodeGenContext::emitTranslationUnit(ComPtr<IArtifact>& outArtifact)
+ {
+ return emitWithDownstreamForEntryPoints(outArtifact);
+ }
+
String GetHLSLProfileName(Profile profile)
{
switch( profile.getFamily() )
@@ -1084,6 +1089,23 @@ namespace Slang
return SLANG_OK;
}
+ bool CodeGenContext::isPrecompiled()
+ {
+ auto program = getProgram();
+
+ bool allPrecompiled = true;
+ program->enumerateIRModules([&](IRModule* irModule)
+ {
+ // TODO: Conditionalize this on target
+ if (!irModule->precompiledDXIL)
+ {
+ allPrecompiled = false;
+ }
+ });
+
+ return allPrecompiled;
+ }
+
SlangResult CodeGenContext::emitWithDownstreamForEntryPoints(ComPtr<IArtifact>& outArtifact)
{
outArtifact.setNull();
@@ -1245,12 +1267,15 @@ namespace Slang
}
else
{
- CodeGenContext sourceCodeGenContext(this, sourceTarget, extensionTracker);
+ if (!isPrecompiled())
+ {
+ CodeGenContext sourceCodeGenContext(this, sourceTarget, extensionTracker);
- SLANG_RETURN_ON_FAIL(sourceCodeGenContext.emitEntryPointsSource(sourceArtifact));
- sourceCodeGenContext.maybeDumpIntermediate(sourceArtifact);
+ SLANG_RETURN_ON_FAIL(sourceCodeGenContext.emitEntryPointsSource(sourceArtifact));
+ sourceCodeGenContext.maybeDumpIntermediate(sourceArtifact);
- sourceLanguage = (SourceLanguage)TypeConvertUtil::getSourceLanguageFromTarget((SlangCompileTarget)sourceTarget);
+ sourceLanguage = (SourceLanguage)TypeConvertUtil::getSourceLanguageFromTarget((SlangCompileTarget)sourceTarget);
+ }
}
if (sourceArtifact)
@@ -1541,6 +1566,25 @@ namespace Slang
libraries.addRange(linkage->m_libModules.getBuffer(), linkage->m_libModules.getCount());
}
+ if (isPrecompiled())
+ {
+ auto program = getProgram();
+ program->enumerateIRModules([&](IRModule* irModule)
+ {
+ // TODO: conditionalize on target
+ if (irModule->precompiledDXIL)
+ {
+ ArtifactDesc desc = ArtifactDescUtil::makeDescForCompileTarget(SLANG_DXIL);
+ desc.kind = ArtifactKind::Library;
+
+ auto library = ArtifactUtil::createArtifact(desc);
+
+ library->addRepresentationUnknown(irModule->precompiledDXIL);
+ libraries.add(library);
+ }
+ });
+ }
+
options.compilerSpecificArguments = allocator.allocate(compilerSpecificArguments);
options.requiredCapabilityVersions = SliceUtil::asSlice(requiredCapabilityVersions);
options.libraries = SliceUtil::asSlice(libraries);
@@ -1991,7 +2035,10 @@ namespace Slang
{
if (auto artifact = targetProgram->getExistingWholeProgramResult())
{
- artifacts.add(ComPtr<IArtifact>(artifact));
+ if (!targetProgram->getOptionSet().getBoolOption(CompilerOptionName::EmbedDXIL))
+ {
+ artifacts.add(ComPtr<IArtifact>(artifact));
+ }
}
}
else
@@ -2251,7 +2298,7 @@ namespace Slang
void EndToEndCompileRequest::generateOutput()
{
generateOutput(getSpecializedGlobalAndEntryPointsComponentType());
-
+
// If we are in command-line mode, we might be expected to actually
// write output to one or more files here.