Skip to content

Commit

Permalink
[client] main: only render if there is actually something to render
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Aug 1, 2021
1 parent 77b3d45 commit 17687fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
25 changes: 6 additions & 19 deletions client/src/main.c
Expand Up @@ -167,8 +167,12 @@ static int renderThread(void * unused)

while(g_state.state != APP_STATE_SHUTDOWN)
{
if (g_state.jitRender || (g_state.ds->waitFrame && g_state.overlayInput))
if (g_state.jitRender)
{
g_state.ds->waitFrame();
if (!lgResetEvent(g_state.frameEvent) && !g_state.overlayInput)
continue;
}
else if (g_params.fpsMin != 0)
{
float ups = atomic_load_explicit(&g_state.ups, memory_order_relaxed);
Expand Down Expand Up @@ -973,23 +977,14 @@ static int lg_run(void)
}

// setup the new frame event
if (!(g_state.frameEvent = lgCreateEvent(true, 0)))
if (!(g_state.frameEvent = lgCreateEvent(!g_state.jitRender, 0)))
{
DEBUG_ERROR("failed to create the frame event");
return -1;
}

if (!(g_state.jitEvent = lgCreateEvent(true, 0)))
{
DEBUG_ERROR("failed to create the overlay render event");
return -1;
}

if (g_state.jitRender)
{
DEBUG_INFO("Using JIT render mode");
lgSignalEvent(g_state.jitEvent);
}

lgInit();

Expand Down Expand Up @@ -1142,8 +1137,6 @@ static int lg_run(void)
goto restart;
}

lgSignalEvent(g_state.jitEvent);

return 0;
}

Expand Down Expand Up @@ -1172,12 +1165,6 @@ static void lg_shutdown(void)
g_state.frameEvent = NULL;
}

if (g_state.jitEvent)
{
lgFreeEvent(g_state.jitEvent);
g_state.jitEvent = NULL;
}

if (e_startup)
{
lgFreeEvent(e_startup);
Expand Down
1 change: 0 additions & 1 deletion client/src/main.h
Expand Up @@ -65,7 +65,6 @@ struct AppState
struct LG_DisplayServerOps * ds;
bool dsInitialized;
bool jitRender;
LGEvent * jitEvent;

bool stopVideo;
bool ignoreInput;
Expand Down

0 comments on commit 17687fd

Please sign in to comment.