From e283de9b6d718948c62f74b56467d01db9b8a702 Mon Sep 17 00:00:00 2001 From: SachinVin <26602104+SachinVin@users.noreply.github.com> Date: Mon, 10 Apr 2023 00:46:44 +0530 Subject: [PATCH] gl_shader_disk_cache.cpp: Invalidate Tranferable cache on error (#6392) --- .../renderer_opengl/gl_shader_disk_cache.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index fbbb88b70..53712a112 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp @@ -126,8 +126,9 @@ std::optional> ShaderDiskCache::LoadTransferable u32 version{}; if (transferable_file.ReadBytes(&version, sizeof(version)) != sizeof(version)) { LOG_ERROR(Render_OpenGL, - "Failed to get transferable cache version for title id={} - skipping", + "Failed to get transferable cache version for title id={} - removing", GetTitleID()); + InvalidateAll(); return std::nullopt; } @@ -147,7 +148,8 @@ std::optional> ShaderDiskCache::LoadTransferable while (transferable_file.Tell() < transferable_file.GetSize()) { TransferableEntryKind kind{}; if (transferable_file.ReadBytes(&kind, sizeof(u32)) != sizeof(u32)) { - LOG_ERROR(Render_OpenGL, "Failed to read transferable file - skipping"); + LOG_ERROR(Render_OpenGL, "Failed to read transferable file - removing"); + InvalidateAll(); return std::nullopt; } @@ -155,7 +157,8 @@ std::optional> ShaderDiskCache::LoadTransferable case TransferableEntryKind::Raw: { ShaderDiskCacheRaw entry; if (!entry.Load(transferable_file)) { - LOG_ERROR(Render_OpenGL, "Failed to load transferable raw entry - skipping"); + LOG_ERROR(Render_OpenGL, "Failed to load transferable raw entry - removing"); + InvalidateAll(); return std::nullopt; } transferable.emplace(entry.GetUniqueIdentifier(), ShaderDiskCacheRaw{}); @@ -163,8 +166,9 @@ std::optional> ShaderDiskCache::LoadTransferable break; } default: - LOG_ERROR(Render_OpenGL, "Unknown transferable shader cache entry kind={} - skipping", + LOG_ERROR(Render_OpenGL, "Unknown transferable shader cache entry kind={} - removing", kind); + InvalidateAll(); return std::nullopt; } } @@ -516,6 +520,8 @@ void ShaderDiskCache::SaveVirtualPrecompiledFile() { precompiled_path); return; } + + precompiled_file.Flush(); } bool ShaderDiskCache::EnsureDirectories() const {