perf(scene): Create light list iterators on the stack at points of use#2646
perf(scene): Create light list iterators on the stack at points of use#2646Mauller wants to merge 1 commit into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp | Uses a stack-local iterator while calculating static terrain lighting. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp | Removes the temporary scene-light iterator during terrain initialization. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp | Uses a stack-local iterator during terrain center updates. |
| Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DScene.h | Exposes the embedded scene light list and removes obsolete iterator APIs. |
| Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp | Removes obsolete heap-based iterator helper implementations. |
| GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DScene.h | Keeps the Zero Hour scene interface aligned with the Generals variant. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp | Removes the mirrored obsolete iterator helper implementations. |
Reviews (3): Last reviewed commit: "perf(heighmap): Create light list iterat..." | Re-trigger Greptile
Are you certain? Need to check if its just unused in a lot of maps but used when point and directional lights are on a map. |
|
Not 100% certain, but at the time I reworked height map I found no evidence that it is used for anything but is passed into many functions. |
I think i remember some people wanting to add point and directional lights into the game again, so might be good to leave in the code for now but add this optimisation to get rid of the performance issue with it. |
f5ed1e1 to
de432ef
Compare
|
Updated to remove the create and destroy iterator functions and all affected call sites. |
…e heap in BaseHeightMapRenderObjClass::getStaticDiffuse()
de432ef to
5f6d113
Compare
|
Rebased and tweaked |





This PR helps with a performance issue caused by a non block allocated, heap based, memory allocation that occurs multiple times every frame.
BaseHeightMapRenderObjClass::getStaticDiffuse()was callingRTS3DScene::createLightsIterator()anddestroyLightsIterator(RefRenderObjListIterator * it)to retrieve theLightListfrom the currentRTS3DScene.Since the
RefRenderObjListIteratoris not properly poolified in the W3D or GameMemory managers, it was causing the game memory manager to constantly acquire, zero, then release system memory.In this tweak i added an extra function in
RTS3DSceneto retrieve a pointer to theLightListinstead.This then allowed a stack created
RefRenderObjListIteratorto be created withinBaseHeightMapRenderObjClass::getStaticDiffuse()instead.This then resulted in a 20-40% performance improvement at the start of the game depending on map.
EDIT:
I have updated this to also remove the create and destroy iterator functions. I then upated all current call sites to use a stack created iterator where necessary or removed using the iterator if it was unused.