diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-01-15 19:22:25 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-02-07 02:23:40 +0100 |
commit | 2bc6a699dc53baf55b0ccbb40750a40036ee184f (patch) | |
tree | f7ce68fd28c9686075ccafa463e65b27d939f787 /src/video_core/renderer_opengl/gl_shader_disk_cache.h | |
parent | gl_shader_disk_cache: Address miscellaneous feedback (diff) | |
download | yuzu-2bc6a699dc53baf55b0ccbb40750a40036ee184f.tar yuzu-2bc6a699dc53baf55b0ccbb40750a40036ee184f.tar.gz yuzu-2bc6a699dc53baf55b0ccbb40750a40036ee184f.tar.bz2 yuzu-2bc6a699dc53baf55b0ccbb40750a40036ee184f.tar.lz yuzu-2bc6a699dc53baf55b0ccbb40750a40036ee184f.tar.xz yuzu-2bc6a699dc53baf55b0ccbb40750a40036ee184f.tar.zst yuzu-2bc6a699dc53baf55b0ccbb40750a40036ee184f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.h | 30 |
1 files changed, 24 insertions, 6 deletions
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 4bffe4307..ddcd4cf51 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h @@ -53,15 +53,15 @@ struct BaseBindings { /// Describes a shader how it's used by the guest GPU class ShaderDiskCacheRaw { public: - explicit ShaderDiskCacheRaw(FileUtil::IOFile& file); - explicit ShaderDiskCacheRaw(u64 unique_identifier, Maxwell::ShaderProgram program_type, u32 program_code_size, u32 program_code_size_b, ProgramCode program_code, ProgramCode program_code_b); - + ShaderDiskCacheRaw(); ~ShaderDiskCacheRaw(); - void Save(FileUtil::IOFile& file) const; + bool Load(FileUtil::IOFile& file); + + bool Save(FileUtil::IOFile& file) const; u64 GetUniqueIdentifier() const { return unique_identifier; @@ -158,10 +158,10 @@ public: LoadPrecompiled(); /// Removes the transferable (and precompiled) cache file. - bool InvalidateTransferable() const; + void InvalidateTransferable() const; /// Removes the precompiled cache file. - bool InvalidatePrecompiled() const; + void InvalidatePrecompiled() const; /// Saves a raw dump to the transferable file. Checks for collisions. void SaveRaw(const ShaderDiskCacheRaw& entry); @@ -177,6 +177,22 @@ public: void SaveDump(const ShaderDiskCacheUsage& usage, GLuint program); private: + /// Loads the transferable cache. Returns empty on failure. + std::optional<std::pair<std::map<u64, ShaderDiskCacheDecompiled>, + std::map<ShaderDiskCacheUsage, ShaderDiskCacheDump>>> + LoadPrecompiledFile(FileUtil::IOFile& file); + + /// Loads a decompiled cache entry from the passed file. Returns empty on failure. + std::optional<ShaderDiskCacheDecompiled> LoadDecompiledEntry(FileUtil::IOFile& file); + + /// Saves a decompiled entry to the passed file. Returns true on success. + bool SaveDecompiledFile(FileUtil::IOFile& file, u64 unique_identifier, const std::string& code, + const std::vector<u8>& compressed_code, + const GLShader::ShaderEntries& entries); + + /// Returns if the cache can be used + bool IsUsable() const; + /// Opens current game's transferable file and write it's header if it doesn't exist FileUtil::IOFile AppendTransferableFile() const; @@ -203,6 +219,8 @@ private: // Stored transferable shaders std::map<u64, std::set<ShaderDiskCacheUsage>> transferable; + // The cache has been loaded at boot + bool tried_to_load{}; }; } // namespace OpenGL
\ No newline at end of file |