summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-08-23 08:19:00 +0200
committerGitHub <noreply@github.com>2018-08-23 08:19:00 +0200
commitc7f2fb2151a5cff3e7626a0ec3cb75c553f41aef (patch)
treec09b3962a8fb306a40f474cac005e5b5316eb654 /src/video_core/renderer_opengl
parentMerge pull request #1156 from Lakumakkara/lop3 (diff)
parentgl_shader_gen: Make ShaderSetup's constructor explicit (diff)
downloadyuzu-c7f2fb2151a5cff3e7626a0ec3cb75c553f41aef.tar
yuzu-c7f2fb2151a5cff3e7626a0ec3cb75c553f41aef.tar.gz
yuzu-c7f2fb2151a5cff3e7626a0ec3cb75c553f41aef.tar.bz2
yuzu-c7f2fb2151a5cff3e7626a0ec3cb75c553f41aef.tar.lz
yuzu-c7f2fb2151a5cff3e7626a0ec3cb75c553f41aef.tar.xz
yuzu-c7f2fb2151a5cff3e7626a0ec3cb75c553f41aef.tar.zst
yuzu-c7f2fb2151a5cff3e7626a0ec3cb75c553f41aef.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.h25
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
auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
// Fetch program code from memory
- GLShader::ProgramCode program_code;
+ GLShader::ProgramCode program_code(GLShader::MAX_PROGRAM_CODE_LENGTH);
auto& shader_config = gpu.regs.shader_config[static_cast<size_t>(program)];
const u64 gpu_address{gpu.regs.code_address.CodeAddress() + shader_config.offset};
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 @@
#include <type_traits>
#include <utility>
#include <vector>
+#include <boost/functional/hash.hpp>
#include "common/common_types.h"
#include "common/hash.h"
namespace OpenGL::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;
+ explicit 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{};