diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-10-24 17:58:24 -0400 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-10-24 14:58:24 -0700 |
| commit | 89ddb50eaccc1b7b590dbde55032721762711fb2 (patch) | |
| tree | e61da2c1604e0d52d3a9915363769ccf950b62f3 /source/slang | |
| parent | 58ad4b1a9ca43098a071c42bd752a4a48405bf0e (diff) | |
OffsetContainer serialization (#1093)
* OffsetContainer with unit tests.
* State serialization working with OffsetContainer.
* Fixes to make work with OffsetContainer.
* Added OffsetContainer documentation.
* Remove RelativeContainer.
* Fix problem with + on Offset32Ptr on windows x86 target.
* * Made OffsetBase a base class of OffsetContainer.
* Added MemoryOffsetBase to just handle being a chunk of memory.
* * Use operator[] to access contents of OffsetContainer
* Fix the type hash to work across different size_t sizes.
* Fixed some Offset type related comments.
* Fix bug around using asBase, because it returns a reference just using 'auto' will means it becomes a value type.
Remove assignment and copy ctor from OffsetBase.
* Evaluation order of assignment can lead to wrong behavior with Offset32Ptr/raw pointers. Document the fact, and fix in StateSerializeUtil.
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-options.cpp | 4 | ||||
| -rw-r--r-- | source/slang/slang-state-serialize.cpp | 435 | ||||
| -rw-r--r-- | source/slang/slang-state-serialize.h | 62 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 10 |
4 files changed, 289 insertions, 222 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 3e2bec07d..c76993ca4 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -514,6 +514,8 @@ struct OptionsParser SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(reproName, buffer)); auto requestState = StateSerializeUtil::getRequest(buffer); + MemoryOffsetBase base; + base.set(buffer.getBuffer(), buffer.getCount()); // If we can find a directory, that exists, we will set up a file system to load from that directory ComPtr<ISlangFileSystem> fileSystem; @@ -527,7 +529,7 @@ struct OptionsParser } } - SLANG_RETURN_ON_FAIL(StateSerializeUtil::load(requestState, fileSystem, requestImpl)); + SLANG_RETURN_ON_FAIL(StateSerializeUtil::load(base, requestState, fileSystem, requestImpl)); if (argCursor < argEnd) { diff --git a/source/slang/slang-state-serialize.cpp b/source/slang/slang-state-serialize.cpp index f7e472643..2d40e78ef 100644 --- a/source/slang/slang-state-serialize.cpp +++ b/source/slang/slang-state-serialize.cpp @@ -12,41 +12,49 @@ namespace Slang { /* static */const RiffSemanticVersion StateSerializeUtil::g_semanticVersion = RiffSemanticVersion::make(StateSerializeUtil::kMajorVersion, StateSerializeUtil::kMinorVersion, StateSerializeUtil::kPatchVersion); +// We can't just use sizeof for the sizes of these types, because the hash will be dependent on the ptr size, +// which isn't an issue for serialization (we turn all pointers into Offset32Ptr -> uint32_t). So we use an x macro +// to set up the thing to hash. +// +// Note that bool is in the list because size of bool can change between compilers. +#define SLANG_STATE_TYPES(x) \ + x(Util::FileState) \ + x(Util::PathInfoState) \ + x(Util::PathInfoState::CompressedResult) \ + x(SlangPathType) \ + x(Util::PathAndPathInfo) \ + x(Util::TargetRequestState) \ + x(Profile) \ + x(CodeGenTarget) \ + x(SlangTargetFlags) \ + x(FloatingPointMode) \ + x(Util::StringPair) \ + x(Util::SourceFileState) \ + x(PathInfo::Type) \ + x(Util::TranslationUnitRequestState) \ + x(SourceLanguage) \ + x(Util::EntryPointState) \ + x(Profile) \ + x(Util::RequestState) \ + x(SlangCompileFlags) \ + x(bool) \ + x(LineDirectiveMode) \ + x(DebugInfoLevel) \ + x(OptimizationLevel) \ + x(ContainerFormat) \ + x(PassThroughMode) \ + x(SlangMatrixLayoutMode) \ + +#define SLANG_STATE_TYPE_SIZE(x) uint32_t(sizeof(x)), + // A function to calculate the hash related in list in part to how the types used are sized. Can catch crude breaking binary differences. static uint32_t _calcTypeHash() { typedef StateSerializeUtil Util; - - const size_t sizes[] = + const uint32_t sizes[] = { - sizeof(Util::FileState), - sizeof(Util::PathInfoState), - sizeof(Util::PathInfoState::CompressedResult), - sizeof(SlangPathType), - sizeof(Util::PathAndPathInfo), - sizeof(Util::TargetRequestState), - sizeof(Profile), - sizeof(CodeGenTarget), - sizeof(SlangTargetFlags), - sizeof(FloatingPointMode), - sizeof(Util::StringPair), - sizeof(Util::SourceFileState), - sizeof(PathInfo::Type), - sizeof(Util::TranslationUnitRequestState), - sizeof(SourceLanguage), - sizeof(Util::EntryPointState), - sizeof(Profile), - sizeof(Util::RequestState), - sizeof(SlangCompileFlags), - sizeof(bool), //< Unfortunately bools size can change across compilers/versions - sizeof(LineDirectiveMode), - sizeof(DebugInfoLevel), - sizeof(OptimizationLevel), - sizeof(ContainerFormat), - sizeof(PassThroughMode), - sizeof(SlangMatrixLayoutMode), + SLANG_STATE_TYPES(SLANG_STATE_TYPE_SIZE) }; - return uint32_t(GetHashCode((const char*)&sizes, sizeof(sizes))); } @@ -65,54 +73,71 @@ struct StoreContext typedef StateSerializeUtil::SourceFileState SourceFileState; typedef StateSerializeUtil::PathInfoState PathInfoState; - StoreContext(RelativeContainer* container) + StoreContext(OffsetContainer* container) { m_container = container; } - Safe32Ptr<FileState> findFile(const String& uniqueIdentity) + Offset32Ptr<FileState> findFile(const String& uniqueIdentity) { - Safe32Ptr<FileState> file; + Offset32Ptr<FileState> file; m_uniqueToFileMap.TryGetValue(uniqueIdentity, file); return file; } - Safe32Ptr<FileState> addFile(const String& uniqueIdentity, const UnownedStringSlice* content) + Offset32Ptr<FileState> addFile(const String& uniqueIdentity, const UnownedStringSlice* content) { - Safe32Ptr<FileState> file; + OffsetBase& base = m_container->asBase(); + Offset32Ptr<FileState> file; + // Get the file, if it has an identity - if (uniqueIdentity.getLength() && m_uniqueToFileMap.TryGetValue(uniqueIdentity, file)) + if (uniqueIdentity.getLength()) { - return file; + if (!m_uniqueToFileMap.TryGetValue(uniqueIdentity, file)) + { + // If file was not found create it + // Create the file + file = m_container->newObject<FileState>(); + // Add it + m_uniqueToFileMap.Add(uniqueIdentity, file); + + // Set the identity + auto offsetUniqueIdentity = m_container->newString(uniqueIdentity.getUnownedSlice()); + base[file]->uniqueIdentity = offsetUniqueIdentity; + + // Add the file + m_files.add(file); + } } - - // If file was not found create it - // Create the file - file = m_container->newObject<FileState>(); - - if (content) + else { - file->contents = m_container->newString(*content); + // Create a file, but we know it can't have unique identity + file = m_container->newObject<FileState>(); + // Add the file + m_files.add(file); } - if (uniqueIdentity.getLength()) + + // If the contents is not set add it + if (!base[file]->contents && content) { - file->uniqueIdentity = m_container->newString(uniqueIdentity.getUnownedSlice()); - m_uniqueToFileMap.Add(uniqueIdentity, file); + auto offsetContent = m_container->newString(*content); + base[file]->contents = offsetContent; } - m_files.add(file); return file; } - Safe32Ptr<SourceFileState> addSourceFile(SourceFile* sourceFile) + Offset32Ptr<SourceFileState> addSourceFile(SourceFile* sourceFile) { if (!sourceFile) { - return Safe32Ptr<SourceFileState>(); + return Offset32Ptr<SourceFileState>(); } - Safe32Ptr<StateSerializeUtil::SourceFileState> sourceFileState; + auto& base = m_container->asBase(); + + Offset32Ptr<StateSerializeUtil::SourceFileState> sourceFileState; if (m_sourceFileMap.TryGetValue(sourceFile, sourceFileState)) { return sourceFileState; @@ -121,32 +146,35 @@ struct StoreContext const PathInfo& pathInfo = sourceFile->getPathInfo(); UnownedStringSlice content = sourceFile->getContent(); - Safe32Ptr<FileState> file = addFile(pathInfo.uniqueIdentity, &content); + Offset32Ptr<FileState> file = addFile(pathInfo.uniqueIdentity, &content); - Safe32Ptr<RelativeString> foundPath; + Offset32Ptr<OffsetString> foundPath; - if (pathInfo.foundPath.getLength() && file->foundPath == nullptr) + if (pathInfo.foundPath.getLength() && base[file]->foundPath.isNull()) { foundPath = fromString(pathInfo.foundPath.getUnownedSlice()); } // Set on the file - file->foundPath = foundPath; + base[file]->foundPath = foundPath; // Create the source file sourceFileState = m_container->newObject<SourceFileState>(); - sourceFileState->file = file; - sourceFileState->foundPath = foundPath; - sourceFileState->type = pathInfo.type; + { + auto dst = base[sourceFileState]; + dst->file = file; + dst->foundPath = foundPath; + dst->type = pathInfo.type; + } m_sourceFileMap.Add(sourceFile, sourceFileState); return sourceFileState; } - Safe32Ptr<RelativeString> fromString(const String& in) + Offset32Ptr<OffsetString> fromString(const String& in) { - Safe32Ptr<RelativeString> value; + Offset32Ptr<OffsetString> value; if (m_stringMap.TryGetValue(in, value)) { @@ -156,39 +184,43 @@ struct StoreContext m_stringMap.Add(in, value); return value; } - Safe32Ptr<RelativeString> fromName(Name* name) + Offset32Ptr<OffsetString> fromName(Name* name) { if (name) { return fromString(name->text); } - return Safe32Ptr<RelativeString>(); + return Offset32Ptr<OffsetString>(); } - Safe32Ptr<PathInfoState> addPathInfo(const CacheFileSystem::PathInfo* srcPathInfo) + Offset32Ptr<PathInfoState> addPathInfo(const CacheFileSystem::PathInfo* srcPathInfo) { if (!srcPathInfo) { - return Safe32Ptr<PathInfoState>(); + return Offset32Ptr<PathInfoState>(); } - Safe32Ptr<PathInfoState> pathInfo; + OffsetBase& base = m_container->asBase(); + + Offset32Ptr<PathInfoState> pathInfo; if (!m_pathInfoMap.TryGetValue(srcPathInfo, pathInfo)) { // Get the associated file - Safe32Ptr<FileState> fileState; + Offset32Ptr<FileState> fileState; // Only store as file if we have the contents - if(srcPathInfo->m_fileBlob) + if(ISlangBlob* fileBlob = srcPathInfo->m_fileBlob) { - fileState = addFile(srcPathInfo->getUniqueIdentity(), nullptr); + UnownedStringSlice content((const char*)fileBlob->getBufferPointer(), fileBlob->getBufferSize()); + + fileState = addFile(srcPathInfo->getUniqueIdentity(), &content); } // Save the rest of the state pathInfo = m_container->newObject<PathInfoState>(); - PathInfoState& dst = *pathInfo; + PathInfoState& dst = base[*pathInfo]; - pathInfo->file = fileState; + dst.file = fileState; // Save any other info dst.getCanonicalPathResult = srcPathInfo->m_getCanonicalPathResult; @@ -200,36 +232,41 @@ struct StoreContext } // Fill in info on the file - Safe32Ptr<FileState> fileState(m_container->toSafe(pathInfo->file.get())); + auto fileState(base[pathInfo]->file); // If have fileState add any missing element if (fileState) { - if (srcPathInfo->m_fileBlob && fileState->contents == nullptr) + if (srcPathInfo->m_fileBlob && base[fileState]->contents.isNull()) { UnownedStringSlice contents((const char*)srcPathInfo->m_fileBlob->getBufferPointer(), srcPathInfo->m_fileBlob->getBufferSize()); - fileState->contents = m_container->newString(contents); + auto offsetContents = m_container->newString(contents); + base[fileState]->contents = offsetContents; } - if (srcPathInfo->m_canonicalPath && fileState->canonicalPath == nullptr) + if (srcPathInfo->m_canonicalPath && base[fileState]->canonicalPath.isNull()) { - fileState->canonicalPath = fromString(srcPathInfo->m_canonicalPath->getString()); + auto offsetCanonicalPath = fromString(srcPathInfo->m_canonicalPath->getString()); + base[fileState]->canonicalPath = offsetCanonicalPath; } - if (srcPathInfo->m_uniqueIdentity && fileState->uniqueIdentity == nullptr) + if (srcPathInfo->m_uniqueIdentity && base[fileState]->uniqueIdentity.isNull()) { - fileState->uniqueIdentity = fromString(srcPathInfo->m_uniqueIdentity->getString()); + auto offsetUniqueIdentity = fromString(srcPathInfo->m_uniqueIdentity->getString()); + base[fileState]->uniqueIdentity = offsetUniqueIdentity; } } return pathInfo; } - const Safe32Array<StateSerializeUtil::StringPair> calcDefines(const Dictionary<String, String>& srcDefines) + const Offset32Array<StateSerializeUtil::StringPair> calcDefines(const Dictionary<String, String>& srcDefines) { typedef StateSerializeUtil::StringPair StringPair; - Safe32Array<StringPair> dstDefines = m_container->newArray<StringPair>(srcDefines.Count()); + Offset32Array<StringPair> dstDefines = m_container->newArray<StringPair>(srcDefines.Count()); + + OffsetBase& base = m_container->asBase(); Index index = 0; for (const auto& srcDefine : srcDefines) @@ -238,7 +275,7 @@ struct StoreContext auto key = fromString(srcDefine.Key); auto value = fromString(srcDefine.Value); - auto& dstDefine = dstDefines[index]; + auto& dstDefine = base[dstDefines[index]]; dstDefine.first = key; dstDefine.second = value; @@ -248,27 +285,29 @@ struct StoreContext return dstDefines; } - const Safe32Array<Relative32Ptr<RelativeString>> fromList(const List<String>& src) + const Offset32Array<Offset32Ptr<OffsetString>> fromList(const List<String>& src) { - Safe32Array<Relative32Ptr<RelativeString>> dst = m_container->newArray<Relative32Ptr<RelativeString>>(src.getCount()); + Offset32Array<Offset32Ptr<OffsetString>> dst = m_container->newArray<Offset32Ptr<OffsetString>>(src.getCount()); + OffsetBase& base = m_container->asBase(); + for (Index j = 0; j < src.getCount(); ++j) { - dst[j] = fromString(src[j]); + base[dst[j]] = fromString(src[j]); } return dst; } - Dictionary<String, Safe32Ptr<RelativeString> > m_stringMap; + Dictionary<String, Offset32Ptr<OffsetString> > m_stringMap; - Dictionary<SourceFile*, Safe32Ptr<StateSerializeUtil::SourceFileState> > m_sourceFileMap; + Dictionary<SourceFile*, Offset32Ptr<StateSerializeUtil::SourceFileState> > m_sourceFileMap; - Dictionary<String, Safe32Ptr<StateSerializeUtil::FileState> > m_uniqueToFileMap; + Dictionary<String, Offset32Ptr<StateSerializeUtil::FileState> > m_uniqueToFileMap; - Dictionary<const CacheFileSystem::PathInfo*, Safe32Ptr<PathInfoState> > m_pathInfoMap; + Dictionary<const CacheFileSystem::PathInfo*, Offset32Ptr<PathInfoState> > m_pathInfoMap; - List<Safe32Ptr<StateSerializeUtil::FileState> > m_files; + List<Offset32Ptr<StateSerializeUtil::FileState> > m_files; - RelativeContainer* m_container; + OffsetContainer* m_container; }; } // @@ -288,16 +327,18 @@ static bool _isStorable(const PathInfo::Type type) } } -/* static */SlangResult StateSerializeUtil::store(EndToEndCompileRequest* request, RelativeContainer& inOutContainer, Safe32Ptr<RequestState>& outRequest) +/* static */SlangResult StateSerializeUtil::store(EndToEndCompileRequest* request, OffsetContainer& inOutContainer, Offset32Ptr<RequestState>& outRequest) { StoreContext context(&inOutContainer); + OffsetBase& base = inOutContainer.asBase(); + auto linkage = request->getLinkage(); - Safe32Ptr<RequestState> requestState = inOutContainer.newObject<RequestState>(); + Offset32Ptr<RequestState> requestState = inOutContainer.newObject<RequestState>(); { - RequestState* dst = requestState; + RequestState* dst = base[requestState]; dst->compileFlags = request->getFrontEndReq()->compileFlags; dst->shouldDumpIntermediates = request->getBackEndReq()->shouldDumpIntermediates; @@ -322,7 +363,7 @@ static bool _isStorable(const PathInfo::Type type) SLANG_ASSERT(srcEntryPoints.getCount() == srcEndToEndEntryPoints.getCount()); - Safe32Array<EntryPointState> dstEntryPoints = inOutContainer.newArray<EntryPointState>(srcEntryPoints.getCount()); + Offset32Array<EntryPointState> dstEntryPoints = inOutContainer.newArray<EntryPointState>(srcEntryPoints.getCount()); for (Index i = 0; i < srcEntryPoints.getCount(); ++i) { @@ -330,9 +371,9 @@ static bool _isStorable(const PathInfo::Type type) const auto& srcEndToEndEntryPoint = srcEndToEndEntryPoints[i]; auto dstSpecializationArgStrings = context.fromList(srcEndToEndEntryPoint.specializationArgStrings); - Safe32Ptr<RelativeString> dstName = context.fromName(srcEntryPoint->getName()); + Offset32Ptr<OffsetString> dstName = context.fromName(srcEntryPoint->getName()); - EntryPointState& dst = dstEntryPoints[i]; + EntryPointState& dst = base[dstEntryPoints[i]]; dst.profile = srcEntryPoint->getProfile(); dst.translationUnitIndex = uint32_t(srcEntryPoint->getTranslationUnitIndex()); @@ -340,7 +381,7 @@ static bool _isStorable(const PathInfo::Type type) dst.name = dstName; } - requestState->entryPoints = dstEntryPoints; + base[requestState]->entryPoints = dstEntryPoints; } @@ -361,7 +402,7 @@ static bool _isStorable(const PathInfo::Type type) // Add all the target requests { - Safe32Array<TargetRequestState> dstTargets = inOutContainer.newArray<TargetRequestState>(linkage->targets.getCount()); + Offset32Array<TargetRequestState> dstTargets = inOutContainer.newArray<TargetRequestState>(linkage->targets.getCount()); for (Index i = 0; i < linkage->targets.getCount(); ++i) { @@ -369,7 +410,7 @@ static bool _isStorable(const PathInfo::Type type) // Copy the simple stuff { - auto& dst = dstTargets[i]; + auto& dst = base[dstTargets[i]]; dst.target = srcTargetRequest->getTarget(); dst.profile = srcTargetRequest->getTargetProfile(); dst.targetFlags = srcTargetRequest->targetFlags; @@ -386,14 +427,14 @@ static bool _isStorable(const PathInfo::Type type) const auto& entryPointOutputPaths = infos->entryPointOutputPaths; - Safe32Array<OutputState> dstOutputStates = inOutContainer.newArray<OutputState>(entryPointOutputPaths.Count()); + Offset32Array<OutputState> dstOutputStates = inOutContainer.newArray<OutputState>(entryPointOutputPaths.Count()); Index index = 0; for (const auto& pair : entryPointOutputPaths) { - Safe32Ptr<RelativeString> outputPath = inOutContainer.newString(pair.Value.getUnownedSlice()); + Offset32Ptr<OffsetString> outputPath = inOutContainer.newString(pair.Value.getUnownedSlice()); - auto& dstOutputState = dstOutputStates[index]; + auto& dstOutputState = base[dstOutputStates[index]]; dstOutputState.entryPointIndex = int32_t(pair.Key); dstOutputState.outputPath = outputPath; @@ -401,35 +442,35 @@ static bool _isStorable(const PathInfo::Type type) index++; } - dstTargets[i].outputStates = dstOutputStates; + base[dstTargets[i]].outputStates = dstOutputStates; } } } // Save the result - requestState->targetRequests = dstTargets; + base[requestState]->targetRequests = dstTargets; } // Add the search paths { const auto& srcPaths = linkage->searchDirectories.searchDirectories; - Safe32Array<Relative32Ptr<RelativeString> > dstPaths = inOutContainer.newArray<Relative32Ptr<RelativeString> >(srcPaths.getCount()); + Offset32Array<Offset32Ptr<OffsetString> > dstPaths = inOutContainer.newArray<Offset32Ptr<OffsetString> >(srcPaths.getCount()); // We don't handle parents here SLANG_ASSERT(linkage->searchDirectories.parent == nullptr); for (Index i = 0; i < srcPaths.getCount(); ++i) { - dstPaths[i] = context.fromString(srcPaths[i].path); + base[dstPaths[i]] = context.fromString(srcPaths[i].path); } - requestState->searchPaths = dstPaths; + base[requestState]->searchPaths = dstPaths; } // Add preprocessor definitions - requestState->preprocessorDefinitions = context.calcDefines(linkage->preprocessorDefinitions); + base[requestState]->preprocessorDefinitions = context.calcDefines(linkage->preprocessorDefinitions); { const auto& srcTranslationUnits = request->getFrontEndReq()->translationUnits; - Safe32Array<TranslationUnitRequestState> dstTranslationUnits = inOutContainer.newArray<TranslationUnitRequestState>(srcTranslationUnits.getCount()); + Offset32Array<TranslationUnitRequestState> dstTranslationUnits = inOutContainer.newArray<TranslationUnitRequestState>(srcTranslationUnits.getCount()); for (Index i = 0; i < srcTranslationUnits.getCount(); ++i) { @@ -439,18 +480,18 @@ static bool _isStorable(const PathInfo::Type type) auto defines = context.calcDefines(srcTranslationUnit->preprocessorDefinitions); auto moduleName = context.fromName(srcTranslationUnit->moduleName); - Safe32Array<Relative32Ptr<SourceFileState>> dstSourceFiles; + Offset32Array<Offset32Ptr<SourceFileState>> dstSourceFiles; { const auto& srcFiles = srcTranslationUnit->getSourceFiles(); - dstSourceFiles = inOutContainer.newArray<Relative32Ptr<SourceFileState> >(srcFiles.getCount()); + dstSourceFiles = inOutContainer.newArray<Offset32Ptr<SourceFileState> >(srcFiles.getCount()); for (Index j = 0; j < srcFiles.getCount(); ++j) { - dstSourceFiles[j] = context.addSourceFile(srcFiles[j]); + base[dstSourceFiles[j]] = context.addSourceFile(srcFiles[j]); } } - TranslationUnitRequestState& dstTranslationUnit = dstTranslationUnits[i]; + TranslationUnitRequestState& dstTranslationUnit = base[dstTranslationUnits[i]]; dstTranslationUnit.language = srcTranslationUnit->sourceLanguage; dstTranslationUnit.moduleName = moduleName; @@ -458,7 +499,7 @@ static bool _isStorable(const PathInfo::Type type) dstTranslationUnit.preprocessorDefinitions = defines; } - requestState->translationUnits = dstTranslationUnits; + base[requestState]->translationUnits = dstTranslationUnits; } // Find files from the file system, and mapping paths to files @@ -473,22 +514,22 @@ static bool _isStorable(const PathInfo::Type type) { const auto& srcFiles = cacheFileSystem->getPathMap(); - Safe32Array<PathAndPathInfo> pathMap = inOutContainer.newArray<PathAndPathInfo>(srcFiles.Count()); + Offset32Array<PathAndPathInfo> pathMap = inOutContainer.newArray<PathAndPathInfo>(srcFiles.Count()); Index index = 0; for (const auto& pair : srcFiles) { - Safe32Ptr<RelativeString> path = context.fromString(pair.Key); - Safe32Ptr<PathInfoState> pathInfo = context.addPathInfo(pair.Value); + Offset32Ptr<OffsetString> path = context.fromString(pair.Key); + Offset32Ptr<PathInfoState> pathInfo = context.addPathInfo(pair.Value); - PathAndPathInfo& dstInfo = pathMap[index]; + PathAndPathInfo& dstInfo = base[pathMap[index]]; dstInfo.path = path; dstInfo.pathInfo = pathInfo; index++; } - requestState->pathInfoMap = pathMap; + base[requestState]->pathInfoMap = pathMap; } } @@ -496,25 +537,25 @@ static bool _isStorable(const PathInfo::Type type) { Dictionary<String, int> uniqueNameMap; - auto files = inOutContainer.newArray<Relative32Ptr<FileState>>(context.m_files.getCount()); + auto files = inOutContainer.newArray<Offset32Ptr<FileState>>(context.m_files.getCount()); for (Index i = 0; i < context.m_files.getCount(); ++i) { - Safe32Ptr<FileState> file = context.m_files[i]; + Offset32Ptr<FileState> file = context.m_files[i]; // Need to come up with unique names String path; - if (file->canonicalPath) + if (auto canonicalPath = base[file]->canonicalPath) { - path = file->canonicalPath->getSlice(); + path = base[canonicalPath]->getSlice(); } - else if (file->foundPath) + else if (auto foundPath = base[file]->foundPath) { - path = file->foundPath->getSlice(); + path = base[foundPath]->getSlice(); } - else if (file->uniqueIdentity) + else if (auto uniqueIdentity = base[file]->uniqueIdentity) { - path = file->uniqueIdentity->getSlice(); + path = base[uniqueIdentity]->getSlice(); } if (path.getLength() == 0) @@ -552,26 +593,26 @@ static bool _isStorable(const PathInfo::Type type) } // Save the unique generated name - file->uniqueName = inOutContainer.newString(uniqueName.getUnownedSlice()); + base[file]->uniqueName = inOutContainer.newString(uniqueName.getUnownedSlice()); - files[i] = file; + base[files[i]] = file; } - requestState->files = files; + base[requestState]->files = files; } // Save all the SourceFile state { const auto& srcSourceFiles = context.m_sourceFileMap; - auto dstSourceFiles = inOutContainer.newArray<Relative32Ptr<SourceFileState>>(srcSourceFiles.Count()); + auto dstSourceFiles = inOutContainer.newArray<Offset32Ptr<SourceFileState>>(srcSourceFiles.Count()); Index index = 0; for (const auto& pair : srcSourceFiles) { - dstSourceFiles[index] = pair.Value; + base[dstSourceFiles[index]] = pair.Value; index++; } - requestState->sourceFiles = dstSourceFiles; + base[requestState]->sourceFiles = dstSourceFiles; } outRequest = requestState; @@ -599,13 +640,13 @@ struct LoadContext if (m_fileSystem && file->uniqueName) { // Try loading from the file system - m_fileSystem->loadFile(file->uniqueName->getCstr(), blob.writeRef()); + m_fileSystem->loadFile(m_base->asRaw(file->uniqueName)->getCstr(), blob.writeRef()); } // If wasn't loaded, and has contents, use that if (!blob && file->contents) { - blob = new StringBlob(file->contents->getSlice()); + blob = new StringBlob(m_base->asRaw(file->contents)->getSlice()); } // Add to map, even if the blob is nullptr (say from a failed read) @@ -625,7 +666,7 @@ struct LoadContext SourceFile* dstFile; if (!m_sourceFileMap.TryGetValue(sourceFile, dstFile)) { - FileState* file = sourceFile->file; + FileState* file = m_base->asRaw(sourceFile->file); ISlangBlob* blob = getFileBlob(file); PathInfo pathInfo; @@ -634,16 +675,16 @@ struct LoadContext if (sourceFile->foundPath) { - pathInfo.foundPath = sourceFile->foundPath->getSlice(); + pathInfo.foundPath = m_base->asRaw(sourceFile->foundPath)->getSlice(); } else if (file->foundPath) { - pathInfo.foundPath = file->foundPath->getSlice(); + pathInfo.foundPath = m_base->asRaw(file->foundPath)->getSlice(); } if (file->uniqueIdentity) { - pathInfo.uniqueIdentity = file->uniqueIdentity->getSlice(); + pathInfo.uniqueIdentity = m_base->asRaw(file->uniqueIdentity)->getSlice(); } dstFile = new SourceFile(m_sourceManager, pathInfo, blob->getBufferSize()); @@ -667,18 +708,18 @@ struct LoadContext } CacheFileSystem::PathInfo* dstInfo = new CacheFileSystem::PathInfo(String()); - FileState* file = srcInfo->file; + FileState* file = m_base->asRaw(srcInfo->file); if (file) { if (file->uniqueIdentity) { - String uniqueIdentity = file->uniqueIdentity->getSlice(); + String uniqueIdentity = m_base->asRaw(file->uniqueIdentity)->getSlice(); dstInfo->m_uniqueIdentity = new StringBlob(uniqueIdentity); } if (file->canonicalPath) { - dstInfo->m_canonicalPath = new StringBlob(file->canonicalPath->getSlice()); + dstInfo->m_canonicalPath = new StringBlob(m_base->asRaw(file->canonicalPath)->getSlice()); } dstInfo->m_fileBlob = getFileBlob(file); @@ -693,26 +734,40 @@ struct LoadContext return dstInfo; } - static List<const char*> toList(const Relative32Array<Relative32Ptr<RelativeString>>& src) + List<const char*> toList(const Offset32Array<Offset32Ptr<OffsetString>>& src) { List<const char*> dst; dst.setCount(src.getCount()); for (Index i = 0; i < src.getCount(); ++i) { - RelativeString* srcString = src[i]; + OffsetString* srcString = m_base->asRaw(m_base->asRaw(src[i])); dst[i] = srcString ? srcString->getCstr() : nullptr; } return dst; } - LoadContext(SourceManager* sourceManger, ISlangFileSystem* fileSystem): + + void loadDefines(const Offset32Array<StateSerializeUtil::StringPair>& in, Dictionary<String, String>& out) + { + out.Clear(); + + for (const auto& define : in) + { + out.Add(m_base->asRaw(m_base->asRaw(define).first)->getSlice(), m_base->asRaw(m_base->asRaw(define).second)->getSlice()); + } + } + + LoadContext(SourceManager* sourceManger, ISlangFileSystem* fileSystem, OffsetBase* base): m_sourceManager(sourceManger), - m_fileSystem(fileSystem) + m_fileSystem(fileSystem), + m_base(base) { } ISlangFileSystem* m_fileSystem; + OffsetBase* m_base; + SourceManager* m_sourceManager; Dictionary<SourceFileState*, SourceFile*> m_sourceFileMap; Dictionary<FileState*, ComPtr<ISlangBlob> > m_fileToBlobMap; @@ -721,22 +776,12 @@ struct LoadContext } // anonymous -static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& in, Dictionary<String, String>& out) -{ - out.Clear(); - - for (const auto& define : in) - { - out.Add(define.first->getSlice(), define.second->getSlice()); - } -} -/* static */SlangResult StateSerializeUtil::load(RequestState* requestState, ISlangFileSystem* fileSystem, EndToEndCompileRequest* request) +/* static */SlangResult StateSerializeUtil::load(OffsetBase& base, RequestState* requestState, ISlangFileSystem* fileSystem, EndToEndCompileRequest* request) { auto externalRequest = asExternal(request); - auto linkage = request->getLinkage(); // TODO(JS): Really should be more exhaustive here, and set up to initial state ideally @@ -747,7 +792,7 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& linkage->targets.clear(); } - LoadContext context(linkage->getSourceManager(), fileSystem); + LoadContext context(linkage->getSourceManager(), fileSystem, &base); // Try to set state through API - as doing so means if state stored in multiple places it will be ok @@ -772,7 +817,7 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& { for (Index i = 0; i < requestState->targetRequests.getCount(); ++i) { - TargetRequestState& src = requestState->targetRequests[i]; + TargetRequestState& src = base.asRaw(requestState->targetRequests[i]); int index = spAddCodeGenTarget(externalRequest, SlangCompileTarget(src.target)); SLANG_ASSERT(index == i); @@ -789,14 +834,16 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& RefPtr<EndToEndCompileRequest::TargetInfo> dstTargetInfo(new EndToEndCompileRequest::TargetInfo); request->targetInfos[dstTarget] = dstTargetInfo; - for (const auto& srcOutputState : src.outputStates) + for (const auto& srcOutputStateOffset : src.outputStates) { + const auto& srcOutputState = base.asRaw(srcOutputStateOffset); + SLANG_ASSERT(srcOutputState.entryPointIndex < requestState->entryPoints.getCount()); String entryPointPath; if (srcOutputState.outputPath) { - entryPointPath = srcOutputState.outputPath->getSlice(); + entryPointPath = base.asRaw(srcOutputState.outputPath)->getSlice(); } dstTargetInfo->entryPointOutputPaths.Add(srcOutputState.entryPointIndex, entryPointPath); @@ -811,11 +858,11 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& dstPaths.setCount(srcPaths.getCount()); for (Index i = 0; i < srcPaths.getCount(); ++i) { - dstPaths[i].path = srcPaths[i]->getSlice(); + dstPaths[i].path = base.asRaw(base.asRaw(srcPaths[i]))->getSlice(); } } - _loadDefines(requestState->preprocessorDefinitions, linkage->preprocessorDefinitions); + context.loadDefines(requestState->preprocessorDefinitions, linkage->preprocessorDefinitions); { auto frontEndReq = request->getFrontEndReq(); @@ -827,7 +874,7 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& for (Index i = 0; i < srcTranslationUnits.getCount(); ++i) { - const auto& srcTranslationUnit = srcTranslationUnits[i]; + const auto& srcTranslationUnit = base.asRaw(srcTranslationUnits[i]); int index = frontEndReq->addTranslationUnit(srcTranslationUnit.language); SLANG_UNUSED(index); @@ -835,12 +882,12 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& TranslationUnitRequest* dstTranslationUnit = dstTranslationUnits[i]; - _loadDefines(srcTranslationUnit.preprocessorDefinitions, dstTranslationUnit->preprocessorDefinitions); + context.loadDefines(srcTranslationUnit.preprocessorDefinitions, dstTranslationUnit->preprocessorDefinitions); Name* moduleName = nullptr; if (srcTranslationUnit.moduleName) { - moduleName = request->getNamePool()->getName(srcTranslationUnit.moduleName->getSlice()); + moduleName = request->getNamePool()->getName(base.asRaw(srcTranslationUnit.moduleName)->getSlice()); } dstTranslationUnit->moduleName = moduleName; @@ -852,7 +899,7 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& for (Index j = 0; j < srcSourceFiles.getCount(); ++j) { - SourceFile* sourceFile = context.getSourceFile(srcSourceFiles[i]); + SourceFile* sourceFile = context.getSourceFile(base.asRaw(base.asRaw(srcSourceFiles[i]))); // Add to translation unit dstTranslationUnit->addSourceFile(sourceFile); } @@ -864,9 +911,11 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& // Check there aren't any set entry point SLANG_ASSERT(request->getFrontEndReq()->m_entryPointReqs.getCount() == 0); - for (const auto& srcEntryPoint : requestState->entryPoints) + for (const auto& srcEntryPointOffset : requestState->entryPoints) { - const char* name = srcEntryPoint.name ? srcEntryPoint.name->getCstr() : nullptr; + const auto srcEntryPoint = base.asRaw(srcEntryPointOffset); + + const char* name = srcEntryPoint.name ? base.asRaw(srcEntryPoint.name)->getCstr() : nullptr; Stage stage = srcEntryPoint.profile.GetStage(); @@ -883,10 +932,11 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& // Put all the paths to path info { - for (const auto& pair : requestState->pathInfoMap) + for (const auto& pairOffset : requestState->pathInfoMap) { - CacheFileSystem::PathInfo* pathInfo = context.addPathInfo(pair.pathInfo); - dstPathMap.Add(pair.path->getSlice(), pathInfo); + const auto& pair = base.asRaw(pairOffset); + CacheFileSystem::PathInfo* pathInfo = context.addPathInfo(base.asRaw(pair.pathInfo)); + dstPathMap.Add(base.asRaw(pair.path)->getSlice(), pathInfo); } } // Put all the path infos in the cache system @@ -912,8 +962,8 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& /* static */SlangResult StateSerializeUtil::saveState(EndToEndCompileRequest* request, Stream* stream) { - RelativeContainer container; - Safe32Ptr<RequestState> requestState; + OffsetContainer container; + Offset32Ptr<RequestState> requestState; SLANG_RETURN_ON_FAIL(store(request, container, requestState)); Header header; @@ -976,7 +1026,7 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& /* static */ StateSerializeUtil::RequestState* StateSerializeUtil::getRequest(const List<uint8_t>& buffer) { - return (StateSerializeUtil::RequestState*)buffer.getBuffer(); + return (StateSerializeUtil::RequestState*)(buffer.getBuffer() + kStartOffset); } /* static */SlangResult StateSerializeUtil::calcDirectoryPathFromFilename(const String& filename, String& outPath) @@ -1005,6 +1055,9 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& List<uint8_t> buffer; SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(filename, buffer)); + MemoryOffsetBase base; + base.set(buffer.getBuffer(), buffer.getCount()); + RequestState* requestState = StateSerializeUtil::getRequest(buffer); String dirPath; @@ -1014,60 +1067,66 @@ static void _loadDefines(const Relative32Array<StateSerializeUtil::StringPair>& // Set up a file system to write into this directory RelativeFileSystem relFileSystem(OSFileSystemExt::getSingleton(), dirPath); - return extractFiles(requestState, &relFileSystem); + return extractFiles(base, requestState, &relFileSystem); } -/* static */SlangResult StateSerializeUtil::extractFiles(RequestState* requestState, ISlangFileSystemExt* fileSystem) +/* static */SlangResult StateSerializeUtil::extractFiles(OffsetBase& base, RequestState* requestState, ISlangFileSystemExt* fileSystem) { StringBuilder builder; builder << "[files]\n"; - for (FileState* file : requestState->files) + for (auto fileOffset : requestState->files) { + auto file = base.asRaw(base.asRaw(fileOffset)); + if (file->contents) { - UnownedStringSlice contents = file->contents->getSlice(); + UnownedStringSlice contents = base.asRaw(file->contents)->getSlice(); - SLANG_RETURN_ON_FAIL(fileSystem->saveFile(file->uniqueName->getCstr(), contents.begin(), contents.size())); + SLANG_RETURN_ON_FAIL(fileSystem->saveFile(base.asRaw(file->uniqueName)->getCstr(), contents.begin(), contents.size())); - RelativeString* originalName = nullptr; + OffsetString* originalName = nullptr; if (file->canonicalPath) { - originalName = file->canonicalPath; + originalName = base.asRaw(file->canonicalPath); } else if (file->foundPath) { - originalName = file->foundPath; + originalName = base.asRaw(file->foundPath); } else if (file->uniqueIdentity) { - originalName = file->uniqueIdentity; + originalName = base.asRaw(file->uniqueIdentity); } - builder << file->uniqueName->getSlice() << " -> "; + builder << base.asRaw(file->uniqueName)->getSlice() << " -> "; if (originalName) { builder << originalName->getSlice(); } - else + + if (builder.getLength() == 0) { builder << "?"; } + builder << "\n"; } } builder << "[paths]\n"; - for (const PathAndPathInfo& path : requestState->pathInfoMap) + for (const auto pathOffset : requestState->pathInfoMap) { - builder << path.path->getSlice() << " -> "; + const auto& path = base.asRaw(pathOffset); + + builder << base.asRaw(path.path)->getSlice() << " -> "; - const auto pathInfo = path.pathInfo.get(); + const auto pathInfo = base.asRaw(path.pathInfo); if (pathInfo->file) { - builder << pathInfo->file->uniqueName->getSlice(); + builder << base.asRaw(base.asRaw(pathInfo->file)->uniqueName)->getSlice(); } else { diff --git a/source/slang/slang-state-serialize.h b/source/slang/slang-state-serialize.h index 42edd4080..6de792097 100644 --- a/source/slang/slang-state-serialize.h +++ b/source/slang/slang-state-serialize.h @@ -8,7 +8,7 @@ // For TranslationUnitRequest #include "slang-compiler.h" -#include "../core/slang-relative-container.h" +#include "../core/slang-offset-container.h" #include "slang-file-system.h" @@ -35,12 +35,12 @@ struct StateSerializeUtil struct FileState { - Relative32Ptr<RelativeString> uniqueIdentity; ///< The unique identity for the file (from ISlangFileSystem), or nullptr - Relative32Ptr<RelativeString> contents; ///< The contents of this file - Relative32Ptr<RelativeString> canonicalPath; ///< The canonical name of this file (or nullptr) - Relative32Ptr<RelativeString> foundPath; ///< The 'found' path + Offset32Ptr<OffsetString> uniqueIdentity; ///< The unique identity for the file (from ISlangFileSystem), or nullptr + Offset32Ptr<OffsetString> contents; ///< The contents of this file + Offset32Ptr<OffsetString> canonicalPath; ///< The canonical name of this file (or nullptr) + Offset32Ptr<OffsetString> foundPath; ///< The 'found' path - Relative32Ptr<RelativeString> uniqueName; ///< A generated unique name (not used by slang, but used as mechanism to replace files) + Offset32Ptr<OffsetString> uniqueName; ///< A generated unique name (not used by slang, but used as mechanism to replace files) }; struct PathInfoState @@ -52,19 +52,19 @@ struct StateSerializeUtil CompressedResult getPathTypeResult = CompressedResult::Uninitialized; CompressedResult getCanonicalPathResult = CompressedResult::Uninitialized; - Relative32Ptr<FileState> file; ///< File contents + Offset32Ptr<FileState> file; ///< File contents }; struct PathAndPathInfo { - Relative32Ptr<RelativeString> path; - Relative32Ptr<PathInfoState> pathInfo; + Offset32Ptr<OffsetString> path; + Offset32Ptr<PathInfoState> pathInfo; }; struct OutputState { int32_t entryPointIndex; - Relative32Ptr<RelativeString> outputPath; + Offset32Ptr<OffsetString> outputPath; }; // spSetCodeGenTarget/spAddCodeGenTarget @@ -79,20 +79,20 @@ struct StateSerializeUtil SlangTargetFlags targetFlags; FloatingPointMode floatingPointMode; - Relative32Array<OutputState> outputStates; + Offset32Array<OutputState> outputStates; }; struct StringPair { - Relative32Ptr<RelativeString> first; - Relative32Ptr<RelativeString> second; + Offset32Ptr<OffsetString> first; + Offset32Ptr<OffsetString> second; }; struct SourceFileState { PathInfo::Type type; ///< The type of this file - Relative32Ptr<RelativeString> foundPath; ///< The Path this was found along - Relative32Ptr<FileState> file; ///< The file contents + Offset32Ptr<OffsetString> foundPath; ///< The Path this was found along + Offset32Ptr<FileState> file; ///< The file contents }; // spAddTranslationUnit @@ -100,26 +100,26 @@ struct StateSerializeUtil { SourceLanguage language; - Relative32Ptr<RelativeString> moduleName; + Offset32Ptr<OffsetString> moduleName; // spTranslationUnit_addPreprocessorDefine - Relative32Array<StringPair> preprocessorDefinitions; + Offset32Array<StringPair> preprocessorDefinitions; - Relative32Array<Relative32Ptr<SourceFileState> > sourceFiles; + Offset32Array<Offset32Ptr<SourceFileState> > sourceFiles; }; struct EntryPointState { - Relative32Ptr<RelativeString> name; + Offset32Ptr<OffsetString> name; Profile profile; uint32_t translationUnitIndex; - Relative32Array<Relative32Ptr<RelativeString>> specializationArgStrings; + Offset32Array<Offset32Ptr<OffsetString>> specializationArgStrings; }; struct RequestState { - Relative32Array<Relative32Ptr<FileState>> files; ///< All of the files - Relative32Array<Relative32Ptr<SourceFileState>> sourceFiles; ///< All of the source files (from source manager) + Offset32Array<Offset32Ptr<FileState>> files; ///< All of the files + Offset32Array<Offset32Ptr<SourceFileState>> sourceFiles; ///< All of the source files (from source manager) // spSetCompileFlags SlangCompileFlags compileFlags; @@ -128,7 +128,7 @@ struct StateSerializeUtil // spSetLineDirectiveMode LineDirectiveMode lineDirectiveMode; - Relative32Array<TargetRequestState> targetRequests; + Offset32Array<TargetRequestState> targetRequests; // spSetDebugInfoLevel DebugInfoLevel debugInfoLevel; @@ -140,24 +140,24 @@ struct StateSerializeUtil PassThroughMode passThroughMode; // spAddSearchPath - Relative32Array<Relative32Ptr<RelativeString> > searchPaths; + Offset32Array<Offset32Ptr<OffsetString> > searchPaths; // spAddPreprocessorDefine - Relative32Array<StringPair> preprocessorDefinitions; + Offset32Array<StringPair> preprocessorDefinitions; bool useUnknownImageFormatAsDefault = false; bool obfuscateCode = false; - Relative32Array<PathAndPathInfo> pathInfoMap; ///< Stores all the accesses to the file system + Offset32Array<PathAndPathInfo> pathInfoMap; ///< Stores all the accesses to the file system - Relative32Array<TranslationUnitRequestState> translationUnits; + Offset32Array<TranslationUnitRequestState> translationUnits; - Relative32Array<EntryPointState> entryPoints; + Offset32Array<EntryPointState> entryPoints; SlangMatrixLayoutMode defaultMatrixLayoutMode; }; - static SlangResult store(EndToEndCompileRequest* request, RelativeContainer& inOutContainer, Safe32Ptr<RequestState>& outRequest); + static SlangResult store(EndToEndCompileRequest* request, OffsetContainer& inOutContainer, Offset32Ptr<RequestState>& outRequest); static SlangResult saveState(EndToEndCompileRequest* request, const String& filename); @@ -166,7 +166,7 @@ struct StateSerializeUtil /// Load the requestState into request /// The fileSystem is optional and can be passed as nullptr. If set, as each file is loaded /// it will attempt to load from fileSystem the *uniqueName* - static SlangResult load(RequestState* requestState, ISlangFileSystem* fileSystem, EndToEndCompileRequest* request); + static SlangResult load(OffsetBase& base, RequestState* requestState, ISlangFileSystem* fileSystem, EndToEndCompileRequest* request); static SlangResult loadState(const String& filename, List<uint8_t>& outBuffer); static SlangResult loadState(Stream* stream, List<uint8_t>& outBuffer); @@ -176,7 +176,7 @@ struct StateSerializeUtil static SlangResult extractFilesToDirectory(const String& file); - static SlangResult extractFiles(RequestState* requestState, ISlangFileSystemExt* fileSystem); + static SlangResult extractFiles(OffsetBase& base, RequestState* requestState, ISlangFileSystemExt* fileSystem); /// Given the repo file work out a suitable path static SlangResult calcDirectoryPathFromFilename(const String& filename, String& outPath); diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 8479d3202..3053b60c0 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -3465,9 +3465,12 @@ SLANG_API SlangResult spLoadRepro( List<uint8_t> buffer; SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState((const uint8_t*)data, size, buffer)); + MemoryOffsetBase base; + base.set(buffer.getBuffer(), buffer.getCount()); + StateSerializeUtil::RequestState* requestState = StateSerializeUtil::getRequest(buffer); - SLANG_RETURN_ON_FAIL(StateSerializeUtil::load(requestState, fileSystem, request)); + SLANG_RETURN_ON_FAIL(StateSerializeUtil::load(base, requestState, fileSystem, request)); return SLANG_OK; } @@ -3512,8 +3515,11 @@ SLANG_API SlangResult spExtractRepro(SlangSession* session, const void* reproDat SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(&memoryStream, buffer)); } + MemoryOffsetBase base; + base.set(buffer.getBuffer(), buffer.getCount()); + StateSerializeUtil::RequestState* requestState = StateSerializeUtil::getRequest(buffer); - return StateSerializeUtil::extractFiles(requestState, fileSystem); + return StateSerializeUtil::extractFiles(base, requestState, fileSystem); } // Reflection API |
