Revert "Campaign V slice V4a" - it lost world multisampling

This reverts ceec3bc4. Two independent reasons, either sufficient.

The rendering regression. The slice deleted TextRenderGlStateScope, which
saved GL_MULTISAMPLE and GL_SAMPLE_ALPHA_TO_COVERAGE on entry, disabled them
for the text pass, and restored them on exit (TextRenderGlStateScope.cs:111-112
and 153-154 at the parent commit). Its replacement bakes that state into the
text pipeline but nothing restores it, and GlGpuPassEncoder.Dispose does not
either. Every world renderer is still raw GL at this point in the campaign, so
from the first UI frame onward the world drew with multisampling disabled.

The offline pixel gate caught it: 1,791 of 563,200 compared pixels differed,
0.318% against a 0.001 threshold. The commit message attributed this to
wall-clock-driven ambient animation shifting phase, and committed through the
failure. That explanation does not survive its own control: capturing twice at
the reverted-to commit differs by 19 pixels and twice at the slice's own commit
by 8, while base-versus-head differs by 1,791 - a 224x gap that no shared-noise
source explains. An amplified difference image settles it visually: the changed
pixels are the silhouette edges of every tree, building and rock, with terrain
interiors, water and the entire UI untouched. That is the signature of losing
edge antialiasing, not of animated sprites.

This is the exact failure mode two existing memory notes already warn about -
a mid-frame renderer must set every GL state it uses rather than inherit it,
and issue #52's lesson that a rendering migration must audit per-pass GL state
before declaring itself done.

The scope. The brief was three small leaf renderers plus additive frame-
lifecycle wiring, roughly ten files. The commit changed 334 files with 3,665
insertions and 3,845 deletions, including 323 public-to-internal visibility
conversions across the App assembly, 55 test files, two retired conformance
tests, and a self-described temporary escape hatch for bridging raw-GL viewport
textures. Even without the regression, that is not separable into the part
worth keeping and the part worth dropping.

Reverting rather than patching because the good work here - the RHI frame
lifecycle wiring and a genuine render-state-cache staleness fix - is small
enough to redo cleanly against a tightened spec, while untangling it from 300+
files of unrelated churn is not.

Post-revert: Release build clean, App suite back to 3,843 passed / 3 skipped,
offline pixel gate passing at 19 differing pixels.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-07-27 18:27:52 +02:00
parent ceec3bc440
commit 9aaf97e785
334 changed files with 3841 additions and 3661 deletions

View file

@ -1,4 +1,4 @@
using Chorizite.Core.Lib;
using Chorizite.Core.Lib;
using Chorizite.Core.Render;
using Chorizite.Core.Render.Enums;
using DatReaderWriter.DBObjs;
@ -26,7 +26,7 @@ namespace AcDream.App.Rendering.Wb
/// <summary>
/// GPU-side render data created on the main thread.
/// </summary>
internal class ObjectRenderData
public class ObjectRenderData
{
public uint VAO { get; set; }
public uint VBO { get; set; }
@ -74,7 +74,7 @@ namespace AcDream.App.Rendering.Wb
/// <summary>
/// A single GPU draw batch: IBO + texture array layer.
/// </summary>
internal class ObjectRenderBatch
public class ObjectRenderBatch
{
public uint IBO { get; set; }
public int IndexCount { get; set; }
@ -101,7 +101,7 @@ namespace AcDream.App.Rendering.Wb
/// Key design: mesh data is prepared on background threads via PrepareMeshData(),
/// then GPU resources are created on the main thread via UploadMeshData().
/// </summary>
internal class ObjectMeshManager : IDisposable
public class ObjectMeshManager : IDisposable
{
private readonly OpenGLGraphicsDevice _graphicsDevice;
private readonly IPreparedAssetSource _preparedAssets;
@ -171,7 +171,7 @@ namespace AcDream.App.Rendering.Wb
private volatile bool _arenaBackpressured;
/// <summary>#125: how many times a failed GL upload is re-staged before
/// giving up loudly. Small — a transient GL error clears on the next
/// giving up loudly. Small a transient GL error clears on the next
/// frame; anything that fails this many times is a genuine defect to
/// surface, not retry forever. See <see cref="ObjectMeshData.UploadAttempts"/>.</summary>
public const int MaxUploadRetries = 3;
@ -179,8 +179,8 @@ namespace AcDream.App.Rendering.Wb
/// <summary>
/// #125: drain one staged upload, returning whether it should be
/// re-staged for a later frame. The caller (the per-frame Tick drain)
/// collects the re-stages and re-enqueues them AFTER the drain loop —
/// never inside it — so a deterministic failure can't spin the queue in
/// collects the re-stages and re-enqueues them AFTER the drain loop
/// never inside it so a deterministic failure can't spin the queue in
/// a single frame. <see cref="UploadMeshData"/> increments the mesh
/// data's own counter only when new upload work actually starts (not
/// while a prior rollback waits); this drain gives up loudly past
@ -197,7 +197,7 @@ namespace AcDream.App.Rendering.Wb
if (UploadMeshData(meshData) is not null)
{
_stagedMeshData.Complete(item);
return false; // success (incl. legitimate 0-vertex → empty render data)
return false; // success (incl. legitimate 0-vertex empty render data)
}
if (HasRenderData(meshData.ObjectId))
{
@ -215,7 +215,7 @@ namespace AcDream.App.Rendering.Wb
if (meshData.UploadAttempts < MaxUploadRetries)
return true; // re-stage for next frame
_stagedMeshData.Complete(item);
Console.WriteLine($"[up-retry] 0x{meshData.ObjectId:X10} upload failed {meshData.UploadAttempts}x — giving up (was the #125 silent sticky drop; a GL error is being surfaced, not hidden)");
Console.WriteLine($"[up-retry] 0x{meshData.ObjectId:X10} upload failed {meshData.UploadAttempts}x giving up (was the #125 silent sticky drop; a GL error is being surfaced, not hidden)");
return false;
}
@ -570,7 +570,7 @@ namespace AcDream.App.Rendering.Wb
/// <summary>
/// #105 diagnostic: counts staged-but-unflushed texture layer updates across all
/// shared atlases (see <see cref="ManagedGLTextureArray.PendingUpdateCount"/>).
/// Render thread only — <c>_globalAtlases</c> is render-thread-owned.
/// Render thread only <c>_globalAtlases</c> is render-thread-owned.
/// </summary>
public (int PendingUpdates, int ArraysWithPending, int TotalArrays) GetPendingTextureUpdateStats()
{
@ -838,7 +838,7 @@ namespace AcDream.App.Rendering.Wb
_cpuMeshCache.Clear();
}
internal struct EnvCellGeomRequest
public struct EnvCellGeomRequest
{
public uint SourceCellId;
public uint EnvironmentId;
@ -1520,14 +1520,14 @@ namespace AcDream.App.Rendering.Wb
{
// 0-vertex mesh: every polygon was gated out at extraction. #119
// (2026-06-11) dat-verified this is LEGITIMATE for all-no-draw
// models (all polys NoPos + Base1Solid surfaces — retail's
// models (all polys NoPos + Base1Solid surfaces retail's
// skipNoTexture never draws them either; 0x010002B4/0x010008A8
// are this class, Issue119UpNullGfxObjDumpTests). The empty
// cache is the correct terminal state for those. The line stays
// as a tripwire for the OTHER way to get here (extraction
// dropped textured polys — a real defect; dat-verify with the
// dropped textured polys a real defect; dat-verify with the
// dump test before treating as one).
Console.WriteLine($"[up-null] 0x{meshData.ObjectId:X10} produced a 0-vertex mesh — caching empty render data (legitimate for all-no-draw models; dat-verify via Issue119UpNullGfxObjDumpTests)");
Console.WriteLine($"[up-null] 0x{meshData.ObjectId:X10} produced a 0-vertex mesh caching empty render data (legitimate for all-no-draw models; dat-verify via Issue119UpNullGfxObjDumpTests)");
renderData = new ObjectRenderData();
}
@ -1611,7 +1611,7 @@ namespace AcDream.App.Rendering.Wb
/// <summary>
/// Plans the actual GL work the next object would trigger against the
/// current atlas inventory. This includes array storage, global-buffer
/// growth/copies, and one full mip generation per newly-dirtied array—not merely the
/// growth/copies, and one full mip generation per newly-dirtied arraynot merely the
/// source byte arrays held by ObjectMeshData.
/// </summary>
internal MeshUploadCost PlanUploadCost(
@ -1852,7 +1852,7 @@ namespace AcDream.App.Rendering.Wb
#region Private: Background Preparation
/// <summary>
/// #113: the set of polygon ids referenced by the GfxObj's drawing BSP —
/// #113: the set of polygon ids referenced by the GfxObj's drawing BSP
/// the polys retail actually renders (D3DPolyRender traverses the BSP;
/// dictionary-orphaned polys are physics/no-draw geometry). Returns null
/// when the model has no drawing BSP (caller draws everything).
@ -1985,7 +1985,7 @@ namespace AcDream.App.Rendering.Wb
}
atlasManager.LastUseSequence = ++_atlasUseSequence;
// MP1a: AcDream.Content is Silk.NET-free — the extraction records
// MP1a: AcDream.Content is Silk.NET-free the extraction records
// carry Content-owned UploadPixelFormat/UploadPixelType enums whose
// underlying values are the GL ABI constants (numerically identical
// to Silk.NET.OpenGL.PixelFormat/PixelType), so this lifted nullable
@ -2591,7 +2591,7 @@ namespace AcDream.App.Rendering.Wb
// disposes the DatCollection right after this adapter chain, which
// unmaps the dats' memory-mapped views. A worker still inside
// MemoryMappedBlockAllocator.ReadBlock at that point dereferences the
// dead view pointer — an uncatchable, process-fatal AccessViolation
// dead view pointer an uncatchable, process-fatal AccessViolation
// (dat-race investigation 2026-06-09). Setting IsDisposed under the
// queue lock publishes it to workers, which re-check it before every
// dequeue; draining the queue means each worker exits after at most