mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-10-30 15:39:02 -05:00 
			
		
		
		
	Merge pull request #1825 from ReinUsesLisp/shader-pipeline-cache
gl_shader_manager: Update pipeline when programs have changed
This commit is contained in:
		| @@ -60,6 +60,17 @@ public: | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     void ApplyTo(OpenGLState& state) { |     void ApplyTo(OpenGLState& state) { | ||||||
|  |         UpdatePipeline(); | ||||||
|  |         state.draw.shader_program = 0; | ||||||
|  |         state.draw.program_pipeline = pipeline.handle; | ||||||
|  |         state.geometry_shaders.enabled = (gs != 0); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | private: | ||||||
|  |     void UpdatePipeline() { | ||||||
|  |         // Avoid updating the pipeline when values have no changed | ||||||
|  |         if (old_vs == vs && old_fs == fs && old_gs == gs) | ||||||
|  |             return; | ||||||
|         // Workaround for AMD bug |         // Workaround for AMD bug | ||||||
|         glUseProgramStages(pipeline.handle, |         glUseProgramStages(pipeline.handle, | ||||||
|                            GL_VERTEX_SHADER_BIT | GL_GEOMETRY_SHADER_BIT | GL_FRAGMENT_SHADER_BIT, |                            GL_VERTEX_SHADER_BIT | GL_GEOMETRY_SHADER_BIT | GL_FRAGMENT_SHADER_BIT, | ||||||
| @@ -68,14 +79,16 @@ public: | |||||||
|         glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, vs); |         glUseProgramStages(pipeline.handle, GL_VERTEX_SHADER_BIT, vs); | ||||||
|         glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, gs); |         glUseProgramStages(pipeline.handle, GL_GEOMETRY_SHADER_BIT, gs); | ||||||
|         glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, fs); |         glUseProgramStages(pipeline.handle, GL_FRAGMENT_SHADER_BIT, fs); | ||||||
|         state.draw.shader_program = 0; |  | ||||||
|         state.draw.program_pipeline = pipeline.handle; |         // Update the old values | ||||||
|         state.geometry_shaders.enabled = (gs != 0); |         old_vs = vs; | ||||||
|  |         old_fs = fs; | ||||||
|  |         old_gs = gs; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| private: |  | ||||||
|     OGLPipeline pipeline; |     OGLPipeline pipeline; | ||||||
|     GLuint vs{}, fs{}, gs{}; |     GLuint vs{}, fs{}, gs{}; | ||||||
|  |     GLuint old_vs{}, old_fs{}, old_gs{}; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } // namespace OpenGL::GLShader | } // namespace OpenGL::GLShader | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bunnei
					bunnei