[client] renderers: only rebuild the font atlas if marked dirty

This commit is contained in:
Geoffrey McRae
2026-07-30 12:48:30 +10:00
parent 9657ac7aa2
commit f5dee45adc
6 changed files with 35 additions and 11 deletions

View File

@@ -1157,7 +1157,7 @@ void app_registerImGuiText(const char * text)
if (!util_uiFontAddText(text))
return;
atomic_fetch_add(&g_state.lgrResize, 1);
atomic_store(&g_state.fontDirty, true);
app_invalidateOverlay(false);
}

View File

@@ -268,11 +268,23 @@ static int renderThread(void * unused)
.y = g_state.windowScale,
};
g_state.io->FontGlobalScale = 1.0f / g_state.windowScale;
}
const bool fontDirty = atomic_exchange(&g_state.fontDirty, false);
if (unlikely(fontDirty || g_state.fontScale != g_state.windowScale))
{
if (!util_buildUIFontAtlas(g_state.io->Fonts,
g_params.uiSize * g_state.windowScale, &g_state.fontLarge))
DEBUG_FATAL("Failed to build font atlas: %s (%s)", g_params.uiFont, g_state.fontName);
if (g_state.lgr && !RENDERER(onFontUpdate))
DEBUG_FATAL("Failed to upload the ImGui font atlas");
g_state.fontScale = g_state.windowScale;
}
if (unlikely(resize))
{
if (g_state.lgr)
RENDERER(onResize, g_state.windowW, g_state.windowH,
g_state.windowScale, g_state.dstRect, g_params.winRotate);

View File

@@ -106,6 +106,7 @@ struct AppState
int windowW, windowH;
int windowCX, windowCY;
double windowScale;
double fontScale;
LG_RendererRotate rotate;
bool focused;
struct Border border;
@@ -120,6 +121,7 @@ struct AppState
LG_Renderer * lgr;
atomic_int lgrResize;
atomic_bool fontDirty;
LG_Lock lgrLock;
bool useDMA;