diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_manager.h | 21 |
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 | |||
| 69 | private: | ||
| 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 | ||
| 76 | private: | ||
| 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 |