diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2017-11-26 11:36:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-26 11:36:10 +0100 |
| commit | 96e094e127b2abd72c06d7803f5d8ee8e7ad8aa0 (patch) | |
| tree | df4204128c08e5f6da0a52817898e4ead0fa9789 /Source/Core/VideoBackends | |
| parent | 7e24b093013d4dac14c4adea31322fd0b527d639 (diff) | |
| parent | cf1f97514866a655f0d497ab61c9c392d83bef6c (diff) | |
Merge pull request #6216 from stenzek/headless-frame-dumping
OGL: Fix headless frame dumping
Diffstat (limited to 'Source/Core/VideoBackends')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/FramebufferManager.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/OGL/PostProcessing.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/OGL/Render.cpp | 83 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Software/SWRenderer.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/Renderer.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp | 4 |
6 files changed, 59 insertions, 41 deletions
diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp index af526fce36..a00b026103 100644 --- a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp @@ -54,6 +54,7 @@ GLuint FramebufferManager::CreateTexture(GLenum texture_type, GLenum internal_fo GLenum pixel_format, GLenum data_type) { GLuint texture; + glActiveTexture(GL_TEXTURE9); glGenTextures(1, &texture); glBindTexture(texture_type, texture); if (texture_type == GL_TEXTURE_2D_ARRAY) diff --git a/Source/Core/VideoBackends/OGL/PostProcessing.cpp b/Source/Core/VideoBackends/OGL/PostProcessing.cpp index bf34e2a54c..74a4c2da0e 100644 --- a/Source/Core/VideoBackends/OGL/PostProcessing.cpp +++ b/Source/Core/VideoBackends/OGL/PostProcessing.cpp @@ -12,6 +12,7 @@ #include "Core/Config/GraphicsSettings.h" #include "VideoBackends/OGL/FramebufferManager.h" +#include "VideoBackends/OGL/OGLTexture.h" #include "VideoBackends/OGL/ProgramShaderCache.h" #include "VideoBackends/OGL/SamplerCache.h" @@ -121,6 +122,7 @@ void OpenGLPostProcessing::BlitFromTexture(TargetRectangle src, TargetRectangle glBindTexture(GL_TEXTURE_2D_ARRAY, src_texture); g_sampler_cache->BindLinearSampler(9); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + OGLTexture::SetStage(); } void OpenGLPostProcessing::ApplyShader() 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()) { diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index 69523efe78..4c298e927e 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -45,9 +45,11 @@ void SWRenderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_regi { OSD::DoCallbacks(OSD::CallbackType::OnFrame); - DrawDebugText(); - - SWOGLWindow::s_instance->ShowImage(texture, xfb_region); + if (!IsHeadless()) + { + DrawDebugText(); + SWOGLWindow::s_instance->ShowImage(texture, xfb_region); + } UpdateActiveConfig(); } diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index 8f83e2b202..084e7a2880 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -600,7 +600,6 @@ void Renderer::DrawScreen(VKTexture* xfb_texture, const EFBRectangle& xfb_region VK_SUBPASS_CONTENTS_INLINE); // Draw - TargetRectangle source_rc = xfb_texture->GetConfig().GetRect(); BlitScreen(m_swap_chain->GetRenderPass(), GetTargetRectangle(), xfb_region, xfb_texture->GetRawTexIdentifier()); @@ -702,6 +701,7 @@ void Renderer::CheckForSurfaceChange() // Notify calling thread. m_surface_needs_change.Clear(); + m_surface_handle = m_new_surface_handle; m_new_surface_handle = nullptr; m_surface_changed.Set(); } diff --git a/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp b/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp index f72d43d62e..0c9fae677b 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp @@ -14,7 +14,7 @@ #if defined(VK_USE_PLATFORM_WIN32_KHR) #include <Windows.h> #elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) || \ - defined(VK_USE_PLATFORM_ANDROID_KHR) + defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(USE_HEADLESS) #include <dlfcn.h> #endif @@ -98,7 +98,7 @@ void UnloadVulkanLibrary() } #elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) || \ - defined(VK_USE_PLATFORM_ANDROID_KHR) + defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(USE_HEADLESS) static void* vulkan_module; static std::atomic_int vulkan_module_ref_count = {0}; |
