summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.cpp39
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.h6
2 files changed, 45 insertions, 0 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 0c42e3d8a..a87bb1f9e 100644
--- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
@@ -121,6 +121,45 @@ bool ShaderDiskCacheOpenGL::LoadTransferable(std::vector<ShaderDiskCacheRaw>& ra
return true;
}
+std::vector<ShaderDiskCachePrecompiledEntry> ShaderDiskCacheOpenGL::LoadPrecompiled() {
+ FileUtil::IOFile file(GetPrecompiledPath(), "rb");
+ if (!file.IsOpen()) {
+ LOG_INFO(Render_OpenGL, "No precompiled shader cache found for game with title id={}",
+ GetTitleID());
+ return {};
+ }
+ const u64 file_size = file.GetSize();
+
+ u64 precompiled_hash{};
+ file.ReadBytes(&precompiled_hash, sizeof(precompiled_hash));
+ if (precompiled_hash != PrecompiledHash) {
+ LOG_INFO(Render_OpenGL, "Precompiled cache is from another version of yuzu - removing");
+ file.Close();
+ InvalidatePrecompiled();
+ return {};
+ }
+
+ std::vector<ShaderDiskCachePrecompiledEntry> precompiled;
+ while (file.Tell() < file_size) {
+ ShaderDiskCachePrecompiledEntry entry;
+ file.ReadBytes(&entry.usage, sizeof(entry.usage));
+
+ file.ReadBytes(&entry.binary_format, sizeof(u32));
+
+ u32 binary_length{};
+ file.ReadBytes(&binary_length, sizeof(u32));
+ entry.binary.resize(binary_length);
+ file.ReadBytes(entry.binary.data(), entry.binary.size());
+
+ precompiled.push_back(entry);
+ }
+ return precompiled;
+}
+
+void ShaderDiskCacheOpenGL::InvalidatePrecompiled() const {
+ FileUtil::Delete(GetPrecompiledPath());
+}
+
void ShaderDiskCacheOpenGL::SaveRaw(const ShaderDiskCacheRaw& entry) {
const u64 id = entry.GetUniqueIdentifier();
if (transferable.find(id) != transferable.end()) {
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 fdb29caa5..e68aea694 100644
--- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h
+++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h
@@ -144,6 +144,12 @@ public:
bool LoadTransferable(std::vector<ShaderDiskCacheRaw>& raws,
std::vector<ShaderDiskCacheUsage>& usages);
+ /// Loads current game's precompiled cache. Invalidates if emulator's version has changed.
+ std::vector<ShaderDiskCachePrecompiledEntry> LoadPrecompiled();
+
+ /// Removes the precompiled cache file.
+ void InvalidatePrecompiled() const;
+
/// Saves a raw dump to the transferable file. Checks for collisions.
void SaveRaw(const ShaderDiskCacheRaw& entry);