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

@@ -15,8 +15,9 @@ NullThreadedVsyncSource::~NullThreadedVsyncSource()
}
}
bool NullThreadedVsyncSource::initialize(SDL_Window*)
bool NullThreadedVsyncSource::initialize(SDL_Window*, int displayFps)
{
m_DisplayFps = displayFps;
m_Thread = SDL_CreateThread(vsyncThread, "Null Vsync Thread", this);
if (m_Thread == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -35,7 +36,7 @@ int NullThreadedVsyncSource::vsyncThread(void* context)
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
while (SDL_AtomicGet(&me->m_Stopping) == 0) {
me->m_Pacer->vsyncCallback();
me->m_Pacer->vsyncCallback(1000 / me->m_DisplayFps);
}
return 0;