diff options
| author | Dietrich Geisler <dag368@cornell.edu> | 2020-07-20 14:53:23 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-20 11:53:23 -0700 |
| commit | 115920406ebd747e02e1e6a8e4595f7d88eef0d9 (patch) | |
| tree | a230b6358b35569da5f588d733643198ff38293f /source/slang/slang-emit.cpp | |
| parent | 975c5db3f0a71bc93369a321318e7d3b43001ff5 (diff) | |
Multiple Entry Point Backend (#1437)
* Multiple Entry Point Backend
This PR introduces changes to the IR linking, emitting, and options for
multiple entry points. Specifically, this PR updates several locations
to support a (potentially empty) list of entry points, adding list infrastructure and looping over entry points as appropriate.
* Formatting change
* Updated unknown target case to not require an entry point
* Formatting and list consts updates
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit.cpp')
| -rw-r--r-- | source/slang/slang-emit.cpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 63bf8f054..72b2e07c5 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -165,7 +165,6 @@ struct LinkingAndOptimizationOptions CLikeSourceEmitter* sourceEmitter = nullptr; }; -// TODO(DG): A bit tricky; this needs to be generalized to multiple entry points Result linkAndOptimizeIR( BackEndCompileRequest* compileRequest, const List<Int>& entryPointIndices, @@ -194,7 +193,7 @@ Result linkAndOptimizeIR( target, targetProgram); auto irModule = outLinkedIR.module; - auto irEntryPoint = outLinkedIR.entryPoint; + auto irEntryPoints = outLinkedIR.entryPoints; #if 0 dumpIRIfEnabled(compileRequest, irModule, "LINKED"); @@ -341,8 +340,7 @@ Result linkAndOptimizeIR( } // TODO(DG): There are multiple DCE steps here, which need to be changed - // CHECK: how to these modules work? - // so that they don't just throw out any non-entry point code + // so that they don't just throw out any non-entry point code // Debugging code for IR transformations... #if 0 dumpIRIfEnabled(compileRequest, irModule, "SPECIALIZED"); @@ -611,10 +609,10 @@ Result linkAndOptimizeIR( { auto glslExtensionTracker = as<GLSLExtensionTracker>(options.sourceEmitter->getExtensionTracker()); - legalizeEntryPointForGLSL( + legalizeEntryPointsForGLSL( session, irModule, - irEntryPoint, + irEntryPoints, compileRequest->getSink(), glslExtensionTracker); @@ -692,8 +690,7 @@ Result linkAndOptimizeIR( return SLANG_OK; } -// TODO(DG): This probably needs to be generalized to a list -SlangResult emitEntryPointSourceFromIR( +SlangResult emitEntryPointsSourceFromIR( BackEndCompileRequest* compileRequest, const List<Int>& entryPointIndices, CodeGenTarget target, @@ -705,10 +702,6 @@ SlangResult emitEntryPointSourceFromIR( auto sink = compileRequest->getSink(); auto program = compileRequest->getProgram(); - // Temporary assertion for checkpoint - SLANG_ASSERT(entryPointIndices.getCount() == 1); - auto entryPoint = program->getEntryPoint(entryPointIndices[0]); - auto lineDirectiveMode = compileRequest->getLineDirectiveMode(); // To try to make the default behavior reasonable, we will // always use C-style line directives (to give the user @@ -728,8 +721,12 @@ SlangResult emitEntryPointSourceFromIR( desc.compileRequest = compileRequest; desc.target = target; // TODO(DG): Can't assume a single entry point stage for multiple entry points - desc.entryPointStage = entryPoint->getStage(); - desc.effectiveProfile = getEffectiveProfile(entryPoint, targetRequest); + if (entryPointIndices.getCount() == 1) + { + auto entryPoint = program->getEntryPoint(entryPointIndices[0]); + desc.entryPointStage = entryPoint->getStage(); + desc.effectiveProfile = getEffectiveProfile(entryPoint, targetRequest); + } desc.sourceWriter = &sourceWriter; // Define here, because must be in scope longer than the sourceEmitter, as sourceEmitter might reference @@ -857,7 +854,7 @@ SlangResult emitEntryPointSourceFromIR( SlangResult emitSPIRVFromIR( BackEndCompileRequest* compileRequest, IRModule* irModule, - IRFunc* irEntryPoint, + const List<IRFunc*>& irEntryPoints, List<uint8_t>& spirvOut); SlangResult emitSPIRVForEntryPointsDirectly( @@ -866,8 +863,6 @@ SlangResult emitSPIRVForEntryPointsDirectly( TargetRequest* targetRequest, List<uint8_t>& spirvOut) { - // TODO(DG): Temporary assertion for checkpoint - SLANG_ASSERT(entryPointIndices.getCount() == 1); auto sink = compileRequest->getSink(); auto program = compileRequest->getProgram(); auto targetProgram = program->getTargetProgram(targetRequest); @@ -887,12 +882,12 @@ SlangResult emitSPIRVForEntryPointsDirectly( linkedIR); auto irModule = linkedIR.module; - auto irEntryPoint = linkedIR.entryPoint; + auto irEntryPoints = linkedIR.entryPoints; emitSPIRVFromIR( compileRequest, irModule, - irEntryPoint, + irEntryPoints, spirvOut); return SLANG_OK; |
