@@ -233,6 +233,7 @@ void ogl_renderer_get_screen_uv(float* u, float* v)
233233bool ogl_renderer_load_shader_preset (const char * path)
234234{
235235 char resolved_path[SHADER_PRESET_MAX_PATH ];
236+
236237 if (!shader_preset_resolve_config_path (path, resolved_path, sizeof (resolved_path)))
237238 {
238239 Error (" Shader preset is not in the bundled shader directory: %s" , path ? path : " " );
@@ -246,6 +247,7 @@ bool ogl_renderer_load_shader_preset(const char* path)
246247 apply_shader_parameter_config ();
247248
248249 char config_path[SHADER_PRESET_MAX_PATH ];
250+
249251 if (shader_preset_get_config_path (resolved_path, config_path, sizeof (config_path)))
250252 config_video.shader_preset_path .assign (config_path);
251253
@@ -263,6 +265,7 @@ void ogl_renderer_unload_shader_preset(void)
263265void ogl_renderer_save_shader_parameter_config (void )
264266{
265267 char preset_file[SHADER_PRESET_MAX_PATH ];
268+
266269 if (!get_active_shader_preset_file (preset_file, sizeof (preset_file)))
267270 return ;
268271
@@ -567,18 +570,36 @@ static void render_quad_preset(int pass_index, uint32_t program, uint32_t textur
567570 glActiveTexture (GL_TEXTURE0 );
568571 glBindTexture (GL_TEXTURE_2D , texture);
569572
570- glActiveTexture (GL_TEXTURE1 );
571- glBindTexture (GL_TEXTURE_2D , ogl_shader_chain_get_source_texture ());
573+ if (ogl_shader_chain_get_preset_pass_uses_original_sampler (pass_index))
574+ {
575+ glActiveTexture (GL_TEXTURE1 );
576+ glBindTexture (GL_TEXTURE_2D , ogl_shader_chain_get_source_texture ());
577+ }
572578
573- glActiveTexture (GL_TEXTURE2 );
574- glBindTexture (GL_TEXTURE_2D , ogl_shader_chain_get_feedback_texture ());
579+ if (ogl_shader_chain_get_preset_pass_uses_feedback_sampler (pass_index))
580+ {
581+ glActiveTexture (GL_TEXTURE2 );
582+ glBindTexture (GL_TEXTURE_2D , ogl_shader_chain_get_feedback_texture ());
583+ }
575584
576585 for (int i = 0 ; i < SHADER_PRESET_MAX_HISTORY_TEXTURES ; i++)
577586 {
587+ if (!ogl_shader_chain_get_preset_pass_uses_history_sampler (pass_index, i))
588+ continue ;
589+
578590 glActiveTexture (GL_TEXTURE3 + i);
579591 glBindTexture (GL_TEXTURE_2D , ogl_shader_chain_get_pass_history_texture (pass_index, i));
580592 }
581593
594+ for (int i = 0 ; i < SHADER_PRESET_MAX_PASS_OUTPUT_TEXTURES ; i++)
595+ {
596+ if (!ogl_shader_chain_get_preset_pass_uses_pass_output_sampler (pass_index, i))
597+ continue ;
598+
599+ glActiveTexture (GL_TEXTURE3 + SHADER_PRESET_MAX_HISTORY_TEXTURES + i);
600+ glBindTexture (GL_TEXTURE_2D , (i < pass_index) ? ogl_shader_chain_get_intermediate_texture (i) : 0 );
601+ }
602+
582603 glUseProgram (program);
583604 OglShaderChainUniforms uniforms;
584605 uniforms.source_width = current_runtime.screen_width ;
@@ -612,6 +633,7 @@ static void load_configured_shader_preset(void)
612633 return ;
613634
614635 char resolved_path[SHADER_PRESET_MAX_PATH ];
636+
615637 if (!shader_preset_resolve_config_path (config_video.shader_preset_path .c_str (), resolved_path, sizeof (resolved_path)))
616638 {
617639 Error (" Configured shader preset is not available in the bundled shader directory: %s" , config_video.shader_preset_path .c_str ());
@@ -627,6 +649,7 @@ static void load_configured_shader_preset(void)
627649 }
628650
629651 char config_path[SHADER_PRESET_MAX_PATH ];
652+
630653 if (shader_preset_get_config_path (resolved_path, config_path, sizeof (config_path)))
631654 config_video.shader_preset_path .assign (config_path);
632655 else
@@ -638,6 +661,7 @@ static void load_configured_shader_preset(void)
638661static void apply_shader_parameter_config (void )
639662{
640663 char preset_file[SHADER_PRESET_MAX_PATH ];
664+
641665 if (!get_active_shader_preset_file (preset_file, sizeof (preset_file)))
642666 return ;
643667
@@ -695,6 +719,7 @@ static void resize_texture_2d(uint32_t texture, int width, int height, int inter
695719static bool check_framebuffer_complete (const char * name)
696720{
697721 uint32_t status = glCheckFramebufferStatus (GL_FRAMEBUFFER );
722+
698723 if (status == GL_FRAMEBUFFER_COMPLETE )
699724 return true ;
700725
0 commit comments