diff options
| author | 2019-06-24 01:58:44 -0300 | |
|---|---|---|
| committer | 2019-06-24 01:59:32 -0300 | |
| commit | 0b6df52109bc3d3d9161732131ffa29e6a51d976 (patch) | |
| tree | 3ee4675711a28b897f522fa22ed93202db182493 /src | |
| parent | gl_shader_decompiler: Address feedback (diff) | |
| download | yuzu-0b6df52109bc3d3d9161732131ffa29e6a51d976.tar.gz yuzu-0b6df52109bc3d3d9161732131ffa29e6a51d976.tar.xz yuzu-0b6df52109bc3d3d9161732131ffa29e6a51d976.zip | |
gl_shader_disk_cache: Address feedback
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_disk_cache.h | 5 |
2 files changed, 8 insertions, 4 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 922c72590..10688397b 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | |||
| @@ -285,18 +285,20 @@ std::optional<ShaderDiskCacheDecompiled> ShaderDiskCacheOpenGL::LoadDecompiledEn | |||
| 285 | if (!LoadObjectFromPrecompiled(code_size)) { | 285 | if (!LoadObjectFromPrecompiled(code_size)) { |
| 286 | return {}; | 286 | return {}; |
| 287 | } | 287 | } |
| 288 | std::vector<u8> code(code_size); | 288 | |
| 289 | std::string code(code_size, '\0'); | ||
| 289 | if (!LoadArrayFromPrecompiled(code.data(), code.size())) { | 290 | if (!LoadArrayFromPrecompiled(code.data(), code.size())) { |
| 290 | return {}; | 291 | return {}; |
| 291 | } | 292 | } |
| 292 | 293 | ||
| 293 | ShaderDiskCacheDecompiled entry; | 294 | ShaderDiskCacheDecompiled entry; |
| 294 | entry.code = std::string(reinterpret_cast<const char*>(code.data()), code_size); | 295 | entry.code = std::move(code); |
| 295 | 296 | ||
| 296 | u32 const_buffers_count{}; | 297 | u32 const_buffers_count{}; |
| 297 | if (!LoadObjectFromPrecompiled(const_buffers_count)) { | 298 | if (!LoadObjectFromPrecompiled(const_buffers_count)) { |
| 298 | return {}; | 299 | return {}; |
| 299 | } | 300 | } |
| 301 | |||
| 300 | for (u32 i = 0; i < const_buffers_count; ++i) { | 302 | for (u32 i = 0; i < const_buffers_count; ++i) { |
| 301 | u32 max_offset{}; | 303 | u32 max_offset{}; |
| 302 | u32 index{}; | 304 | u32 index{}; |
| @@ -312,6 +314,7 @@ std::optional<ShaderDiskCacheDecompiled> ShaderDiskCacheOpenGL::LoadDecompiledEn | |||
| 312 | if (!LoadObjectFromPrecompiled(samplers_count)) { | 314 | if (!LoadObjectFromPrecompiled(samplers_count)) { |
| 313 | return {}; | 315 | return {}; |
| 314 | } | 316 | } |
| 317 | |||
| 315 | for (u32 i = 0; i < samplers_count; ++i) { | 318 | for (u32 i = 0; i < samplers_count; ++i) { |
| 316 | u64 offset{}; | 319 | u64 offset{}; |
| 317 | u64 index{}; | 320 | u64 index{}; |
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 aa12ffc71..4f296dda6 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <bitset> | ||
| 7 | #include <optional> | 8 | #include <optional> |
| 8 | #include <string> | 9 | #include <string> |
| 9 | #include <tuple> | 10 | #include <tuple> |
| @@ -93,7 +94,7 @@ namespace std { | |||
| 93 | 94 | ||
| 94 | template <> | 95 | template <> |
| 95 | struct hash<OpenGL::BaseBindings> { | 96 | struct hash<OpenGL::BaseBindings> { |
| 96 | std::size_t operator()(const OpenGL::BaseBindings& bindings) const { | 97 | std::size_t operator()(const OpenGL::BaseBindings& bindings) const noexcept { |
| 97 | return static_cast<std::size_t>(bindings.cbuf) ^ | 98 | return static_cast<std::size_t>(bindings.cbuf) ^ |
| 98 | (static_cast<std::size_t>(bindings.gmem) << 8) ^ | 99 | (static_cast<std::size_t>(bindings.gmem) << 8) ^ |
| 99 | (static_cast<std::size_t>(bindings.sampler) << 16) ^ | 100 | (static_cast<std::size_t>(bindings.sampler) << 16) ^ |
| @@ -103,7 +104,7 @@ struct hash<OpenGL::BaseBindings> { | |||
| 103 | 104 | ||
| 104 | template <> | 105 | template <> |
| 105 | struct hash<OpenGL::ProgramVariant> { | 106 | struct hash<OpenGL::ProgramVariant> { |
| 106 | std::size_t operator()(const OpenGL::ProgramVariant& variant) const { | 107 | std::size_t operator()(const OpenGL::ProgramVariant& variant) const noexcept { |
| 107 | return std::hash<OpenGL::BaseBindings>()(variant.base_bindings) ^ | 108 | return std::hash<OpenGL::BaseBindings>()(variant.base_bindings) ^ |
| 108 | std::hash<OpenGL::TextureBufferUsage>()(variant.texture_buffer_usage) ^ | 109 | std::hash<OpenGL::TextureBufferUsage>()(variant.texture_buffer_usage) ^ |
| 109 | (static_cast<std::size_t>(variant.primitive_mode) << 6); | 110 | (static_cast<std::size_t>(variant.primitive_mode) << 6); |