perf(view): Cache only latest screen-to-terrain result#2992
Open
CryoTheRenegade wants to merge 3 commits into
Open
perf(view): Cache only latest screen-to-terrain result#2992CryoTheRenegade wants to merge 3 commits into
CryoTheRenegade wants to merge 3 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/Common/STLTypedefs.h | Removed the old position-request cache typedefs. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h | Replaced the vector cache members with scalar fields for one cached request. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp | Implements the single-entry cache and invalidates it around view, terrain, seismic, and bridge changes. |
| Generals/Code/GameEngine/Include/GameLogic/TerrainLogic.h | Adds the bridge-change counter field and accessor. |
| Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp | Adds bridge-change counter updates, with one over-invalidation issue in damage-state polling. |
| GeneralsMD/Code/GameEngine/Include/GameLogic/TerrainLogic.h | Mirrors the bridge-change counter API for Zero Hour. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp | Mirrors the bridge-change counter implementation, including the same damage-polling over-invalidation issue. |
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp:1866
**Bridge Counter Always Changes**
When `updateBridgeDamageStates()` runs, this increment advances the cache generation even if the bridge scan found no real damage-state change. `W3DView::screenToTerrain()` now treats any generation change as an invalidation, so maps with bridges can throw away the new one-entry cache every frame and lose the intended reuse.
### Issue 2 of 2
GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp:1866
**Bridge Counter Always Changes**
This mirrored Zero Hour path also advances `m_bridgeChangeCounter` every time bridge damage states are polled, even when no bridge state changed. Since `screenToTerrain()` invalidates its cached result on any counter difference, bridge maps can miss the new cache every frame instead of reusing the latest result.
Reviews (1): Last reviewed commit: "bugfix(w3d): Invalidate terrain cache on..." | Re-trigger Greptile
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.
Summary
In #2815 I profiled
W3DView::m_locationRequestsand found that only the newest entry was reused out of the 40 entry cache. The movement (moving camera in replays) test produced 33,590 newest-entry hits, while older cached entries had no hits.This change replaces the 40 entry cache with a single entry cache that tracks bridge and seismic additions, deletions, and damage-state changes persistently so we can invalidate the entry when a change occurs.