diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 28 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.h | 5 |
2 files changed, 17 insertions, 16 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 6a7012b54..74cc33476 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | |||
| @@ -112,14 +112,15 @@ std::optional<std::pair<std::vector<ShaderDiskCacheRaw>, std::vector<ShaderDiskC | |||
| 112 | ShaderDiskCacheOpenGL::LoadTransferable() { | 112 | ShaderDiskCacheOpenGL::LoadTransferable() { |
| 113 | // Skip games without title id | 113 | // Skip games without title id |
| 114 | const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0; | 114 | const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0; |
| 115 | if (!Settings::values.use_disk_shader_cache || !has_title_id) | 115 | if (!Settings::values.use_disk_shader_cache || !has_title_id) { |
| 116 | return {}; | 116 | return {}; |
| 117 | tried_to_load = true; | 117 | } |
| 118 | 118 | ||
| 119 | FileUtil::IOFile file(GetTransferablePath(), "rb"); | 119 | FileUtil::IOFile file(GetTransferablePath(), "rb"); |
| 120 | if (!file.IsOpen()) { | 120 | if (!file.IsOpen()) { |
| 121 | LOG_INFO(Render_OpenGL, "No transferable shader cache found for game with title id={}", | 121 | LOG_INFO(Render_OpenGL, "No transferable shader cache found for game with title id={}", |
| 122 | GetTitleID()); | 122 | GetTitleID()); |
| 123 | is_usable = true; | ||
| 123 | return {}; | 124 | return {}; |
| 124 | } | 125 | } |
| 125 | 126 | ||
| @@ -135,6 +136,7 @@ ShaderDiskCacheOpenGL::LoadTransferable() { | |||
| 135 | LOG_INFO(Render_OpenGL, "Transferable shader cache is old - removing"); | 136 | LOG_INFO(Render_OpenGL, "Transferable shader cache is old - removing"); |
| 136 | file.Close(); | 137 | file.Close(); |
| 137 | InvalidateTransferable(); | 138 | InvalidateTransferable(); |
| 139 | is_usable = true; | ||
| 138 | return {}; | 140 | return {}; |
| 139 | } | 141 | } |
| 140 | if (version > NativeVersion) { | 142 | if (version > NativeVersion) { |
| @@ -180,13 +182,15 @@ ShaderDiskCacheOpenGL::LoadTransferable() { | |||
| 180 | } | 182 | } |
| 181 | } | 183 | } |
| 182 | 184 | ||
| 183 | return {{raws, usages}}; | 185 | is_usable = true; |
| 186 | return {{std::move(raws), std::move(usages)}}; | ||
| 184 | } | 187 | } |
| 185 | 188 | ||
| 186 | std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap> | 189 | std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap> |
| 187 | ShaderDiskCacheOpenGL::LoadPrecompiled() { | 190 | ShaderDiskCacheOpenGL::LoadPrecompiled() { |
| 188 | if (!IsUsable()) | 191 | if (!is_usable) { |
| 189 | return {}; | 192 | return {}; |
| 193 | } | ||
| 190 | 194 | ||
| 191 | FileUtil::IOFile file(GetPrecompiledPath(), "rb"); | 195 | FileUtil::IOFile file(GetPrecompiledPath(), "rb"); |
| 192 | if (!file.IsOpen()) { | 196 | if (!file.IsOpen()) { |
| @@ -479,8 +483,9 @@ void ShaderDiskCacheOpenGL::InvalidatePrecompiled() { | |||
| 479 | } | 483 | } |
| 480 | 484 | ||
| 481 | void ShaderDiskCacheOpenGL::SaveRaw(const ShaderDiskCacheRaw& entry) { | 485 | void ShaderDiskCacheOpenGL::SaveRaw(const ShaderDiskCacheRaw& entry) { |
| 482 | if (!IsUsable()) | 486 | if (!is_usable) { |
| 483 | return; | 487 | return; |
| 488 | } | ||
| 484 | 489 | ||
| 485 | const u64 id = entry.GetUniqueIdentifier(); | 490 | const u64 id = entry.GetUniqueIdentifier(); |
| 486 | if (transferable.find(id) != transferable.end()) { | 491 | if (transferable.find(id) != transferable.end()) { |
| @@ -501,8 +506,9 @@ void ShaderDiskCacheOpenGL::SaveRaw(const ShaderDiskCacheRaw& entry) { | |||
| 501 | } | 506 | } |
| 502 | 507 | ||
| 503 | void ShaderDiskCacheOpenGL::SaveUsage(const ShaderDiskCacheUsage& usage) { | 508 | void ShaderDiskCacheOpenGL::SaveUsage(const ShaderDiskCacheUsage& usage) { |
| 504 | if (!IsUsable()) | 509 | if (!is_usable) { |
| 505 | return; | 510 | return; |
| 511 | } | ||
| 506 | 512 | ||
| 507 | const auto it = transferable.find(usage.unique_identifier); | 513 | const auto it = transferable.find(usage.unique_identifier); |
| 508 | ASSERT_MSG(it != transferable.end(), "Saving shader usage without storing raw previously"); | 514 | ASSERT_MSG(it != transferable.end(), "Saving shader usage without storing raw previously"); |
| @@ -528,8 +534,9 @@ void ShaderDiskCacheOpenGL::SaveUsage(const ShaderDiskCacheUsage& usage) { | |||
| 528 | 534 | ||
| 529 | void ShaderDiskCacheOpenGL::SaveDecompiled(u64 unique_identifier, const std::string& code, | 535 | void ShaderDiskCacheOpenGL::SaveDecompiled(u64 unique_identifier, const std::string& code, |
| 530 | const GLShader::ShaderEntries& entries) { | 536 | const GLShader::ShaderEntries& entries) { |
| 531 | if (!IsUsable()) | 537 | if (!is_usable) { |
| 532 | return; | 538 | return; |
| 539 | } | ||
| 533 | 540 | ||
| 534 | if (precompiled_cache_virtual_file.GetSize() == 0) { | 541 | if (precompiled_cache_virtual_file.GetSize() == 0) { |
| 535 | SavePrecompiledHeaderToVirtualPrecompiledCache(); | 542 | SavePrecompiledHeaderToVirtualPrecompiledCache(); |
| @@ -543,8 +550,9 @@ void ShaderDiskCacheOpenGL::SaveDecompiled(u64 unique_identifier, const std::str | |||
| 543 | } | 550 | } |
| 544 | 551 | ||
| 545 | void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint program) { | 552 | void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint program) { |
| 546 | if (!IsUsable()) | 553 | if (!is_usable) { |
| 547 | return; | 554 | return; |
| 555 | } | ||
| 548 | 556 | ||
| 549 | GLint binary_length{}; | 557 | GLint binary_length{}; |
| 550 | glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &binary_length); | 558 | glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &binary_length); |
| @@ -565,10 +573,6 @@ void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint p | |||
| 565 | } | 573 | } |
| 566 | } | 574 | } |
| 567 | 575 | ||
| 568 | bool ShaderDiskCacheOpenGL::IsUsable() const { | ||
| 569 | return tried_to_load && Settings::values.use_disk_shader_cache; | ||
| 570 | } | ||
| 571 | |||
| 572 | FileUtil::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const { | 576 | FileUtil::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const { |
| 573 | if (!EnsureDirectories()) | 577 | if (!EnsureDirectories()) |
| 574 | return {}; | 578 | return {}; |
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.h b/src/video_core/renderer_opengl/gl_shader_disk_cache.h index cc8bbd61e..9595bd71b 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h | |||
| @@ -224,9 +224,6 @@ private: | |||
| 224 | bool SaveDecompiledFile(u64 unique_identifier, const std::string& code, | 224 | bool SaveDecompiledFile(u64 unique_identifier, const std::string& code, |
| 225 | const GLShader::ShaderEntries& entries); | 225 | const GLShader::ShaderEntries& entries); |
| 226 | 226 | ||
| 227 | /// Returns if the cache can be used | ||
| 228 | bool IsUsable() const; | ||
| 229 | |||
| 230 | /// Opens current game's transferable file and write it's header if it doesn't exist | 227 | /// Opens current game's transferable file and write it's header if it doesn't exist |
| 231 | FileUtil::IOFile AppendTransferableFile() const; | 228 | FileUtil::IOFile AppendTransferableFile() const; |
| 232 | 229 | ||
| @@ -297,7 +294,7 @@ private: | |||
| 297 | std::unordered_map<u64, std::unordered_set<ShaderDiskCacheUsage>> transferable; | 294 | std::unordered_map<u64, std::unordered_set<ShaderDiskCacheUsage>> transferable; |
| 298 | 295 | ||
| 299 | // The cache has been loaded at boot | 296 | // The cache has been loaded at boot |
| 300 | bool tried_to_load{}; | 297 | bool is_usable{}; |
| 301 | }; | 298 | }; |
| 302 | 299 | ||
| 303 | } // namespace OpenGL | 300 | } // namespace OpenGL |