perf(GL4): batch ghost-building rendering#3110
Open
bruno-dasilva wants to merge 3 commits into
Open
Conversation
This was referenced Jul 14, 2026
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Jul 14, 2026
Closed
bruno-dasilva
marked this pull request as ready for review
July 15, 2026 05:12
bruno-dasilva
commented
Jul 15, 2026
Comment on lines
+1844
to
+1852
| if (anyNormal) { | ||
| modelDrawerState->SetColorMultiplier(0.6f, 0.6f, 0.6f, IModelDrawerState::alphaValues.y); | ||
| modelDrawerState->SetTeamColor(0, IModelDrawerState::alphaValues.y); | ||
| flushGhosts(byTexNormal); | ||
| } | ||
| if (anyContradar) { | ||
| modelDrawerState->SetColorMultiplier(0.9f, 0.9f, 0.9f, IModelDrawerState::alphaValues.z); | ||
| modelDrawerState->SetTeamColor(0, IModelDrawerState::alphaValues.z); | ||
| flushGhosts(byTexContradar); |
Collaborator
Author
There was a problem hiding this comment.
I honestly CANNOT tell the difference between these two greys in the screenshots...
Contributor
There was a problem hiding this comment.
I didnt even realize these looked different (or should have looked different)
Add SetFlag("MATMODE_XXX", ...) alongside the existing GBUFFER_*_IDX flags so
the GL4 model shaders can reference the matrix-mode enum value by name instead
of hardcoding a literal.
Intended as a precursor for the ghost draw perf fixes, which add a third mode in the shader.
Ghost buildings are static (no animation, never move), so each gets a single world-transform slot in the transforms SSBO, and is drawn batched through ARRAY_MATMODE. One multidraw per (color bucket x texture type) instead of one immediate draw per ghost.
bruno-dasilva
force-pushed
the
bruno/refactor-extract-emplace-instance
branch
from
July 15, 2026 05:25
6783f8b to
b1c4e01
Compare
bruno-dasilva
force-pushed
the
bruno/batch-ghost-buildings-2
branch
from
July 15, 2026 05:25
55c66e8 to
05bce7c
Compare
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.

Context
POC here: #3001
When looking at large numbers of ghost buildings, performance massively drops waiting on the GPU.
eg. I spawn 600 winds, those 600 ghosts take me from 500 fps -> 120 fps. In other cases we saw dropping from ~100+fps -> 20fps in a real game/replay.
Work done
Ghost buildings are drawn batched through a new draw mode ARRAY_MATMODE. One multidraw per (color bucket x texture type) instead of one immediate draw per ghost.
Screenshots
Performance:


Before:
After:
building ghosts:

Before:
After:

radar'd + live ghost buildings:

Before:
After:
dead ghost buildings:

Before:
After:
AI Disclosure
Claude code. Claude did most of the code writing but I iterated a lot to get somewhere that's easy to review and easy to maintain.