gl: Fix flip regression

- Restore graphics state after flip (including active fbo) because flip can be made through a syscall
This commit is contained in:
kd-11 2018-11-30 12:29:35 +03:00 committed by kd-11
parent b96ed5cd4e
commit 2168159d03
3 changed files with 24 additions and 6 deletions

View file

@ -1560,14 +1560,20 @@ void GLGSRender::flip(int buffer)
return; return;
} }
gl::screen.clear(gl::buffers::color);
u32 buffer_width = display_buffers[buffer].width; u32 buffer_width = display_buffers[buffer].width;
u32 buffer_height = display_buffers[buffer].height; u32 buffer_height = display_buffers[buffer].height;
u32 buffer_pitch = display_buffers[buffer].pitch; u32 buffer_pitch = display_buffers[buffer].pitch;
if (!buffer_pitch) buffer_pitch = buffer_width * 4; 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) if ((u32)buffer < display_buffers_count && buffer_width && buffer_height)
{ {
// Calculate blit coordinates // 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)) if (g_cfg.video.full_rgb_range_output && (!avconfig || avconfig->gamma == 1.f))
{ {
// Blit source image to the screen // Blit source image to the screen
// Disable scissor test (affects blit)
glDisable(GL_SCISSOR_TEST);
m_flip_fbo.recreate(); m_flip_fbo.recreate();
m_flip_fbo.bind(); m_flip_fbo.bind();
m_flip_fbo.color = image; m_flip_fbo.color = image;
m_flip_fbo.read_buffer(m_flip_fbo.color); 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); m_flip_fbo.blit(gl::screen, screen_area, areai(aspect_ratio).flipped_vertical(), gl::buffers::color, gl::filter::linear);
} }
else else
@ -1758,7 +1762,15 @@ void GLGSRender::flip(int buffer)
return false; 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; if (skip_frame) return;
m_begin_time = 0; m_begin_time = 0;

View file

@ -212,6 +212,10 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
ds->write_aa_mode = layout.aa_mode; ds->write_aa_mode = layout.aa_mode;
} }
m_draw_fbo->bind();
set_viewport();
set_scissor();
return; return;
} }

View file

@ -1013,6 +1013,8 @@ namespace rsx
{ {
if (async_flip_requested & flip_request::emu_requested) 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); handle_emu_flip(async_flip_buffer);
} }