| 48 | } |
| 49 | |
| 50 | Result<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 | |
| 71 | void ShaderCache::storeShaderToDisk(const BytesView& key, const BytesView& data) const { |
| 72 | auto keyFilePathResult = keyToFileName(key); |