Skip to content

Commit

Permalink
Merge pull request #3961 from phire/less_virtual_xfb_lag
Browse files Browse the repository at this point in the history
XFB: Send image to screen at start of field (Reduce VirtualXFB latency)
  • Loading branch information
delroth committed Jul 10, 2016
2 parents 6204a81 + 3556631 commit 7ee6d08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
5 changes: 4 additions & 1 deletion Source/Core/Core/HW/VideoInterface.cpp
Expand Up @@ -700,13 +700,16 @@ static void BeginField(FieldType field)
DEBUG_LOG(VIDEOINTERFACE, "HorizScaling: %04x | fbwidth %d | %u | %u", m_HorizontalScaling.Hex,
m_FBWidth.Hex, GetTicksPerEvenField(), GetTicksPerOddField());

// This assumes the game isn't going to change the VI registers while a
// frame is scanning out.
// To correctly handle that case we would need to collate all changes
// to VI during scanout and delay outputting the frame till then.
if (xfbAddr)
g_video_backend->Video_BeginField(xfbAddr, fbWidth, fbStride, fbHeight);
}

static void EndField()
{
g_video_backend->Video_EndField();
Core::VideoThrottle();
}

Expand Down
20 changes: 4 additions & 16 deletions Source/Core/VideoCommon/MainBase.cpp
Expand Up @@ -48,18 +48,6 @@ void VideoBackendBase::Video_ExitLoop()

// Run from the CPU thread (from VideoInterface.cpp)
void VideoBackendBase::Video_BeginField(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight)
{
if (m_initialized && g_ActiveConfig.bUseXFB)
{
s_beginFieldArgs.xfbAddr = xfbAddr;
s_beginFieldArgs.fbWidth = fbWidth;
s_beginFieldArgs.fbStride = fbStride;
s_beginFieldArgs.fbHeight = fbHeight;
}
}

// Run from the CPU thread (from VideoInterface.cpp)
void VideoBackendBase::Video_EndField()
{
if (m_initialized && g_ActiveConfig.bUseXFB && g_renderer)
{
Expand All @@ -69,10 +57,10 @@ void VideoBackendBase::Video_EndField()
e.time = 0;
e.type = AsyncRequests::Event::SWAP_EVENT;

e.swap_event.xfbAddr = s_beginFieldArgs.xfbAddr;
e.swap_event.fbWidth = s_beginFieldArgs.fbWidth;
e.swap_event.fbStride = s_beginFieldArgs.fbStride;
e.swap_event.fbHeight = s_beginFieldArgs.fbHeight;
e.swap_event.xfbAddr = xfbAddr;
e.swap_event.fbWidth = fbWidth;
e.swap_event.fbStride = fbStride;
e.swap_event.fbHeight = fbHeight;
AsyncRequests::GetInstance()->PushEvent(e, false);
}
}
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoCommon/VideoBackendBase.h
Expand Up @@ -81,7 +81,6 @@ class VideoBackendBase
virtual void Video_Cleanup() = 0; // called from gl/d3d thread

void Video_BeginField(u32, u32, u32, u32);
void Video_EndField();

u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
u32 Video_GetQueryResult(PerfQueryType type);
Expand Down

0 comments on commit 7ee6d08

Please sign in to comment.