diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.h | 25 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index c67eabe65..516e1b50f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -181,7 +181,7 @@ static GLShader::ProgramCode GetShaderProgramCode(Maxwell::ShaderProgram program | |||
| 181 | auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | 181 | auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); |
| 182 | 182 | ||
| 183 | // Fetch program code from memory | 183 | // Fetch program code from memory |
| 184 | GLShader::ProgramCode program_code; | 184 | GLShader::ProgramCode program_code(GLShader::MAX_PROGRAM_CODE_LENGTH); |
| 185 | auto& shader_config = gpu.regs.shader_config[static_cast<size_t>(program)]; | 185 | auto& shader_config = gpu.regs.shader_config[static_cast<size_t>(program)]; |
| 186 | const u64 gpu_address{gpu.regs.code_address.CodeAddress() + shader_config.offset}; | 186 | const u64 gpu_address{gpu.regs.code_address.CodeAddress() + shader_config.offset}; |
| 187 | const boost::optional<VAddr> cpu_address{gpu.memory_manager.GpuToCpuAddress(gpu_address)}; | 187 | const boost::optional<VAddr> cpu_address{gpu.memory_manager.GpuToCpuAddress(gpu_address)}; |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 2c636b7f3..4e5a6f130 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 @@ | |||
| 9 | #include <type_traits> | 9 | #include <type_traits> |
| 10 | #include <utility> | 10 | #include <utility> |
| 11 | #include <vector> | 11 | #include <vector> |
| 12 | #include <boost/functional/hash.hpp> | ||
| 12 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 13 | #include "common/hash.h" | 14 | #include "common/hash.h" |
| 14 | 15 | ||
| 15 | namespace OpenGL::GLShader { | 16 | namespace OpenGL::GLShader { |
| 16 | 17 | ||
| 17 | constexpr size_t MAX_PROGRAM_CODE_LENGTH{0x1000}; | 18 | constexpr size_t MAX_PROGRAM_CODE_LENGTH{0x1000}; |
| 18 | 19 | using ProgramCode = std::vector<u64>; | |
| 19 | using ProgramCode = std::array<u64, MAX_PROGRAM_CODE_LENGTH>; | ||
| 20 | 20 | ||
| 21 | class ConstBufferEntry { | 21 | class ConstBufferEntry { |
| 22 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | 22 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; |
| @@ -115,8 +115,8 @@ struct ShaderEntries { | |||
| 115 | using ProgramResult = std::pair<std::string, ShaderEntries>; | 115 | using ProgramResult = std::pair<std::string, ShaderEntries>; |
| 116 | 116 | ||
| 117 | struct ShaderSetup { | 117 | struct ShaderSetup { |
| 118 | ShaderSetup(const ProgramCode& program_code) { | 118 | explicit ShaderSetup(ProgramCode program_code) { |
| 119 | program.code = program_code; | 119 | program.code = std::move(program_code); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | struct { | 122 | struct { |
| @@ -135,8 +135,8 @@ struct ShaderSetup { | |||
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | /// Used in scenarios where we have a dual vertex shaders | 137 | /// Used in scenarios where we have a dual vertex shaders |
| 138 | void SetProgramB(const ProgramCode& program_b) { | 138 | void SetProgramB(ProgramCode program_b) { |
| 139 | program.code_b = program_b; | 139 | program.code_b = std::move(program_b); |
| 140 | has_program_b = true; | 140 | has_program_b = true; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| @@ -146,13 +146,18 @@ struct ShaderSetup { | |||
| 146 | 146 | ||
| 147 | private: | 147 | private: |
| 148 | u64 GetNewHash() const { | 148 | u64 GetNewHash() const { |
| 149 | size_t hash = 0; | ||
| 150 | |||
| 151 | const u64 hash_a = Common::ComputeHash64(program.code.data(), program.code.size()); | ||
| 152 | boost::hash_combine(hash, hash_a); | ||
| 153 | |||
| 149 | if (has_program_b) { | 154 | if (has_program_b) { |
| 150 | // Compute hash over dual shader programs | 155 | // Compute hash over dual shader programs |
| 151 | return Common::ComputeHash64(&program, sizeof(program)); | 156 | const u64 hash_b = Common::ComputeHash64(program.code_b.data(), program.code_b.size()); |
| 152 | } else { | 157 | boost::hash_combine(hash, hash_b); |
| 153 | // Compute hash over a single shader program | ||
| 154 | return Common::ComputeHash64(&program.code, program.code.size()); | ||
| 155 | } | 158 | } |
| 159 | |||
| 160 | return hash; | ||
| 156 | } | 161 | } |
| 157 | 162 | ||
| 158 | u64 program_code_hash{}; | 163 | u64 program_code_hash{}; |