From 4c76b275907cf2d764f3fc51468d1c58635a10c1 Mon Sep 17 00:00:00 2001 From: Theresa Foley <10618364+tangent-vector@users.noreply.github.com> Date: Mon, 12 May 2025 10:28:05 -0700 Subject: Cleanups related to RIFF support (#7041) --- source/slang/slang-module-library.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'source/slang/slang-module-library.cpp') diff --git a/source/slang/slang-module-library.cpp b/source/slang/slang-module-library.cpp index c03d5c2dd..c3f4a1349 100644 --- a/source/slang/slang-module-library.cpp +++ b/source/slang/slang-module-library.cpp @@ -39,8 +39,8 @@ void* ModuleLibrary::castAs(const Guid& guid) } SlangResult loadModuleLibrary( - const Byte* inBytes, - size_t bytesCount, + const Byte* inData, + size_t dataSize, String path, EndToEndCompileRequest* req, ComPtr& outLibrary) @@ -51,32 +51,38 @@ SlangResult loadModuleLibrary( ComPtr scopeLibrary(library); // Load up the module - MemoryStreamBase memoryStream(FileAccess::Read, inBytes, bytesCount); - - RiffContainer riffContainer; - SLANG_RETURN_ON_FAIL(RiffUtil::read(&memoryStream, riffContainer)); + auto rootChunk = RIFF::RootChunk::getFromBlob(inData, dataSize); + if (!rootChunk) + { + return SLANG_FAIL; + } auto linkage = req->getLinkage(); auto sink = req->getSink(); auto namePool = req->getNamePool(); - auto container = ContainerChunkRef::find(&riffContainer); + auto container = ContainerChunk::find(rootChunk); + if (!container) + { + return SLANG_FAIL; + } - for (auto moduleChunk : container.getModules()) + for (auto moduleChunk : container->getModules()) { - auto loadedModule = linkage->findOrLoadSerializedModuleForModuleLibrary(moduleChunk, sink); + auto loadedModule = + linkage->findOrLoadSerializedModuleForModuleLibrary(moduleChunk, container, sink); if (!loadedModule) return SLANG_FAIL; library->m_modules.add(loadedModule); } - for (auto entryPointChunk : container.getEntryPoints()) + for (auto entryPointChunk : container->getEntryPoints()) { FrontEndCompileRequest::ExtraEntryPointInfo entryPointInfo; - entryPointInfo.mangledName = entryPointChunk.getMangledName(); - entryPointInfo.name = namePool->getName(entryPointChunk.getName()); - entryPointInfo.profile = entryPointChunk.getProfile(); + entryPointInfo.mangledName = entryPointChunk->getMangledName(); + entryPointInfo.name = namePool->getName(entryPointChunk->getName()); + entryPointInfo.profile = entryPointChunk->getProfile(); library->m_entryPoints.add(entryPointInfo); } -- cgit v1.2.3