mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 15:59:23 +01:00
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.
This commit is contained in:
parent
ab44536a3c
commit
32125cf181
@ -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?
|
// Flip top and bottom for some reason; TODO: Fix the code to suck less?
|
||||||
std::swap(flipped_trc.top, flipped_trc.bottom);
|
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);
|
|
||||||
|
|
||||||
// Finish up the current frame, print some stats
|
|
||||||
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
|
// Do our OSD callbacks
|
||||||
OSD::DoCallbacks(OSD::CallbackType::OnFrame);
|
OSD::DoCallbacks(OSD::CallbackType::OnFrame);
|
||||||
OSD::DrawMessages();
|
|
||||||
|
|
||||||
// Copy the rendered frame to the real window.
|
// Skip screen rendering when running in headless mode.
|
||||||
GLInterface->Swap();
|
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
|
||||||
|
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();
|
||||||
|
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
|
#ifdef ANDROID
|
||||||
// Handle surface changes on 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->UpdateHandle(m_new_surface_handle);
|
||||||
GLInterface->UpdateSurface();
|
GLInterface->UpdateSurface();
|
||||||
|
m_surface_handle = m_new_surface_handle;
|
||||||
m_new_surface_handle = nullptr;
|
m_new_surface_handle = nullptr;
|
||||||
m_surface_needs_change.Clear();
|
m_surface_needs_change.Clear();
|
||||||
m_surface_changed.Set();
|
m_surface_changed.Set();
|
||||||
@ -1431,8 +1442,11 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear framebuffer
|
// Clear framebuffer
|
||||||
glClearColor(0, 0, 0, 0);
|
if (!IsHeadless())
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
{
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
if (s_vsync != g_ActiveConfig.IsVSync())
|
if (s_vsync != g_ActiveConfig.IsVSync())
|
||||||
{
|
{
|
||||||
|
@ -45,9 +45,11 @@ void SWRenderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_regi
|
|||||||
{
|
{
|
||||||
OSD::DoCallbacks(OSD::CallbackType::OnFrame);
|
OSD::DoCallbacks(OSD::CallbackType::OnFrame);
|
||||||
|
|
||||||
DrawDebugText();
|
if (!IsHeadless())
|
||||||
|
{
|
||||||
SWOGLWindow::s_instance->ShowImage(texture, xfb_region);
|
DrawDebugText();
|
||||||
|
SWOGLWindow::s_instance->ShowImage(texture, xfb_region);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,6 @@ void Renderer::DrawScreen(VKTexture* xfb_texture, const EFBRectangle& xfb_region
|
|||||||
VK_SUBPASS_CONTENTS_INLINE);
|
VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
TargetRectangle source_rc = xfb_texture->GetConfig().GetRect();
|
|
||||||
BlitScreen(m_swap_chain->GetRenderPass(), GetTargetRectangle(), xfb_region,
|
BlitScreen(m_swap_chain->GetRenderPass(), GetTargetRectangle(), xfb_region,
|
||||||
xfb_texture->GetRawTexIdentifier());
|
xfb_texture->GetRawTexIdentifier());
|
||||||
|
|
||||||
@ -702,6 +701,7 @@ void Renderer::CheckForSurfaceChange()
|
|||||||
|
|
||||||
// Notify calling thread.
|
// Notify calling thread.
|
||||||
m_surface_needs_change.Clear();
|
m_surface_needs_change.Clear();
|
||||||
|
m_surface_handle = m_new_surface_handle;
|
||||||
m_new_surface_handle = nullptr;
|
m_new_surface_handle = nullptr;
|
||||||
m_surface_changed.Set();
|
m_surface_changed.Set();
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ Renderer::Renderer(int backbuffer_width, int backbuffer_height)
|
|||||||
if (SConfig::GetInstance().bWii)
|
if (SConfig::GetInstance().bWii)
|
||||||
m_aspect_wide = Config::Get(Config::SYSCONF_WIDESCREEN);
|
m_aspect_wide = Config::Get(Config::SYSCONF_WIDESCREEN);
|
||||||
|
|
||||||
|
m_surface_handle = Host_GetRenderHandle();
|
||||||
m_last_host_config_bits = ShaderHostConfig::GetCurrent().bits;
|
m_last_host_config_bits = ShaderHostConfig::GetCurrent().bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,6 +401,11 @@ float Renderer::CalculateDrawAspectRatio() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Renderer::IsHeadless() const
|
||||||
|
{
|
||||||
|
return !m_surface_handle;
|
||||||
|
}
|
||||||
|
|
||||||
std::tuple<float, float> Renderer::ScaleToDisplayAspectRatio(const int width,
|
std::tuple<float, float> Renderer::ScaleToDisplayAspectRatio(const int width,
|
||||||
const int height) const
|
const int height) const
|
||||||
{
|
{
|
||||||
@ -711,7 +717,7 @@ void Renderer::DoDumpFrame()
|
|||||||
void Renderer::UpdateFrameDumpTexture()
|
void Renderer::UpdateFrameDumpTexture()
|
||||||
{
|
{
|
||||||
int target_width, target_height;
|
int target_width, target_height;
|
||||||
if (!g_ActiveConfig.bInternalResolutionFrameDumps)
|
if (!g_ActiveConfig.bInternalResolutionFrameDumps && !IsHeadless())
|
||||||
{
|
{
|
||||||
auto target_rect = GetTargetRectangle();
|
auto target_rect = GetTargetRectangle();
|
||||||
target_width = target_rect.GetWidth();
|
target_width = target_rect.GetWidth();
|
||||||
|
@ -94,6 +94,7 @@ public:
|
|||||||
|
|
||||||
const TargetRectangle& GetTargetRectangle() const { return m_target_rectangle; }
|
const TargetRectangle& GetTargetRectangle() const { return m_target_rectangle; }
|
||||||
float CalculateDrawAspectRatio() const;
|
float CalculateDrawAspectRatio() const;
|
||||||
|
bool IsHeadless() const;
|
||||||
|
|
||||||
std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height) const;
|
std::tuple<float, float> ScaleToDisplayAspectRatio(int width, int height) const;
|
||||||
void UpdateDrawRectangle();
|
void UpdateDrawRectangle();
|
||||||
@ -176,9 +177,10 @@ protected:
|
|||||||
|
|
||||||
static const float GX_MAX_DEPTH;
|
static const float GX_MAX_DEPTH;
|
||||||
|
|
||||||
|
void* m_surface_handle = nullptr;
|
||||||
|
void* m_new_surface_handle = nullptr;
|
||||||
Common::Flag m_surface_needs_change;
|
Common::Flag m_surface_needs_change;
|
||||||
Common::Event m_surface_changed;
|
Common::Event m_surface_changed;
|
||||||
void* m_new_surface_handle = nullptr;
|
|
||||||
|
|
||||||
u32 m_last_host_config_bits = 0;
|
u32 m_last_host_config_bits = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user