Graphics/ForwardFramePipeline: Fix unregister + register the same renderable pointer not invalidating rendering

This can happen with ECS components which are mostly stable in memory, when destroying a graphics entity and recreating it (even with a different mesh) its pointer may not change due to memory recycling, especially on simple scenes.

A UInt8 generation counter helps prevents this
This commit is contained in:
SirLynix
2023-05-30 13:34:41 +02:00
parent f2f90e2ca3
commit cff918f6a3
2 changed files with 5 additions and 1 deletions

View File

@@ -108,6 +108,7 @@ namespace Nz
const InstancedRenderable* renderable;
Recti scissorBox;
UInt32 renderMask = 0;
UInt8 generation;
NazaraSlot(InstancedRenderable, OnElementInvalidated, onElementInvalidated);
NazaraSlot(InstancedRenderable, OnMaterialInvalidated, onMaterialInvalidated);
@@ -169,6 +170,7 @@ namespace Nz
MemoryPool<ViewerData> m_viewerPool;
MemoryPool<WorldInstanceData> m_worldInstances;
RenderFrame* m_currentRenderFrame;
UInt8 m_generationCounter;
bool m_rebuildFrameGraph;
};
}