Skip to content

Commit

Permalink
Some micro-optimizations while searching for a root cause of #1941 an…
Browse files Browse the repository at this point in the history
…d alike
  • Loading branch information
lhog committed Feb 10, 2025
1 parent ebec01e commit 580edd9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions rts/Rendering/Fonts/CFontTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,25 +874,27 @@ void CFontTexture::Update() {
std::erase_if(allFonts, [](std::weak_ptr<CFontTexture> item) { return item.expired(); });

static std::vector<std::shared_ptr<CFontTexture>> 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)
Expand Down

0 comments on commit 580edd9

Please sign in to comment.