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

Method writeCache

Source/Falcor/Scene/SceneCache.cpp:233–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231 }
232
233 void SceneCache::writeCache(const Scene::SceneData& sceneData, const Key& key)
234 {
235 auto cachePath = getCachePath(key);
236
237 logInfo("Writing scene cache to '{}'.", cachePath);
238
239 // Create directories if not existing.
240 std::filesystem::create_directories(cachePath.parent_path());
241
242 // Open file.
243 std::ofstream fs(cachePath.c_str(), std::ios_base::binary);
244 if (fs.bad()) FALCOR_THROW("Failed to create scene cache file '{}'.", cachePath);
245
246 // Write header (uncompressed).
247 Header header;
248 std::memcpy(header.magic, kMagic, sizeof(Header::magic));
249 header.version = kVersion;
250 fs.write(reinterpret_cast<const char*>(&header), sizeof(header));
251
252 // Write cache (compressed).
253 lz4_stream::basic_ostream<kBlockSize> zs(fs);
254 OutputStream stream(zs);
255 writeSceneData(stream, sceneData);
256 if (fs.bad()) FALCOR_THROW("Failed to write scene cache file to '{}'.", cachePath);
257 }
258
259 Scene::SceneData SceneCache::readCache(ref<Device> pDevice, const Key& key)
260 {

Callers

nothing calls this directly

Calls 2

logInfoFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected