Optimize text rendering, particle draw state, and scene loop hot paths#47
Draft
alegemaate with Copilot wants to merge 4 commits into
Draft
Optimize text rendering, particle draw state, and scene loop hot paths#47alegemaate with Copilot wants to merge 4 commits into
alegemaate with Copilot wants to merge 4 commits into
Conversation
Copilot
AI
changed the title
[WIP] Implement performance-oriented fixes in AdsGames/asw
Optimize text rendering, particle draw state, and scene loop hot paths
Jul 3, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This change targets the highest-frequency rendering and scene-management paths without changing public behavior. It removes repeated work in text drawing, particle rendering, and scene update/draw loops, while keeping cache invalidation aligned with existing SDL resource ownership.
Text rendering
(renderer, font, text, color)instead of recreating a surface/texture on every draw.draw::text(...)API.Text measurement / UI layout
get_text_size(font, text)results to avoid repeating SDL_ttf layout work for stable UI strings.Particle rendering
Scene update/draw
Frame loop overhead
now()timestamp in managed scene loops instead of reading the clock multiple times per frame.Example of the main rendering-path change:
TextCacheKey cache_key { r, font, text, pack_color(color) }; auto cached_text = text_cache.find(cache_key); if (cached_text == text_cache.end()) { SDL_Surface* textSurface = TTF_RenderText_Blended(font.get(), text.c_str(), 0, sdlColor); SDL_Texture* textTexture = SDL_CreateTextureFromSurface(r, textSurface); cached_text = text_cache.emplace(cache_key, TextCacheEntry { make_cached_texture(textTexture), textSurface->w, textSurface->h, }).first; } SDL_RenderTexture(r, cached_text->second.texture.get(), nullptr, &dest);