[client] overlay: add new needs_render for realtime overlays

This commit is contained in:
Geoffrey McRae 2021-08-01 21:13:59 +10:00
parent 23c77e8508
commit e23144aecd
4 changed files with 28 additions and 2 deletions

View File

@ -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:

View File

@ -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

View File

@ -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;

View File

@ -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)