diff options
| author | 2019-01-15 02:05:30 -0300 | |
|---|---|---|
| committer | 2019-02-06 22:23:39 -0300 | |
| commit | ed956569a4a56a20dc3a26d16f8920a6c63fda09 (patch) | |
| tree | 594063b3f565a3de6ce00f3d161f1c3d893141b1 /src | |
| parent | gl_shader_disk_cache: Compress GLSL code using LZ4 (diff) | |
| download | yuzu-ed956569a4a56a20dc3a26d16f8920a6c63fda09.tar.gz yuzu-ed956569a4a56a20dc3a26d16f8920a6c63fda09.tar.xz yuzu-ed956569a4a56a20dc3a26d16f8920a6c63fda09.zip | |
gl_shader_disk_cache: Compress program binaries using LZ4
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 35 |
1 files changed, 28 insertions, 7 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 bea4b29d1..f6d950b0b 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | |||
| @@ -282,9 +282,22 @@ bool ShaderDiskCacheOpenGL::LoadPrecompiled( | |||
| 282 | file.ReadBytes(&dump.binary_format, sizeof(u32)); | 282 | file.ReadBytes(&dump.binary_format, sizeof(u32)); |
| 283 | 283 | ||
| 284 | u32 binary_length{}; | 284 | u32 binary_length{}; |
| 285 | u32 compressed_size{}; | ||
| 285 | file.ReadBytes(&binary_length, sizeof(u32)); | 286 | file.ReadBytes(&binary_length, sizeof(u32)); |
| 286 | dump.binary.resize(binary_length); | 287 | file.ReadBytes(&compressed_size, sizeof(u32)); |
| 287 | file.ReadBytes(dump.binary.data(), dump.binary.size()); | 288 | |
| 289 | std::vector<u8> compressed_binary(compressed_size); | ||
| 290 | file.ReadArray(compressed_binary.data(), compressed_binary.size()); | ||
| 291 | |||
| 292 | dump.binary = DecompressData(compressed_binary, binary_length); | ||
| 293 | if (dump.binary.empty()) { | ||
| 294 | LOG_ERROR(Render_OpenGL, | ||
| 295 | "Failed to decompress precompiled binary program - removing"); | ||
| 296 | InvalidatePrecompiled(); | ||
| 297 | dumps.clear(); | ||
| 298 | decompiled.clear(); | ||
| 299 | return false; | ||
| 300 | } | ||
| 288 | 301 | ||
| 289 | dumps.insert({usage, dump}); | 302 | dumps.insert({usage, dump}); |
| 290 | break; | 303 | break; |
| @@ -418,10 +431,6 @@ void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint p | |||
| 418 | return; | 431 | return; |
| 419 | } | 432 | } |
| 420 | 433 | ||
| 421 | file.WriteObject(static_cast<u32>(PrecompiledEntryKind::Dump)); | ||
| 422 | |||
| 423 | file.WriteObject(usage); | ||
| 424 | |||
| 425 | GLint binary_length{}; | 434 | GLint binary_length{}; |
| 426 | glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &binary_length); | 435 | glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &binary_length); |
| 427 | 436 | ||
| @@ -429,9 +438,21 @@ void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint p | |||
| 429 | std::vector<u8> binary(binary_length); | 438 | std::vector<u8> binary(binary_length); |
| 430 | glGetProgramBinary(program, binary_length, nullptr, &binary_format, binary.data()); | 439 | glGetProgramBinary(program, binary_length, nullptr, &binary_format, binary.data()); |
| 431 | 440 | ||
| 441 | const std::vector<u8> compressed_binary = CompressData(binary.data(), binary.size()); | ||
| 442 | if (compressed_binary.empty()) { | ||
| 443 | LOG_ERROR(Render_OpenGL, "Failed to compress binary program in shader={:016x}", | ||
| 444 | usage.unique_identifier); | ||
| 445 | return; | ||
| 446 | } | ||
| 447 | |||
| 448 | file.WriteObject(static_cast<u32>(PrecompiledEntryKind::Dump)); | ||
| 449 | |||
| 450 | file.WriteObject(usage); | ||
| 451 | |||
| 432 | file.WriteObject(static_cast<u32>(binary_format)); | 452 | file.WriteObject(static_cast<u32>(binary_format)); |
| 433 | file.WriteObject(static_cast<u32>(binary_length)); | 453 | file.WriteObject(static_cast<u32>(binary_length)); |
| 434 | file.WriteArray(binary.data(), binary.size()); | 454 | file.WriteObject(static_cast<u32>(compressed_binary.size())); |
| 455 | file.WriteArray(compressed_binary.data(), compressed_binary.size()); | ||
| 435 | } | 456 | } |
| 436 | 457 | ||
| 437 | FileUtil::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const { | 458 | FileUtil::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const { |