diff options
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/Render.cpp | 83 |
1 files changed, 48 insertions, 35 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index ac662e456b..84c1ce0dfc 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1349,17 +1349,54 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region // Flip top and bottom for some reason; TODO: Fix the code to suck less? std::swap(flipped_trc.top, flipped_trc.bottom); - // Copy the framebuffer to screen. - glBindFramebuffer(GL_FRAMEBUFFER, 0); - BlitScreen(sourceRc, flipped_trc, xfb_texture->GetRawTexIdentifier(), - xfb_texture->GetConfig().width, xfb_texture->GetConfig().height); + // Do our OSD callbacks + OSD::DoCallbacks(OSD::CallbackType::OnFrame); + + // Skip screen rendering when running in headless mode. + if (!IsHeadless()) + { + // Copy the framebuffer to screen. + glBindFramebuffer(GL_FRAMEBUFFER, 0); + BlitScreen(sourceRc, flipped_trc, xfb_texture->GetRawTexIdentifier(), + xfb_texture->GetConfig().width, xfb_texture->GetConfig().height); - // Finish up the current frame, print some stats + // Finish up the current frame, print some stats + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - SetWindowSize(xfb_texture->GetConfig().width, xfb_texture->GetConfig().height); + // Reset viewport for drawing text + glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight()); + DrawDebugText(); + OSD::DrawMessages(); + + // Copy the rendered frame to the real window. + GLInterface->Swap(); + } + else + { + // Since we're not swapping in headless mode, ensure all commands are sent to the GPU. + // Otherwise the driver could batch several frames togehter. + glFlush(); + } + +#ifdef ANDROID + // Handle surface changes on Android. + if (m_surface_needs_change.IsSet()) + { + GLInterface->UpdateHandle(m_new_surface_handle); + GLInterface->UpdateSurface(); + m_surface_handle = m_new_surface_handle; + m_new_surface_handle = nullptr; + m_surface_needs_change.Clear(); + m_surface_changed.Set(); + } +#endif - GLInterface->Update(); // just updates the render window position and the backbuffer size + // Update the render window position and the backbuffer size + SetWindowSize(xfb_texture->GetConfig().width, xfb_texture->GetConfig().height); + GLInterface->Update(); + // Was the size changed since the last frame? bool window_resized = false; int window_width = static_cast<int>(std::max(GLInterface->GetBackBufferWidth(), 1u)); int window_height = static_cast<int>(std::max(GLInterface->GetBackBufferHeight(), 1u)); @@ -1404,36 +1441,12 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region BoundingBox::SetTargetSizeChanged(m_target_width, m_target_height); } - // --------------------------------------------------------------------- - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // Reset viewport for drawing text - glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight()); - - DrawDebugText(); - - // Do our OSD callbacks - OSD::DoCallbacks(OSD::CallbackType::OnFrame); - OSD::DrawMessages(); - -#ifdef ANDROID - if (m_surface_needs_change.IsSet()) + // Clear framebuffer + if (!IsHeadless()) { - GLInterface->UpdateHandle(m_new_surface_handle); - GLInterface->UpdateSurface(); - m_new_surface_handle = nullptr; - m_surface_needs_change.Clear(); - m_surface_changed.Set(); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } -#endif - - // Copy the rendered frame to the real window - GLInterface->Swap(); - - // Clear framebuffer - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (s_vsync != g_ActiveConfig.IsVSync()) { |
