From 5c153295205d2d5d6340f3d569a550f4697946c5 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 1 Jul 2020 14:20:42 -0400 Subject: Fix bug in slang-dxc-support where it didn't get the source path correctly (#1420) * Fix handling of UniformState from #1396 * * Fix bug in slang-dxc-support where it didn't get the source path correctly * Make entryPointIndices const List& --- source/slang/slang-compiler.cpp | 35 +++++++++++++++++++---------------- source/slang/slang-compiler.h | 8 ++++---- source/slang/slang-dxc-support.cpp | 4 +--- source/slang/slang-emit.cpp | 8 ++++---- source/slang/slang-emit.h | 4 ++-- source/slang/slang-ir-link.cpp | 2 +- source/slang/slang-ir-link.h | 2 +- 7 files changed, 32 insertions(+), 31 deletions(-) (limited to 'source') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index ca7e5fb83..68ab205c4 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -567,7 +567,7 @@ namespace Slang SlangResult emitEntryPointsSource( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, TargetRequest* targetReq, CodeGenTarget target, EndToEndCompileRequest* endToEndReq, @@ -577,9 +577,9 @@ namespace Slang if(isPassThroughEnabled(endToEndReq)) { - for (auto entryPointIndex = entryPointIndices.begin(); entryPointIndex != entryPointIndices.end(); entryPointIndex++) + for (auto entryPointIndex : entryPointIndices) { - auto translationUnit = getPassThroughTranslationUnit(endToEndReq, *entryPointIndex); + auto translationUnit = getPassThroughTranslationUnit(endToEndReq, entryPointIndex); SLANG_ASSERT(translationUnit); // Generate a string that includes the content of // the source file(s), along with a line directive @@ -779,7 +779,7 @@ namespace Slang String calcSourcePathForEntryPoints( EndToEndCompileRequest* endToEndReq, - List entryPointIndices) + const List& entryPointIndices) { String failureMode = "slang-generated"; if (entryPointIndices.getCount() != 1) @@ -841,10 +841,12 @@ namespace Slang } // Helper function for recovering the entry point code indices from a list of entry points - List getEntryPointIndices(List const& entryPoints) { + List getEntryPointIndices(List const& entryPoints) + { List result; - for (auto entryPoint = entryPoints.begin(); entryPoint != entryPoints.end(); entryPoint++) { - result.add(entryPoint->index); + for (auto& entryPoint : entryPoints) + { + result.add(entryPoint.index); } return result; } @@ -1276,7 +1278,7 @@ SlangResult dissassembleDXILUsingDXC( SlangResult emitWithDownstreamForEntryPoints( BackEndCompileRequest* slangRequest, - List entryPointIndices, + const List& entryPointIndices, TargetRequest* targetReq, EndToEndCompileRequest* endToEndReq, RefPtr& outResult) @@ -1638,7 +1640,7 @@ SlangResult dissassembleDXILUsingDXC( SlangResult emitSPIRVForEntryPointsDirectly( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, TargetRequest* targetReq, List& spirvOut); @@ -2229,14 +2231,15 @@ SlangResult dissassembleDXILUsingDXC( } CompileResult& TargetProgram::_createWholeProgramResult( - List entryPointIndices, + const List& entryPointIndices, BackEndCompileRequest* backEndRequest, EndToEndCompileRequest* endToEndRequest) { List entryPoints; - for (auto entryPointIndex = entryPointIndices.begin(); entryPointIndex != entryPointIndices.end(); entryPointIndex++) { - if (*entryPointIndex >= m_entryPointResults.getCount()) - m_entryPointResults.setCount(*entryPointIndex + 1); + for (auto entryPointIndex : entryPointIndices) + { + if (entryPointIndex >= m_entryPointResults.getCount()) + m_entryPointResults.setCount(entryPointIndex + 1); // It is possible that entry points goot added to the `Program` // *after* we created this `TargetProgram`, so there might be @@ -2246,8 +2249,8 @@ SlangResult dissassembleDXILUsingDXC( // constructed all at once rather than incrementally, to avoid // this problem. // - auto entryPoint = m_program->getEntryPoint(*entryPointIndex); - entryPoints.add(EntryPointAndIndex(entryPoint, *entryPointIndex)); + auto entryPoint = m_program->getEntryPoint(entryPointIndex); + entryPoints.add(EntryPointAndIndex(entryPoint, entryPointIndex)); } auto& result = m_wholeProgramResult; result = emitEntryPoints( @@ -2290,7 +2293,7 @@ SlangResult dissassembleDXILUsingDXC( } CompileResult& TargetProgram::getOrCreateWholeProgramResult( - List entryPointIndices, + const List& entryPointIndices, DiagnosticSink* sink) { auto& result = m_wholeProgramResult; diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 72c40a497..bbf3be1ca 100644 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -1682,7 +1682,7 @@ namespace Slang /// code generation to the given `sink`. /// CompileResult& getOrCreateEntryPointResult(Int entryPointIndex, DiagnosticSink* sink); - CompileResult& getOrCreateWholeProgramResult(List entryPointIndices, DiagnosticSink* sink); + CompileResult& getOrCreateWholeProgramResult(const List& entryPointIndices, DiagnosticSink* sink); CompileResult& getExistingWholeProgramResult() @@ -1700,7 +1700,7 @@ namespace Slang } CompileResult& _createWholeProgramResult( - List entryPointIndices, + const List& entryPointIndices, BackEndCompileRequest* backEndRequest, EndToEndCompileRequest* endToEndRequest); /// Internal helper for `getOrCreateEntryPointResult`. @@ -1959,7 +1959,7 @@ namespace Slang // TODO(DG): Note to reviewer; this was changed from UInt to List -- let me know if that's a problem // and I can work out the appropriate casts String calcSourcePathForEntryPoint(EndToEndCompileRequest* endToEndReq, Int entryPointIndex); - String calcSourcePathForEntryPoints(EndToEndCompileRequest* endToEndReq, List entryPointIndices); + String calcSourcePathForEntryPoints(EndToEndCompileRequest* endToEndReq, const List& entryPointIndices); struct SourceResult { @@ -1978,7 +1978,7 @@ namespace Slang the target (not targetReq) */ SlangResult emitEntryPointsSource( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, TargetRequest* targetReq, CodeGenTarget target, EndToEndCompileRequest* endToEndReq, diff --git a/source/slang/slang-dxc-support.cpp b/source/slang/slang-dxc-support.cpp index 4fdb55e29..1bd4f101a 100644 --- a/source/slang/slang-dxc-support.cpp +++ b/source/slang/slang-dxc-support.cpp @@ -193,9 +193,7 @@ namespace Slang args[argCount++] = L"-enable-16bit-types"; } - List entryPointIndices2; - entryPointIndices.add(entryPointIndex); - const String sourcePath = calcSourcePathForEntryPoints(endToEndReq, entryPointIndices2); + const String sourcePath = calcSourcePathForEntryPoints(endToEndReq, entryPointIndices); ComPtr dxcResult; SLANG_RETURN_ON_FAIL(dxcCompiler->Compile(dxcSourceBlob, diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index e59cfae37..a93427e29 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -163,7 +163,7 @@ struct LinkingAndOptimizationOptions // TODO(DG): A bit tricky; this needs to be generalized to multiple entry points Result linkAndOptimizeIR( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, CodeGenTarget target, TargetRequest* targetRequest, LinkingAndOptimizationOptions const& options, @@ -612,10 +612,10 @@ Result linkAndOptimizeIR( // TODO(DG): This probably needs to be generalized to a list SlangResult emitEntryPointSourceFromIR( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, CodeGenTarget target, TargetRequest* targetRequest, - SourceResult& outSource) + SourceResult& outSource) { // Temporary assertion for checkpoint SLANG_ASSERT(entryPointIndices.getCount() == 1); @@ -780,7 +780,7 @@ SlangResult emitSPIRVFromIR( SlangResult emitSPIRVForEntryPointsDirectly( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, TargetRequest* targetRequest, List& spirvOut) { diff --git a/source/slang/slang-emit.h b/source/slang/slang-emit.h index 09da4c2ba..2c36436ee 100644 --- a/source/slang/slang-emit.h +++ b/source/slang/slang-emit.h @@ -38,9 +38,9 @@ namespace Slang /// SlangResult emitEntryPointSourceFromIR( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, CodeGenTarget target, TargetRequest* targetRequest, - SourceResult& outSource); + SourceResult& outSource); } #endif diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp index f1f6d4cd4..7acdac40b 100644 --- a/source/slang/slang-ir-link.cpp +++ b/source/slang/slang-ir-link.cpp @@ -1349,7 +1349,7 @@ struct IRSpecializationState // TODO(DG): Generalize to multiple entry points LinkedIR linkIR( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, CodeGenTarget target, TargetProgram* targetProgram) { diff --git a/source/slang/slang-ir-link.h b/source/slang/slang-ir-link.h index e244f29e6..dc9ad50a0 100644 --- a/source/slang/slang-ir-link.h +++ b/source/slang/slang-ir-link.h @@ -20,7 +20,7 @@ namespace Slang // LinkedIR linkIR( BackEndCompileRequest* compileRequest, - List entryPointIndices, + const List& entryPointIndices, CodeGenTarget target, TargetProgram* targetProgram); -- cgit v1.2.3