diff --git a/docs/superpowers/plans/2026-05-08-phase-n4-rendering-foundation.md b/docs/superpowers/plans/2026-05-08-phase-n4-rendering-foundation.md index 7c55aba..6458ac5 100644 --- a/docs/superpowers/plans/2026-05-08-phase-n4-rendering-foundation.md +++ b/docs/superpowers/plans/2026-05-08-phase-n4-rendering-foundation.md @@ -800,7 +800,24 @@ EOF --- -### Task 6: `WbDatReaderAdapter` — bridge our `DatCollection` to WB's `IDatReaderWriter` +### Task 6: ~~WbDatReaderAdapter~~ — OBSOLETED 2026-05-08 + +**Adjustment 1 (2026-05-08):** discovered during pre-Task-6 grep that +WB ships `WorldBuilder.Shared.Services.DefaultDatReaderWriter`, a +concrete `IDatReaderWriter` implementation that takes a dat-directory +path and constructs all four databases (Portal / HighRes / Language + +CellRegions) internally. We can instantiate it directly with the same +`%USERPROFILE%\Documents\Asheron's Call` path acdream's `DatCollection` +uses; both will open the same dat files with separate handles. Memory +cost: ~50-100 MB of duplicate index caches, acceptable for foundation +work. Task 9 incorporates the construction step directly. + +If memory pressure surfaces during week 2 stress testing, revisit by +writing a real bridge that shares index caches with our `DatCollection`. + +**No work for this task — skip and proceed to Task 7.** + +### Task 6 (original — kept for history) **Files:** - Create: `src/AcDream.App/Rendering/Wb/WbDatReaderAdapter.cs` diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs index b00345d..543a1f4 100644 --- a/src/AcDream.App/Rendering/GameWindow.cs +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -28,6 +28,9 @@ public sealed class GameWindow : IDisposable private InstancedMeshRenderer? _staticMesh; private Shader? _meshShader; private TextureCache? _textureCache; + /// Phase N.4: WB-backed rendering pipeline adapter. Non-null only + /// when ACDREAM_USE_WB_FOUNDATION=1 is set; null otherwise. + private AcDream.App.Rendering.Wb.WbMeshAdapter? _wbMeshAdapter; private SamplerCache? _samplerCache; private DebugLineRenderer? _debugLines; // K-fix4 (2026-04-26): default OFF. The orange BSP / green cylinder @@ -1421,6 +1424,19 @@ public sealed class GameWindow : IDisposable // WorldBuilder reference at // references/WorldBuilder/Chorizite.OpenGLSDLBackend/OpenGLGraphicsDevice.cs:115-132. _samplerCache = new SamplerCache(_gl); + + // Phase N.4 — WB rendering pipeline foundation. Constructed only when + // ACDREAM_USE_WB_FOUNDATION=1 is set; otherwise the legacy renderer + // path stays in charge. The full ObjectMeshManager bring-up is + // deferred to Task 9 — for now this is a stub adapter that exposes + // the public API so call sites can wire without behavioral effect. + if (AcDream.App.Rendering.Wb.WbFoundationFlag.IsEnabled) + { + var wbLogger = Microsoft.Extensions.Logging.Abstractions.NullLogger.Instance; + _wbMeshAdapter = new AcDream.App.Rendering.Wb.WbMeshAdapter(_gl, _dats, wbLogger); + Console.WriteLine("[N.4] WbFoundation flag is ENABLED — routing static content through ObjectMeshManager."); + } + _staticMesh = new InstancedMeshRenderer(_gl, _meshShader, _textureCache); // Phase G.1 sky renderer — its own shader (sky.vert / sky.frag) @@ -8625,6 +8641,8 @@ public sealed class GameWindow : IDisposable _skyRenderer?.Dispose(); // depends on sampler cache; dispose first _samplerCache?.Dispose(); _textureCache?.Dispose(); + _wbMeshAdapter?.Dispose(); // Phase N.4 WB foundation — null when flag off + _meshShader?.Dispose(); _terrain?.Dispose(); _shader?.Dispose();