From 0b6df52109bc3d3d9161732131ffa29e6a51d976 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 24 Jun 2019 01:58:44 -0300 Subject: gl_shader_disk_cache: Address feedback --- src/video_core/renderer_opengl/gl_shader_disk_cache.cpp | 7 +++++-- src/video_core/renderer_opengl/gl_shader_disk_cache.h | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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 ShaderDiskCacheOpenGL::LoadDecompiledEn if (!LoadObjectFromPrecompiled(code_size)) { return {}; } - std::vector code(code_size); + + std::string code(code_size, '\0'); if (!LoadArrayFromPrecompiled(code.data(), code.size())) { return {}; } ShaderDiskCacheDecompiled entry; - entry.code = std::string(reinterpret_cast(code.data()), code_size); + entry.code = std::move(code); u32 const_buffers_count{}; if (!LoadObjectFromPrecompiled(const_buffers_count)) { return {}; } + for (u32 i = 0; i < const_buffers_count; ++i) { u32 max_offset{}; u32 index{}; @@ -312,6 +314,7 @@ std::optional ShaderDiskCacheOpenGL::LoadDecompiledEn if (!LoadObjectFromPrecompiled(samplers_count)) { return {}; } + for (u32 i = 0; i < samplers_count; ++i) { u64 offset{}; 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 @@ #pragma once +#include #include #include #include @@ -93,7 +94,7 @@ namespace std { template <> struct hash { - std::size_t operator()(const OpenGL::BaseBindings& bindings) const { + std::size_t operator()(const OpenGL::BaseBindings& bindings) const noexcept { return static_cast(bindings.cbuf) ^ (static_cast(bindings.gmem) << 8) ^ (static_cast(bindings.sampler) << 16) ^ @@ -103,7 +104,7 @@ struct hash { template <> struct hash { - std::size_t operator()(const OpenGL::ProgramVariant& variant) const { + std::size_t operator()(const OpenGL::ProgramVariant& variant) const noexcept { return std::hash()(variant.base_bindings) ^ std::hash()(variant.texture_buffer_usage) ^ (static_cast(variant.primitive_mode) << 6); -- cgit v1.2.3