acdream/src/AcDream.App/Rendering/Wb
Erik 9559726960 fix(render): Phase A8 — pool aliasing in EnvCellRenderer (visual chaos root cause)
The post-Wave-5 indoor branch chaos (flickering, missing walls, GPU 100%,
~10 FPS) is caused by two interconnected pool-management bugs in
EnvCellRenderer that line-by-line WB comparison surfaced in 30 minutes.
Neither was found by the five post-Wave-5 speculative fixes because none
of them inspected the pool path.

Bug #1 — GetPooledList missing list.Clear():
The reuse branch returned pool lists with prior-frame data still inside.
PrepareRenderBatches' merge phase pattern `gfxDict[k] = list; list.AddRange(...)`
assumes empty lists. Without Clear(), lists grow unbounded each frame, GPU
draws cumulative instance counts, and per-instance transforms become a stew
of past + present data. Mirrors WB ObjectRenderManagerBase.cs:1221-1233.

Bug #2 — Render uses snapshot.BatchedByCell.Count instead of PostPreparePoolIndex:
The snapshot author dropped WB's PostPreparePoolIndex field calling it
"scenery-only," then "compensated" in Render by setting _poolIndex to the
cell count. The cell count has no relation to the pool — Prepare may have
used 50+ pool lists for an 18-cell scene. Render's filter-path GetPooledList
then returns lists that ARE in snapshot.BatchedByCell, corrupting the snapshot
mid-Render. Restoring PostPreparePoolIndex (WB VisibilitySnapshot.cs:31)
correctly places Render's pool cursor past the snapshot's owned region.

Bug #3 (minor) — PopulateRecursive hardcoded isSetup:false for nested parts:
Setup IDs use high-byte 0x02 (per retail). WB ObjectRenderManagerBase.cs:813
checks `(partId >> 24) == 0x02` to detect nested Setups. Our port always
passed isSetup:false, silently dropping any nested Setup (its TryGetRenderData
returns IsSetup=true, Render's `!IsSetup` guard skips the draw). Probably
rare in EnvCells but fixed for completeness.

Regression coverage:
- GetPooledList_ReusedList_IsClearedBeforeReturn — would have failed pre-fix
- GetPooledList_FreshList_IsAlwaysEmpty — sanity check
- Snapshot_PostPreparePoolIndex_IsInitSettable — compile-time guarantee
- Snapshot_PostPreparePoolIndex_DefaultsToZero — defensive default

86/86 App tests pass. Build green. The fix is the audit's primary
deliverable; the GL state probe option-1 apparatus follows in a separate
commit as defense-in-depth for any unidentified residual issue.

Full audit + WB cross-reference in
docs/research/2026-05-28-a8-env-cell-renderer-audit-findings.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 19:08:49 +02:00
..
AcSurfaceMetadata.cs phase(N.4): AcSurfaceMetadata side-table for WB-pristine surface props 2026-05-08 13:08:56 +02:00
AcSurfaceMetadataTable.cs phase(N.4): AcSurfaceMetadata side-table for WB-pristine surface props 2026-05-08 13:08:56 +02:00
ActiveParticleEmitter.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
AnimatedEntityState.cs phase(N.4) Tasks 16+18+19: AnimatedEntityState + AnimPartChange + HiddenParts 2026-05-08 14:37:09 +02:00
BindlessSupport.cs fix(N.5b): black terrain — switch to uvec2 handle + sampler constructor 2026-05-09 12:53:21 +02:00
BufferUsageExtensions.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
Building.cs feat(render): Phase A8 RR3 — Building + BuildingRegistry + BuildingLoader 2026-05-27 11:08:43 +02:00
BuildingLoader.cs Revert "fix(render): Phase A8 RR7.3 — dat-driven BFS in BuildingLoader" 2026-05-27 14:07:13 +02:00
BuildingRegistry.cs feat(render): Phase A8 RR3 — Building + BuildingRegistry + BuildingLoader 2026-05-27 11:08:43 +02:00
CachedBatch.cs feat(render #53): EntityClassificationCache skeleton + first test 2026-05-10 17:23:37 +02:00
DatCollectionAdapter.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
DebugRenderSettings.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
DrawElementsIndirectCommand.cs phase(N.5) Task 7: dispatcher SSBO + indirect buffer infrastructure 2026-05-08 20:25:29 +02:00
EdgeLineBuilder.cs feat(O-T4): extract ObjectMeshManager + mesh pipeline closure into AcDream.App.Rendering.Wb 2026-05-21 16:37:55 +02:00
EmbeddedResourceReader.cs fix(O-T4): address spec-review findings — InstanceData + using cleanups 2026-05-21 16:50:05 +02:00
EntityClassificationCache.cs fix(render #53): key cache by (entityId, landblockHint) to defeat ID collision 2026-05-10 23:02:14 +02:00
EntitySpawnAdapter.cs feat(A.5 T18): use cached WorldEntity AABB in dispatcher; populate at register 2026-05-10 08:20:20 +02:00
EnvCellRenderer.cs fix(render): Phase A8 — pool aliasing in EnvCellRenderer (visual chaos root cause) 2026-05-27 19:08:49 +02:00
EnvCellSceneryInstance.cs feat(render): Phase A8 Wave 1 — WB scaffolding extraction + stencil low-level method 2026-05-27 14:46:07 +02:00
EnvCellVisibilitySnapshot.cs fix(render): Phase A8 — pool aliasing in EnvCellRenderer (visual chaos root cause) 2026-05-27 19:08:49 +02:00
GeometryUtils.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
GLHelpers.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
GlobalMeshBuffer.cs feat(O-T4): extract ObjectMeshManager + mesh pipeline closure into AcDream.App.Rendering.Wb 2026-05-21 16:37:55 +02:00
GLSLShader.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
GLStateScope.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
GpuMemoryTracker.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
GroupKey.cs refactor(render): extract WbDrawDispatcher.GroupKey to internal type at namespace scope 2026-05-10 17:13:44 +02:00
IDatReaderWriter.cs chore(O-T7): code-review housekeeping after WB extraction 2026-05-21 17:29:06 +02:00
InstanceData.cs fix(O-T4): address spec-review findings — InstanceData + using cleanups 2026-05-21 16:50:05 +02:00
ITextureCachePerInstance.cs phase(N.4) Task 17: EntitySpawnAdapter for server-spawned per-instance content 2026-05-08 14:46:34 +02:00
IWbMeshAdapter.cs phase(N.4): WbMeshAdapter stub + IWbMeshAdapter interface 2026-05-08 13:18:50 +02:00
LandblockSpawnAdapter.cs phase(N.4) Task 11: LandblockSpawnAdapter (atlas-tier ref-count bridge) 2026-05-08 13:53:38 +02:00
ManagedGLFrameBuffer.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
ManagedGLIndexBuffer.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
ManagedGLTexture.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
ManagedGLTextureArray.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
ManagedGLUniformBuffer.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
ManagedGLVertexArray.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
ManagedGLVertexBuffer.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
ModernRenderData.cs feat(O-T4): extract ObjectMeshManager + mesh pipeline closure into AcDream.App.Rendering.Wb 2026-05-21 16:37:55 +02:00
ObjectMeshManager.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
OpenGLGraphicsDevice.cs fix(O-T4): address spec-review findings — InstanceData + using cleanups 2026-05-21 16:50:05 +02:00
ParticleBatcher.cs feat(O-T7): drop WB project references; complete extraction 2026-05-21 17:17:33 +02:00
ParticleEmitterRenderer.cs feat(O-T4): extract ObjectMeshManager + mesh pipeline closure into AcDream.App.Rendering.Wb 2026-05-21 16:37:55 +02:00
RenderStateCache.cs chore(O-T7): code-review housekeeping after WB extraction 2026-05-21 17:29:06 +02:00
SceneData.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
TextureAtlasManager.cs feat(O-T4): extract ObjectMeshManager + mesh pipeline closure into AcDream.App.Rendering.Wb 2026-05-21 16:37:55 +02:00
TextureFormatExtensions.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
TextureParameters.cs feat(O-T3): extract GL infrastructure to AcDream.App 2026-05-21 16:00:31 +02:00
WbDrawDispatcher.cs feat(render): Phase A8 RR5 — WbDrawDispatcher Draw(cellIds:) overload 2026-05-27 11:18:21 +02:00
WbFrustum.cs feat(render): Phase A8 Wave 1 — WB scaffolding extraction + stencil low-level method 2026-05-27 14:46:07 +02:00
WbMeshAdapter.cs feat(render): Phase A8 Wave 3 — wire EnvCellRenderer into landblock streaming 2026-05-27 15:03:17 +02:00
WbRenderPass.cs feat(render): Phase A8 Wave 1 — WB scaffolding extraction + stencil low-level method 2026-05-27 14:46:07 +02:00