diff --git a/client/include/app.h b/client/include/app.h index 5e245239..58c180de 100644 --- a/client/include/app.h +++ b/client/include/app.h @@ -85,7 +85,7 @@ void app_glSwapBuffers(void); #define MAX_OVERLAY_RECTS 10 void app_registerOverlay(const struct LG_OverlayOps * ops, void * params); void app_setOverlay(bool enable); - +bool app_overlayNeedsRender(void); /** * render the overlay * returns: diff --git a/client/include/interface/overlay.h b/client/include/interface/overlay.h index 13916eb8..d4395dd3 100644 --- a/client/include/interface/overlay.h +++ b/client/include/interface/overlay.h @@ -37,6 +37,10 @@ struct LG_OverlayOps /* final free */ void (*free)(void * udata); + /* return true if realtime rendering is required when in jitRender mode + * optional, if omitted assumes false */ + bool (*needs_render)(void * udata, bool interactive); + /* perform the actual drawing/rendering * * `interactive` is true if the application is currently in overlay interaction diff --git a/client/src/app.c b/client/src/app.c index e3dc60f5..d6a4bd17 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -734,6 +734,26 @@ static inline LG_DSPointer mapImGuiCursor(ImGuiMouseCursor cursor) } } +bool app_overlayNeedsRender(void) +{ + struct Overlay * overlay; + + if (g_state.overlayInput) + return true; + + for (ll_reset(g_state.overlays); + ll_walk(g_state.overlays, (void **)&overlay); ) + { + if (!overlay->ops->needs_render) + continue; + + if (overlay->ops->needs_render(overlay->udata, g_state.overlayInput)) + return true; + } + + return false; +} + int app_renderOverlay(struct Rect * rects, int maxRects) { int totalRects = 0; diff --git a/client/src/main.c b/client/src/main.c index 050f96b4..ad5be375 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -174,7 +174,9 @@ static int renderThread(void * unused) const uint64_t pending = atomic_load_explicit(&g_state.pendingCount, memory_order_acquire); - if (!lgResetEvent(g_state.frameEvent) && !pending && !g_state.overlayInput + if (!lgResetEvent(g_state.frameEvent) + && !pending + && !app_overlayNeedsRender() && !g_state.lgr->needs_render(g_state.lgrData)) { if (g_state.ds->skipFrame)