| 69 | } |
| 70 | |
| 71 | void ShaderCache::storeShaderToDisk(const BytesView& key, const BytesView& data) const { |
| 72 | auto keyFilePathResult = keyToFileName(key); |
| 73 | if (keyFilePathResult.failure()) { |
| 74 | VALDI_ERROR(_logger, "Failed to generate file name from key"); |
| 75 | return; |
| 76 | } |
| 77 | auto keyFilePath = keyFilePathResult.moveValue(); |
| 78 | if (_diskCache->exists(keyFilePath)) { |
| 79 | VALDI_WARN(_logger, "Overwriting shader item for {}", keyFilePath); |
| 80 | } |
| 81 | |
| 82 | auto storeResult = _diskCache->store(keyFilePath, data); |
| 83 | if (storeResult.failure()) { |
| 84 | VALDI_ERROR(_logger, "Failed to store content for {} with error {}", keyFilePath, storeResult.error()); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | ShaderCache::ShaderCache(const Ref<IDiskCache>& diskCache, const Ref<DispatchQueue>& dispatchQueue, ILogger& logger) |
| 89 | : _logger(logger), |