MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / readCache

Method readCache

Source/Falcor/Scene/SceneCache.cpp:259–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257 }
258
259 Scene::SceneData SceneCache::readCache(ref<Device> pDevice, const Key& key)
260 {
261 auto cachePath = getCachePath(key);
262
263 logInfo("Loading scene cache from '{}'.", cachePath);
264
265 // Open file.
266 std::ifstream fs(cachePath.c_str(), std::ios_base::binary);
267 if (fs.bad()) FALCOR_THROW("Failed to open scene cache file '{}'.", cachePath);
268
269 // Read header (uncompressed).
270 Header header;
271 fs.read(reinterpret_cast<char*>(&header), sizeof(header));
272 if (!header.isValid()) FALCOR_THROW("Invalid header in scene cache file '{}'.", cachePath);
273
274 // Read cache (compressed).
275 lz4_stream::basic_istream<kBlockSize, kBlockSize> zs(fs);
276 InputStream stream(zs);
277 auto sceneData = readSceneData(stream, pDevice);
278 if (fs.bad()) FALCOR_THROW("Failed to read scene cache file from '{}'.", cachePath);
279 return sceneData;
280 }
281
282 std::filesystem::path SceneCache::getCachePath(const Key& key)
283 {

Callers

nothing calls this directly

Calls 3

logInfoFunction · 0.85
readMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected