MCPcopy Create free account
hub / github.com/Snapchat/Valdi / loadShaderFromDisk

Method loadShaderFromDisk

valdi/src/valdi/snap_drawing/Graphics/ShaderCache.cpp:50–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50Result<BytesView> ShaderCache::loadShaderFromDisk(const BytesView& key) const {
51 auto keyFilePathResult = keyToFileName(key);
52 if (keyFilePathResult.failure()) {
53 VALDI_ERROR(_logger, "Failed to generate file name from key");
54 return keyFilePathResult.error();
55 }
56 auto keyFilePath = keyFilePathResult.moveValue();
57
58 if (!_diskCache->exists(keyFilePath)) {
59 return Error("Key not in cache");
60 }
61
62 auto loadResult = _diskCache->load(keyFilePath);
63 if (loadResult.failure()) {
64 VALDI_ERROR(_logger, "Failed to load content from {} with error {}", keyFilePath, loadResult.error());
65 return loadResult.error();
66 }
67
68 return loadResult.value();
69}
70
71void ShaderCache::storeShaderToDisk(const BytesView& key, const BytesView& data) const {
72 auto keyFilePathResult = keyToFileName(key);

Callers

nothing calls this directly

Calls 7

keyToFileNameFunction · 0.85
errorMethod · 0.65
existsMethod · 0.65
loadMethod · 0.65
valueMethod · 0.65
ErrorInterface · 0.50
failureMethod · 0.45

Tested by

no test coverage detected