diff options
| author | Stenzek <stenzek@gmail.com> | 2017-11-23 16:53:44 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2017-11-23 16:53:55 +1000 |
| commit | 32125cf1817b57f0b6eb390409ba7167a1671cf7 (patch) | |
| tree | cc043e67e9ea25c2c9defaad6993ff0f8e675bab /Source/Core/VideoBackends/OGL/Render.cpp | |
| parent | ab44536a3c5e03851a94848c8c08779d11eedf3d (diff) | |
OGL: Fix headless frame dumping
Also skips swapping the window system buffers in headless mode, as there
may not be a surface which can be swapped in the first place. Instead,
we call glFlush() at the end of a frame in this case.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/Render.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 8408d3bcae..84c1ce0dfc 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -1349,25 +1349,35 @@ 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); - // Finish up the current frame, print some stats - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // 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); - // Reset viewport for drawing text - glViewport(0, 0, GLInterface->GetBackBufferWidth(), GLInterface->GetBackBufferHeight()); - DrawDebugText(); + // Finish up the current frame, print some stats + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // Do our OSD callbacks - OSD::DoCallbacks(OSD::CallbackType::OnFrame); - OSD::DrawMessages(); + // 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(); + // 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. @@ -1375,6 +1385,7 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region { 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(); @@ -1431,8 +1442,11 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region } // Clear framebuffer - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + if (!IsHeadless()) + { + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } if (s_vsync != g_ActiveConfig.IsVSync()) { |
