summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorunknown <FreddyFunk@users.noreply.github.com>2019-02-10 16:38:34 +0100
committerFreddyFunk <FreddyFunk@users.noreply.github.com>2019-04-23 22:24:31 +0200
commit3091b40691d767161c0265bab4bddb6687e3698d (patch)
tree666759e8e32f39543f2f5928efc47abe5f784d5c
parentgl_shader_disk_cache: Use VectorVfsFile for the virtual precompiled shader cache file (diff)
downloadyuzu-3091b40691d767161c0265bab4bddb6687e3698d.tar
yuzu-3091b40691d767161c0265bab4bddb6687e3698d.tar.gz
yuzu-3091b40691d767161c0265bab4bddb6687e3698d.tar.bz2
yuzu-3091b40691d767161c0265bab4bddb6687e3698d.tar.lz
yuzu-3091b40691d767161c0265bab4bddb6687e3698d.tar.xz
yuzu-3091b40691d767161c0265bab4bddb6687e3698d.tar.zst
yuzu-3091b40691d767161c0265bab4bddb6687e3698d.zip
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.cpp16
1 files changed, 10 insertions, 6 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 4c76f943f..3c39e5c8c 100644
--- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
@@ -11,6 +11,7 @@
#include "common/file_util.h"
#include "common/logging/log.h"
#include "common/scm_rev.h"
+#include "common/zstd_compression.h"
#include "core/core.h"
#include "core/hle/kernel/process.h"
@@ -209,9 +210,11 @@ ShaderDiskCacheOpenGL::LoadPrecompiled() {
std::optional<std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>,
std::unordered_map<ShaderDiskCacheUsage, ShaderDiskCacheDump>>>
ShaderDiskCacheOpenGL::LoadPrecompiledFile(FileUtil::IOFile& file) {
- std::vector<u8> precompiled_cache(file.GetSize());
- file.ReadBytes(precompiled_cache.data(), precompiled_cache.size());
- SaveArrayToPrecompiled(precompiled_cache.data(), precompiled_cache.size());
+ // Read compressed file from disk and decompress to virtual precompiled cache file
+ std::vector<u8> compressed(file.GetSize());
+ file.ReadBytes(compressed.data(), compressed.size());
+ const std::vector<u8> decompressed = Common::Compression::DecompressDataZSTD(compressed);
+ SaveArrayToPrecompiled(decompressed.data(), decompressed.size());
precompiled_cache_virtual_file_offset = 0;
ShaderCacheVersionHash file_hash{};
@@ -564,7 +567,9 @@ void ShaderDiskCacheOpenGL::SavePrecompiledHeaderToVirtualPrecompiledCache() {
void ShaderDiskCacheOpenGL::SaveVirtualPrecompiledFile() {
precompiled_cache_virtual_file_offset = 0;
- const std::vector<u8>& precompiled_cache = precompiled_cache_virtual_file.ReadAllBytes();
+ const std::vector<u8>& uncompressed = precompiled_cache_virtual_file.ReadAllBytes();
+ const std::vector<u8>& compressed =
+ Common::Compression::CompressDataZSTDDefault(uncompressed.data(), uncompressed.size());
const auto precompiled_path{GetPrecompiledPath()};
FileUtil::IOFile file(precompiled_path, "wb");
@@ -573,8 +578,7 @@ void ShaderDiskCacheOpenGL::SaveVirtualPrecompiledFile() {
LOG_ERROR(Render_OpenGL, "Failed to open precompiled cache in path={}", precompiled_path);
return;
}
- if (file.WriteBytes(precompiled_cache.data(), precompiled_cache.size()) !=
- precompiled_cache.size()) {
+ if (file.WriteBytes(compressed.data(), compressed.size()) != compressed.size()) {
LOG_ERROR(Render_OpenGL, "Failed to write precompiled cache version in path={}",
precompiled_path);
return;