diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 23 |
1 files changed, 12 insertions, 11 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 52fbab3c1..40c0877c1 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | |||
| @@ -214,20 +214,20 @@ std::optional<std::vector<ShaderDiskCacheEntry>> ShaderDiskCacheOpenGL::LoadTran | |||
| 214 | // Skip games without title id | 214 | // Skip games without title id |
| 215 | const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0; | 215 | const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0; |
| 216 | if (!Settings::values.use_disk_shader_cache.GetValue() || !has_title_id) { | 216 | if (!Settings::values.use_disk_shader_cache.GetValue() || !has_title_id) { |
| 217 | return {}; | 217 | return std::nullopt; |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | Common::FS::IOFile file(GetTransferablePath(), "rb"); | 220 | Common::FS::IOFile file(GetTransferablePath(), "rb"); |
| 221 | if (!file.IsOpen()) { | 221 | if (!file.IsOpen()) { |
| 222 | LOG_INFO(Render_OpenGL, "No transferable shader cache found"); | 222 | LOG_INFO(Render_OpenGL, "No transferable shader cache found"); |
| 223 | is_usable = true; | 223 | is_usable = true; |
| 224 | return {}; | 224 | return std::nullopt; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | u32 version{}; | 227 | u32 version{}; |
| 228 | if (file.ReadBytes(&version, sizeof(version)) != sizeof(version)) { | 228 | if (file.ReadBytes(&version, sizeof(version)) != sizeof(version)) { |
| 229 | LOG_ERROR(Render_OpenGL, "Failed to get transferable cache version, skipping it"); | 229 | LOG_ERROR(Render_OpenGL, "Failed to get transferable cache version, skipping it"); |
| 230 | return {}; | 230 | return std::nullopt; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | if (version < NativeVersion) { | 233 | if (version < NativeVersion) { |
| @@ -235,12 +235,12 @@ std::optional<std::vector<ShaderDiskCacheEntry>> ShaderDiskCacheOpenGL::LoadTran | |||
| 235 | file.Close(); | 235 | file.Close(); |
| 236 | InvalidateTransferable(); | 236 | InvalidateTransferable(); |
| 237 | is_usable = true; | 237 | is_usable = true; |
| 238 | return {}; | 238 | return std::nullopt; |
| 239 | } | 239 | } |
| 240 | if (version > NativeVersion) { | 240 | if (version > NativeVersion) { |
| 241 | LOG_WARNING(Render_OpenGL, "Transferable shader cache was generated with a newer version " | 241 | LOG_WARNING(Render_OpenGL, "Transferable shader cache was generated with a newer version " |
| 242 | "of the emulator, skipping"); | 242 | "of the emulator, skipping"); |
| 243 | return {}; | 243 | return std::nullopt; |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | // Version is valid, load the shaders | 246 | // Version is valid, load the shaders |
| @@ -249,7 +249,7 @@ std::optional<std::vector<ShaderDiskCacheEntry>> ShaderDiskCacheOpenGL::LoadTran | |||
| 249 | ShaderDiskCacheEntry& entry = entries.emplace_back(); | 249 | ShaderDiskCacheEntry& entry = entries.emplace_back(); |
| 250 | if (!entry.Load(file)) { | 250 | if (!entry.Load(file)) { |
| 251 | LOG_ERROR(Render_OpenGL, "Failed to load transferable raw entry, skipping"); | 251 | LOG_ERROR(Render_OpenGL, "Failed to load transferable raw entry, skipping"); |
| 252 | return {}; | 252 | return std::nullopt; |
| 253 | } | 253 | } |
| 254 | } | 254 | } |
| 255 | 255 | ||
| @@ -290,12 +290,12 @@ std::optional<std::vector<ShaderDiskCachePrecompiled>> ShaderDiskCacheOpenGL::Lo | |||
| 290 | ShaderCacheVersionHash file_hash{}; | 290 | ShaderCacheVersionHash file_hash{}; |
| 291 | if (!LoadArrayFromPrecompiled(file_hash.data(), file_hash.size())) { | 291 | if (!LoadArrayFromPrecompiled(file_hash.data(), file_hash.size())) { |
| 292 | precompiled_cache_virtual_file_offset = 0; | 292 | precompiled_cache_virtual_file_offset = 0; |
| 293 | return {}; | 293 | return std::nullopt; |
| 294 | } | 294 | } |
| 295 | if (GetShaderCacheVersionHash() != file_hash) { | 295 | if (GetShaderCacheVersionHash() != file_hash) { |
| 296 | LOG_INFO(Render_OpenGL, "Precompiled cache is from another version of the emulator"); | 296 | LOG_INFO(Render_OpenGL, "Precompiled cache is from another version of the emulator"); |
| 297 | precompiled_cache_virtual_file_offset = 0; | 297 | precompiled_cache_virtual_file_offset = 0; |
| 298 | return {}; | 298 | return std::nullopt; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | std::vector<ShaderDiskCachePrecompiled> entries; | 301 | std::vector<ShaderDiskCachePrecompiled> entries; |
| @@ -305,15 +305,16 @@ std::optional<std::vector<ShaderDiskCachePrecompiled>> ShaderDiskCacheOpenGL::Lo | |||
| 305 | if (!LoadObjectFromPrecompiled(entry.unique_identifier) || | 305 | if (!LoadObjectFromPrecompiled(entry.unique_identifier) || |
| 306 | !LoadObjectFromPrecompiled(entry.binary_format) || | 306 | !LoadObjectFromPrecompiled(entry.binary_format) || |
| 307 | !LoadObjectFromPrecompiled(binary_size)) { | 307 | !LoadObjectFromPrecompiled(binary_size)) { |
| 308 | return {}; | 308 | return std::nullopt; |
| 309 | } | 309 | } |
| 310 | 310 | ||
| 311 | entry.binary.resize(binary_size); | 311 | entry.binary.resize(binary_size); |
| 312 | if (!LoadArrayFromPrecompiled(entry.binary.data(), entry.binary.size())) { | 312 | if (!LoadArrayFromPrecompiled(entry.binary.data(), entry.binary.size())) { |
| 313 | return {}; | 313 | return std::nullopt; |
| 314 | } | 314 | } |
| 315 | } | 315 | } |
| 316 | return entries; | 316 | |
| 317 | return std::move(entries); | ||
| 317 | } | 318 | } |
| 318 | 319 | ||
| 319 | void ShaderDiskCacheOpenGL::InvalidateTransferable() { | 320 | void ShaderDiskCacheOpenGL::InvalidateTransferable() { |