summaryrefslogtreecommitdiff
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-10-29 08:51:24 -0400
committerGitHub <noreply@github.com>2019-10-29 08:51:24 -0400
commitc27b7d91aaf6bc764807a8998a9c885e57c22a1b (patch)
tree56dc12c9f326f7d4fe4ddf1bfe5903e8918732bd /source/slang/slang-compiler.cpp
parentc886ca811975e91cedca898a561ff65a5663272d (diff)
Feature/container format (#1098)
* WIP RiffContainer. * WIP riff container. * Testing out RiffContainer. * * Naming improvements * Visitor functions * Ability to dump riffs. * Renamed RiffChunk to RiffHeader * Remove m_ prefix on RiffHeader members. * Riff stream reading writing. Simple test of riff reading/writing. * Fix Riff alignment issue. Make IR serialization use the RiffContainer API. * Improve documentation. * Remove SubChunk fuctionality as not needed with RiffContainer.
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 3fee24003..87a5e01a8 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -2183,7 +2183,58 @@ SlangResult dissassembleDXILUsingDXC(
}
}
+ static SlangResult _writeContainerFile(
+ EndToEndCompileRequest* endToEndReq,
+ Stream* stream)
+ {
+ SLANG_UNUSED(stream);
+
+ auto linkage = endToEndReq->getLinkage();
+ auto sink = endToEndReq->getSink();
+ auto frontEndReq = endToEndReq->getFrontEndReq();
+
+ for (auto translationUnit : frontEndReq->translationUnits)
+ {
+ auto module = translationUnit->module;
+ auto irModule = module->getIRModule();
+
+ SLANG_UNUSED(irModule);
+ // Okay, we need to serialize this module to our container file,
+ // including both its name and generated IR code.
+ }
+
+ auto program = endToEndReq->getSpecializedGlobalAndEntryPointsComponentType();
+
+
+
+ // TODO: in the case where we have specialization, we might need
+ // to serialize IR related to `program`...
+
+ for (auto target : linkage->targets)
+ {
+ auto targetProgram = program->getTargetProgram(target);
+ auto irModule = targetProgram->getOrCreateIRModuleForLayout(sink);
+
+ // Okay, we need to serialize this target program and its IR too...
+ }
+
+ return SLANG_OK;
+ }
+
+ /// Write out a "container" file with the stuff that has
+ /// been compiled as part of this request.
+ ///
+ static void _writeContainerFile(
+ EndToEndCompileRequest* endToEndReq,
+ const String& fileName)
+ {
+ FileStream stream(fileName, FileMode::Create, FileAccess::Write, FileShare::ReadWrite);
+ if (SLANG_FAILED(_writeContainerFile(endToEndReq, &stream)))
+ {
+ endToEndReq->getSink()->diagnose(SourceLoc(), Diagnostics::unableToWriteModuleContainer, fileName);
+ }
+ }
static void _generateOutput(
BackEndCompileRequest* compileRequest,
@@ -2229,6 +2280,11 @@ SlangResult dissassembleDXILUsingDXC(
ee);
}
}
+
+ if (compileRequest->containerOutputPath.getLength() != 0)
+ {
+ _writeContainerFile(compileRequest, compileRequest->containerOutputPath);
+ }
}
}