Allow Pacer to wait for frames up until a few ms before v-sync for better smoothness and lower latency

This commit is contained in:
Cameron Gutman
2018-08-20 17:53:35 -07:00
parent d6e7173af0
commit 6b395c816f
8 changed files with 49 additions and 14 deletions

View File

@@ -34,13 +34,15 @@ DisplayLinkVsyncSource::displayLinkOutputCallback(
// interval, even if many ms prior, we can safely use the current host time
// and get a consistent callback for each v-sync. This reduces video latency
// by at least 1 frame vs. rendering with the actual vsyncTime.
me->m_Pacer->vsyncCallback();
me->m_Pacer->vsyncCallback(500 / m_DisplayFps);
return kCVReturnSuccess;
}
bool DisplayLinkVsyncSource::initialize(SDL_Window*)
bool DisplayLinkVsyncSource::initialize(SDL_Window*, int displayFps)
{
m_DisplayFps = displayFps;
CVDisplayLinkCreateWithActiveCGDisplays(&m_DisplayLink);
CVDisplayLinkSetOutputCallback(m_DisplayLink, displayLinkOutputCallback, this);
CVDisplayLinkStart(m_DisplayLink);