diff options
author | Lioncash <mathew1800@gmail.com> | 2018-08-22 21:43:52 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-08-22 23:04:44 +0200 |
commit | 1fd979f50a9f4c21fa8cafba7268d959e3076924 (patch) | |
tree | 8a46d4c11a65340b316f5bb8d1f895410f3636af /src/video_core/renderer_opengl/gl_shader_gen.h | |
parent | Merge pull request #1155 from tech4me/icon-fix (diff) | |
download | yuzu-1fd979f50a9f4c21fa8cafba7268d959e3076924.tar yuzu-1fd979f50a9f4c21fa8cafba7268d959e3076924.tar.gz yuzu-1fd979f50a9f4c21fa8cafba7268d959e3076924.tar.bz2 yuzu-1fd979f50a9f4c21fa8cafba7268d959e3076924.tar.lz yuzu-1fd979f50a9f4c21fa8cafba7268d959e3076924.tar.xz yuzu-1fd979f50a9f4c21fa8cafba7268d959e3076924.tar.zst yuzu-1fd979f50a9f4c21fa8cafba7268d959e3076924.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.h | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 4729ce0fc..6a1dab0e5 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.h +++ b/src/video_core/renderer_opengl/gl_shader_gen.h @@ -9,14 +9,14 @@ #include <type_traits> #include <utility> #include <vector> +#include <boost/functional/hash.hpp> #include "common/common_types.h" #include "common/hash.h" namespace GLShader { constexpr size_t MAX_PROGRAM_CODE_LENGTH{0x1000}; - -using ProgramCode = std::array<u64, MAX_PROGRAM_CODE_LENGTH>; +using ProgramCode = std::vector<u64>; class ConstBufferEntry { using Maxwell = Tegra::Engines::Maxwell3D::Regs; @@ -115,8 +115,8 @@ struct ShaderEntries { using ProgramResult = std::pair<std::string, ShaderEntries>; struct ShaderSetup { - ShaderSetup(const ProgramCode& program_code) { - program.code = program_code; + ShaderSetup(ProgramCode program_code) { + program.code = std::move(program_code); } struct { @@ -135,8 +135,8 @@ struct ShaderSetup { } /// Used in scenarios where we have a dual vertex shaders - void SetProgramB(const ProgramCode& program_b) { - program.code_b = program_b; + void SetProgramB(ProgramCode program_b) { + program.code_b = std::move(program_b); has_program_b = true; } @@ -146,13 +146,18 @@ struct ShaderSetup { private: u64 GetNewHash() const { + size_t hash = 0; + + const u64 hash_a = Common::ComputeHash64(program.code.data(), program.code.size()); + boost::hash_combine(hash, hash_a); + if (has_program_b) { // Compute hash over dual shader programs - return Common::ComputeHash64(&program, sizeof(program)); - } else { - // Compute hash over a single shader program - return Common::ComputeHash64(&program.code, program.code.size()); + const u64 hash_b = Common::ComputeHash64(program.code_b.data(), program.code_b.size()); + boost::hash_combine(hash, hash_b); } + + return hash; } u64 program_code_hash{}; |