[client] main: implement just-in-time render mode

When requested, JIT render mode will be used if the display server supports it.
Otherwise, a warning is generated instead.

This essentially uses the signalNextFrame logic for imgui, but for everything.
We automatically enable this mode when overlay is on.

Currently, this exposes some damage tracking bugs in the EGL renderer.
This commit is contained in:
Quantum 2021-07-31 20:07:05 -04:00 committed by Geoffrey McRae
parent b9a7ce17fe
commit aed370c7ce
3 changed files with 40 additions and 17 deletions

View File

@ -277,6 +277,13 @@ static struct Option options[] =
.type = OPTION_TYPE_INT, .type = OPTION_TYPE_INT,
.value.x_int = 14 .value.x_int = 14
}, },
{
.module = "win",
.name = "jitRender",
.description = "Enable just-in-time rendering",
.type = OPTION_TYPE_BOOL,
.value.x_bool = false,
},
// input options // input options
{ {
@ -564,6 +571,7 @@ bool config_load(int argc, char * argv[])
g_params.quickSplash = option_get_bool ("win", "quickSplash" ); g_params.quickSplash = option_get_bool ("win", "quickSplash" );
g_params.uiFont = option_get_string("win" , "uiFont" ); g_params.uiFont = option_get_string("win" , "uiFont" );
g_params.uiSize = option_get_int ("win" , "uiSize" ); g_params.uiSize = option_get_int ("win" , "uiSize" );
g_params.jitRender = option_get_bool ("win" , "jitRender" );
if (g_params.noScreensaver && g_params.autoScreensaver) if (g_params.noScreensaver && g_params.autoScreensaver)
{ {

View File

@ -167,8 +167,8 @@ static int renderThread(void * unused)
while(g_state.state != APP_STATE_SHUTDOWN) while(g_state.state != APP_STATE_SHUTDOWN)
{ {
if (g_state.overlayMustWait) if (g_state.jitRender)
lgWaitEvent(g_state.overlayRenderEvent, TIMEOUT_INFINITE); lgWaitEvent(g_state.jitEvent, TIMEOUT_INFINITE);
else if (g_params.fpsMin != 0) else if (g_params.fpsMin != 0)
{ {
float ups = atomic_load_explicit(&g_state.ups, memory_order_relaxed); float ups = atomic_load_explicit(&g_state.ups, memory_order_relaxed);
@ -182,13 +182,11 @@ static int renderThread(void * unused)
} }
} }
if (g_state.overlayInput && g_state.ds->signalNextFrame) if (!g_params.jitRender && g_state.ds->signalNextFrame)
{ g_state.jitRender = g_state.overlayInput;
g_state.ds->signalNextFrame(g_state.overlayRenderEvent);
g_state.overlayMustWait = true; if (g_state.jitRender)
} g_state.ds->signalNextFrame(g_state.jitEvent);
else
g_state.overlayMustWait = false;
int resize = atomic_load(&g_state.lgrResize); int resize = atomic_load(&g_state.lgrResize);
if (resize) if (resize)
@ -828,6 +826,14 @@ static int lg_run(void)
assert(g_state.ds); assert(g_state.ds);
ASSERT_LG_DS_VALID(g_state.ds); ASSERT_LG_DS_VALID(g_state.ds);
if (g_params.jitRender)
{
if (g_state.ds->signalNextFrame)
g_state.jitRender = true;
else
DEBUG_WARN("JIT render not supported on display server backend, disabled");
}
// init the subsystem // init the subsystem
if (!g_state.ds->earlyInit()) if (!g_state.ds->earlyInit())
{ {
@ -979,12 +985,18 @@ static int lg_run(void)
return -1; return -1;
} }
if (!(g_state.overlayRenderEvent = lgCreateEvent(true, 0))) if (!(g_state.jitEvent = lgCreateEvent(true, 0)))
{ {
DEBUG_ERROR("failed to create the overlay render event"); DEBUG_ERROR("failed to create the overlay render event");
return -1; return -1;
} }
if (g_state.jitRender)
{
DEBUG_INFO("Using JIT render mode");
lgSignalEvent(g_state.jitEvent);
}
lgInit(); lgInit();
// start the renderThread so we don't just display junk // start the renderThread so we don't just display junk
@ -1136,6 +1148,8 @@ restart:
goto restart; goto restart;
} }
lgSignalEvent(g_state.jitEvent);
return 0; return 0;
} }
@ -1164,10 +1178,10 @@ static void lg_shutdown(void)
g_state.frameEvent = NULL; g_state.frameEvent = NULL;
} }
if (g_state.overlayRenderEvent) if (g_state.jitEvent)
{ {
lgFreeEvent(g_state.overlayRenderEvent); lgFreeEvent(g_state.jitEvent);
g_state.overlayRenderEvent = NULL; g_state.jitEvent = NULL;
} }
if (e_startup) if (e_startup)

View File

@ -55,8 +55,6 @@ struct AppState
ImFont * fontLarge; ImFont * fontLarge;
bool overlayInput; bool overlayInput;
ImGuiMouseCursor cursorLast; ImGuiMouseCursor cursorLast;
LGEvent * overlayRenderEvent;
bool overlayMustWait;
char * imGuiIni; char * imGuiIni;
bool alertShow; bool alertShow;
@ -66,6 +64,8 @@ struct AppState
struct LG_DisplayServerOps * ds; struct LG_DisplayServerOps * ds;
bool dsInitialized; bool dsInitialized;
bool jitRender;
LGEvent * jitEvent;
bool stopVideo; bool stopVideo;
bool ignoreInput; bool ignoreInput;
@ -171,6 +171,7 @@ struct AppParams
uint64_t helpMenuDelayUs; uint64_t helpMenuDelayUs;
const char * uiFont; const char * uiFont;
int uiSize; int uiSize;
bool jitRender;
unsigned int cursorPollInterval; unsigned int cursorPollInterval;
unsigned int framePollInterval; unsigned int framePollInterval;