Skip to content

perf(gui): Rebuild static text only when its hotkey setting changes - #633

Open
tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/perf/static-text-rebuild
Open

tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/perf/static-text-rebuild

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 8, 2026 •

Copy link
Copy Markdown

The static text gadget calls setUseHotkey on every draw, and that always marked the text as changed. So every static text on screen rebuilt its sentence every frame, creating a new D3D surface and texture each time.

setUseHotkey now returns early when the setting and colour are unchanged. That per-frame rebuild was also hiding two other things, which are fixed here too. Render2DSentenceClass::Reset() cleared the hotkey parse setting, so it now leaves it alone and draw() asks the hotkey renderer whether it has a sentence. And a clip region change did not redo the quads, so setClipRegion now marks them for a redo.

This also removes MonoSpaced from Render2DSentenceClass, which was never read.

This is the merged upstream TheSuperHackers#3443 (issue TheSuperHackers#3441), cherry-picked as is. W3DDisplayString exists once per game in this tree, so it is applied to both the GeneralsMD and Generals copies.

Measured on the upstream build in a Zero Hour skirmish at 120 fps, winRepaint went from about 0.155 ms to 0.099 ms per frame, roughly a third less. Hotkey labels, turning the hotkey on and off, text changes and clip changes were checked on screen on the upstream build. Zero Hour builds here; the Generals half could not be compiled in this tree.

This branch was rebuilt on the merged upstream commit. The code is identical to the earlier version of this PR; the two commits are now the one upstream commit.

@tintinhamans
tintinhamans force-pushed the arctic/go/perf/static-text-rebuild branch from 5a34946 to 6631215 Compare October 15, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant