From 580edd9cfb26b484082a77b43cc935618200865b Mon Sep 17 00:00:00 2001 From: LHoG <1476261+lhog@users.noreply.github.com> Date: Mon, 10 Feb 2025 02:18:40 +0100 Subject: [PATCH] Some micro-optimizations while searching for a root cause of https://github.com/beyond-all-reason/spring/issues/1941 and alike --- rts/Rendering/Fonts/CFontTexture.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rts/Rendering/Fonts/CFontTexture.cpp b/rts/Rendering/Fonts/CFontTexture.cpp index d7983b93d9..05a5bd0189 100644 --- a/rts/Rendering/Fonts/CFontTexture.cpp +++ b/rts/Rendering/Fonts/CFontTexture.cpp @@ -874,25 +874,27 @@ void CFontTexture::Update() { std::erase_if(allFonts, [](std::weak_ptr item) { return item.expired(); }); static std::vector> fontsToUpdate; - fontsToUpdate.clear(); if (needsClearGlyphs) ClearAllGlyphs(); for (const auto& font : allFonts) { auto lf = font.lock(); - if (lf->GlyphAtlasTextureNeedsUpdate() || lf->GlyphAtlasTextureNeedsUpload()) + if (lf->GlyphAtlasTextureNeedsUpdate()) fontsToUpdate.emplace_back(std::move(lf)); } - for_mt_chunk(0, fontsToUpdate.size(), [](int i) { + // note causes nested for_mt in atlasUpdateShadow.Blur() + for_mt(0, fontsToUpdate.size(), [](int i) { fontsToUpdate[i]->UpdateGlyphAtlasTexture(); }); - - for (const auto& font : fontsToUpdate) - font->UploadGlyphAtlasTexture(); - fontsToUpdate.clear(); + + for (const auto& font : allFonts) { + auto lf = font.lock(); + if (lf->GlyphAtlasTextureNeedsUpload()) + lf->UploadGlyphAtlasTexture(); + } } const GlyphInfo& CFontTexture::GetGlyph(char32_t ch)