phase(N.4) Tasks 6+7: skip dat-reader bridge; wire WbMeshAdapter into GameWindow

Task 6 (dat-reader bridge) obsoleted: WB ships DefaultDatReaderWriter
which takes a dat-directory path and constructs all four databases
(Portal/HighRes/Language + CellRegions) internally. We can use it
directly instead of bridging our DatCollection. Adjustment 1 noted
in the plan; full bring-up deferred to Task 9.

Task 7: GameWindow constructs WbMeshAdapter when
ACDREAM_USE_WB_FOUNDATION=1 is set; pairs with Dispose. Field is
null when flag is off, so no behavioral effect on default-off path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-08 13:21:47 +02:00
parent 1030c69b3c
commit 502c3a87e4
2 changed files with 36 additions and 1 deletions

View file

@ -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`

View file

@ -28,6 +28,9 @@ public sealed class GameWindow : IDisposable
private InstancedMeshRenderer? _staticMesh;
private Shader? _meshShader;
private TextureCache? _textureCache;
/// <summary>Phase N.4: WB-backed rendering pipeline adapter. Non-null only
/// when <c>ACDREAM_USE_WB_FOUNDATION=1</c> is set; null otherwise.</summary>
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<AcDream.App.Rendering.Wb.WbMeshAdapter>.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();