summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-12-01 23:48:55 -0500
committerGravatar GitHub2018-12-01 23:48:55 -0500
commit80aa124b1d9da66148ea8d00e563ca7337182e68 (patch)
tree529861d7ee3e480eaf86cb83250236a6230659b6 /src
parentMerge pull request #1795 from ReinUsesLisp/vc-cleanup (diff)
parentgl_shader_manager: Update pipeline when programs have changed (diff)
downloadyuzu-80aa124b1d9da66148ea8d00e563ca7337182e68.tar.gz
yuzu-80aa124b1d9da66148ea8d00e563ca7337182e68.tar.xz
yuzu-80aa124b1d9da66148ea8d00e563ca7337182e68.zip
Merge pull request #1825 from ReinUsesLisp/shader-pipeline-cache
gl_shader_manager: Update pipeline when programs have changed
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_manager.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_manager.h b/src/video_core/renderer_opengl/gl_shader_manager.h
index b757f5f44..4970aafed 100644
--- a/src/video_core/renderer_opengl/gl_shader_manager.h
+++ b/src/video_core/renderer_opengl/gl_shader_manager.h
@@ -60,6 +60,17 @@ public:
60 } 60 }
61 61
62 void ApplyTo(OpenGLState& state) { 62 void ApplyTo(OpenGLState& state) {
63 UpdatePipeline();
64 state.draw.shader_program = 0;
65 state.draw.program_pipeline = pipeline.handle;
66 state.geometry_shaders.enabled = (gs != 0);
67 }
68
69private:
70 void UpdatePipeline() {
71 // Avoid updating the pipeline when values have no changed
72 if (old_vs == vs && old_fs == fs && old_gs == gs)
73 return;
63 // Workaround for AMD bug 74 // Workaround for AMD bug
64 glUseProgramStages(pipeline.handle, 75 glUseProgramStages(pipeline.handle,
65 GL_VERTEX_SHADER_BIT | GL_GEOMETRY_SHADER_BIT | GL_FRAGMENT_SHADER_BIT, 76 GL_VERTEX_SHADER_BIT | GL_GEOMETRY_SHADER_BIT | GL_FRAGMENT_SHADER_BIT,
@@ -68,14 +79,16 @@ public:
68 glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, vs); 79 glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, vs);
69 glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, gs); 80 glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, gs);
70 glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, fs); 81 glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, fs);
71 state.draw.shader_program = 0; 82
72 state.draw.program_pipeline = pipeline.handle; 83 // Update the old values
73 state.geometry_shaders.enabled = (gs != 0); 84 old_vs = vs;
85 old_fs = fs;
86 old_gs = gs;
74 } 87 }
75 88
76private:
77 OGLPipeline pipeline; 89 OGLPipeline pipeline;
78 GLuint vs{}, fs{}, gs{}; 90 GLuint vs{}, fs{}, gs{};
91 GLuint old_vs{}, old_fs{}, old_gs{};
79}; 92};
80 93
81} // namespace OpenGL::GLShader 94} // namespace OpenGL::GLShader