[client] imgui: use signalNextFrame if possible

This allows imgui to be rendered at screen refresh rate for supported display
server backends.
This commit is contained in:
Quantum 2021-07-31 04:02:24 -04:00 committed by Geoffrey McRae
parent a213ee960a
commit c8dc037e94
2 changed files with 25 additions and 1 deletions

View File

@ -166,7 +166,9 @@ static int renderThread(void * unused)
while(g_state.state != APP_STATE_SHUTDOWN)
{
if (g_params.fpsMin != 0)
if (g_state.overlayMustWait)
lgWaitEvent(g_state.overlayRenderEvent, TIMEOUT_INFINITE);
else if (g_params.fpsMin != 0)
{
float ups = atomic_load_explicit(&g_state.ups, memory_order_relaxed);
@ -179,6 +181,14 @@ static int renderThread(void * unused)
}
}
if (g_state.overlayInput && g_state.ds->signalNextFrame)
{
g_state.ds->signalNextFrame(g_state.overlayRenderEvent);
g_state.overlayMustWait = true;
}
else
g_state.overlayMustWait = false;
int resize = atomic_load(&g_state.lgrResize);
if (resize)
{
@ -966,6 +976,12 @@ static int lg_run(void)
return -1;
}
if (!(g_state.overlayRenderEvent = lgCreateEvent(true, 0)))
{
DEBUG_ERROR("failed to create the overlay render event");
return -1;
}
lgInit();
// start the renderThread so we don't just display junk
@ -1145,6 +1161,12 @@ static void lg_shutdown(void)
g_state.frameEvent = NULL;
}
if (g_state.overlayRenderEvent)
{
lgFreeEvent(g_state.overlayRenderEvent);
g_state.overlayRenderEvent = NULL;
}
if (e_startup)
{
lgFreeEvent(e_startup);

View File

@ -55,6 +55,8 @@ struct AppState
ImFont * fontLarge;
bool overlayInput;
ImGuiMouseCursor cursorLast;
LGEvent * overlayRenderEvent;
bool overlayMustWait;
bool alertShow;
char * alertMessage;