Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always clean cache on render swap #7626

Merged
merged 1 commit into from Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Source/Core/VideoBackends/OGL/Render.cpp
Expand Up @@ -1528,6 +1528,13 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
ClearEFBCache();
}

void Renderer::Flush()
{
// ensure all commands are sent to the GPU.
// Otherwise the driver could batch several frames togehter.
glFlush();
}

void Renderer::CheckForSurfaceChange()
{
if (!m_surface_changed.TestAndClear())
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/OGL/Render.h
Expand Up @@ -133,6 +133,7 @@ class Renderer : public ::Renderer
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override;

void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks) override;
void Flush() override;

void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable,
u32 color, u32 z) override;
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/VideoBackends/Vulkan/Renderer.cpp
Expand Up @@ -640,6 +640,11 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& xfb_region
TextureCache::GetInstance()->Cleanup(frameCount);
}

void Renderer::Flush()
{
Util::ExecuteCurrentCommandsAndRestoreState(true, false);
}

void Renderer::DrawScreen(VKTexture* xfb_texture, const EFBRectangle& xfb_region)
{
VkResult res;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/Vulkan/Renderer.h
Expand Up @@ -63,6 +63,7 @@ class Renderer : public ::Renderer
TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) override;

void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks) override;
void Flush() override;

void ClearScreen(const EFBRectangle& rc, bool color_enable, bool alpha_enable, bool z_enable,
u32 color, u32 z) override;
Expand Down
8 changes: 8 additions & 0 deletions Source/Core/VideoCommon/RenderBase.cpp
Expand Up @@ -751,11 +751,19 @@ void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const

Core::Callback_VideoCopiedToXFB(true);
}
else
{
Flush();
}

// Update our last xfb values
m_last_xfb_width = (fbStride < 1 || fbStride > MAX_XFB_WIDTH) ? MAX_XFB_WIDTH : fbStride;
m_last_xfb_height = (fbHeight < 1 || fbHeight > MAX_XFB_HEIGHT) ? MAX_XFB_HEIGHT : fbHeight;
}
else
{
Flush();
}
}

bool Renderer::IsFrameDumping()
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/RenderBase.h
Expand Up @@ -184,6 +184,7 @@ class Renderer
void Swap(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, const EFBRectangle& rc,
u64 ticks);
virtual void SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ticks) = 0;
virtual void Flush() {}

PEControl::PixelFormat GetPrevPixelFormat() const { return m_prev_efb_format; }
void StorePixelFormat(PEControl::PixelFormat new_format) { m_prev_efb_format = new_format; }
Expand Down