From f5be489d9f34d04f59ea9fc21f217aa989696a0d Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 27 Dec 2025 02:29:55 +0300 Subject: [PATCH] rsx: Improve framebuffer layout change detection --- rpcs3/Emu/RSX/GL/GLRenderTargets.cpp | 1 + rpcs3/Emu/RSX/RSXThread.cpp | 25 +++++++++++++++++-------- rpcs3/Emu/RSX/RSXThread.h | 4 ++++ rpcs3/Emu/RSX/VK/VKGSRender.cpp | 5 +++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index c222262699..4e5e61dcba 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -301,6 +301,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool /* } m_graphics_state.set(rsx::rtt_config_valid); + on_framebuffer_layout_updated(); check_zcull_status(true); set_viewport(); diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index c6038e2f50..cc7b9fff17 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1740,14 +1740,7 @@ namespace rsx } } - if (::size32(mrt_buffers) != current_fragment_program.mrt_buffers_count && - !m_graphics_state.test(rsx::pipeline_state::fragment_program_dirty) && - !is_current_program_interpreted()) - { - // Notify that we should recompile the FS - m_graphics_state |= rsx::pipeline_state::fragment_program_state_dirty; - } - + on_framebuffer_layout_updated(); return any_found; }; @@ -1845,6 +1838,22 @@ namespace rsx } } + void thread::on_framebuffer_layout_updated() + { + if (m_graphics_state.test(rsx::fragment_program_state_dirty)) + { + return; + } + + const auto target = m_ctx->register_state->surface_color_target(); + if (rsx::utility::get_mrt_buffers_count(target) == current_fragment_program.mrt_buffers_count) + { + return; + } + + m_graphics_state |= rsx::fragment_program_state_dirty; + } + bool thread::get_scissor(areau& region, bool clip_viewport) { if (!m_graphics_state.test(rsx::pipeline_state::scissor_config_state_dirty)) diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index 9e09c17d78..4f965dee80 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -257,6 +257,10 @@ namespace rsx void get_framebuffer_layout(rsx::framebuffer_creation_context context, framebuffer_layout &layout); bool get_scissor(areau& region, bool clip_viewport); + // Notify framebuffer layout has been committed. + // FIXME: This should not be here + void on_framebuffer_layout_updated(); + RSXVertexProgram current_vertex_program = {}; RSXFragmentProgram current_fragment_program = {}; diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 3bc240b768..4a0e6c19ce 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -2469,7 +2469,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) m_surface_info[i].samples = samples; } - //Process depth surface as well + // Process depth surface as well { if (m_depth_surface_info.pitch && g_cfg.video.write_depth_buffer) { @@ -2486,7 +2486,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) m_depth_surface_info.samples = samples; } - //Bind created rtts as current fbo... + // Bind created rtts as current fbo... const auto draw_buffers = rsx::utility::get_rtt_indexes(m_framebuffer_layout.target); m_draw_buffers.clear(); m_fbo_images.clear(); @@ -2637,6 +2637,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) set_viewport(); set_scissor(clipped_scissor); + on_framebuffer_layout_updated(); check_zcull_status(true); }