diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index dfb0418627..116fa163a6 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -1560,14 +1560,20 @@ void GLGSRender::flip(int buffer) return; } - gl::screen.clear(gl::buffers::color); - u32 buffer_width = display_buffers[buffer].width; u32 buffer_height = display_buffers[buffer].height; u32 buffer_pitch = display_buffers[buffer].pitch; if (!buffer_pitch) buffer_pitch = buffer_width * 4; + // Disable scissor test (affects blit, clear, etc) + glDisable(GL_SCISSOR_TEST); + + // Clear the window background to black + gl_state.clear_color(0, 0, 0, 0); + gl::screen.bind(); + gl::screen.clear(gl::buffers::color); + if ((u32)buffer < display_buffers_count && buffer_width && buffer_height) { // Calculate blit coordinates @@ -1664,13 +1670,11 @@ void GLGSRender::flip(int buffer) if (g_cfg.video.full_rgb_range_output && (!avconfig || avconfig->gamma == 1.f)) { // Blit source image to the screen - // Disable scissor test (affects blit) - glDisable(GL_SCISSOR_TEST); - m_flip_fbo.recreate(); m_flip_fbo.bind(); m_flip_fbo.color = image; m_flip_fbo.read_buffer(m_flip_fbo.color); + m_flip_fbo.draw_buffer(m_flip_fbo.color); m_flip_fbo.blit(gl::screen, screen_area, areai(aspect_ratio).flipped_vertical(), gl::buffers::color, gl::filter::linear); } else @@ -1758,7 +1762,15 @@ void GLGSRender::flip(int buffer) return false; }); - //If we are skipping the next frame, do not reset perf counters + if (m_draw_fbo && !m_rtts_dirty) + { + // Always restore the active framebuffer + m_draw_fbo->bind(); + set_viewport(); + set_scissor(); + } + + // If we are skipping the next frame, do not reset perf counters if (skip_frame) return; m_begin_time = 0; diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index 5d221bc595..854db96a1d 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -212,6 +212,10 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk ds->write_aa_mode = layout.aa_mode; } + m_draw_fbo->bind(); + set_viewport(); + set_scissor(); + return; } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index a02dedb14d..fcd86cf43c 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1013,6 +1013,8 @@ namespace rsx { if (async_flip_requested & flip_request::emu_requested) { + // NOTE: This has to be executed immediately + // Delaying this operation can cause desync due to the delay in firing the flip event handle_emu_flip(async_flip_buffer); }