diff options
Diffstat (limited to 'source/slang/slang-compiler.cpp')
| -rw-r--r-- | source/slang/slang-compiler.cpp | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 428532658..a5a09204b 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -350,7 +350,7 @@ namespace Slang Profile Profile::lookUp(UnownedStringSlice const& name) { #define PROFILE(TAG, NAME, STAGE, VERSION) if(name == UnownedTerminatedStringSlice(#NAME)) return Profile::TAG; - #define PROFILE_ALIAS(TAG, DEF, NAME) if(name == UnownedTerminatedStringSlice(#NAME)) return Profile::TAG; + #define PROFILE_ALIAS(TAG, DEF, NAME) if(name == UnownedTerminatedStringSlice(#NAME)) return Profile::TAG; #include "slang-profile-defs.h" return Profile::Unknown; @@ -767,7 +767,7 @@ namespace Slang # pragma warning(pop) #endif - SlangResult CodeGenContext::emitTranslationUnit(ComPtr<IArtifact>& outArtifact) + SlangResult CodeGenContext::emitPrecompiledDXIL(ComPtr<IArtifact>& outArtifact) { return emitWithDownstreamForEntryPoints(outArtifact); } @@ -1094,23 +1094,6 @@ 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(); @@ -1272,15 +1255,17 @@ namespace Slang } else { - if (!isPrecompiled()) + CodeGenContext sourceCodeGenContext(this, sourceTarget, extensionTracker); + + if (target == CodeGenTarget::DXILAssembly || target == CodeGenTarget::DXIL) { - CodeGenContext sourceCodeGenContext(this, sourceTarget, extensionTracker); + sourceCodeGenContext.removeAvailableInDXIL = true; + } - 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) @@ -1571,24 +1556,29 @@ namespace Slang libraries.addRange(linkage->m_libModules.getBuffer(), linkage->m_libModules.getCount()); } - if (isPrecompiled()) + auto program = getProgram(); + + // Load embedded precompiled libraries from IR into library artifacts + program->enumerateIRModules([&](IRModule* irModule) { - auto program = getProgram(); - program->enumerateIRModules([&](IRModule* irModule) + for (auto inst : irModule->getModuleInst()->getChildren()) + { + if (target == CodeGenTarget::DXILAssembly || target == CodeGenTarget::DXIL) { - // TODO: conditionalize on target - if (irModule->precompiledDXIL) + if (inst->getOp() == kIROp_EmbeddedDXIL) { + auto slice = static_cast<IRBlobLit*>(inst->getOperand(0))->getStringSlice(); ArtifactDesc desc = ArtifactDescUtil::makeDescForCompileTarget(SLANG_DXIL); desc.kind = ArtifactKind::Library; auto library = ArtifactUtil::createArtifact(desc); - library->addRepresentationUnknown(irModule->precompiledDXIL); + library->addRepresentationUnknown(StringBlob::create(slice)); libraries.add(library); } - }); - } + } + } + }); options.compilerSpecificArguments = allocator.allocate(compilerSpecificArguments); options.requiredCapabilityVersions = SliceUtil::asSlice(requiredCapabilityVersions); |
