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,13 +1,13 @@
using System;
using System;
using System.Collections.Generic;
using System.Numerics;
namespace AcDream.App.UI;
/// <summary>Which parent edges a child keeps a fixed margin to on resize.
/// Left+Right ⇒ width stretches; Top+Bottom ⇒ height stretches.</summary>
/// Left+Right ⇒ width stretches; Top+Bottom ⇒ height stretches.</summary>
[System.Flags]
internal enum AnchorEdges { None = 0, Left = 1, Top = 2, Right = 4, Bottom = 8 }
public enum AnchorEdges { None = 0, Left = 1, Top = 2, Right = 4, Bottom = 8 }
/// <summary>Retail dat cursor media attached to a UI state.</summary>
public readonly record struct UiCursorMedia(uint File, int HotspotX, int HotspotY)
@ -21,7 +21,7 @@ public readonly record struct UiCursorMedia(uint File, int HotspotX, int Hotspot
/// Design notes:
/// - Retail AC delegates widget semantics to the external
/// <c>keystone.dll</c> library (see
/// <c>docs/research/retail-ui/02-class-hierarchy.md</c> — there is no
/// <c>docs/research/retail-ui/02-class-hierarchy.md</c> there is no
/// widget hierarchy inside <c>acclient.exe</c> itself). We implement
/// our own retained-mode toolkit here, matching the <i>behavior</i>
/// described in the decompile without trying to byte-match Keystone's
@ -35,13 +35,13 @@ public readonly record struct UiCursorMedia(uint File, int HotspotX, int Hotspot
/// - Coordinates are in <b>screen pixels</b>, origin top-left.
/// <see cref="Bounds"/> is in the parent's local coordinate space.
/// </summary>
internal abstract class UiElement
public abstract class UiElement
{
// ── Identity ─────────────────────────────────────────────────────────
// ── Identity ─────────────────────────────────────────────────────────
/// <summary>
/// Unique 32-bit event ID. Retail uses the range <c>0x10000000+</c>
/// for custom app events (see
/// <c>docs/research/retail-ui/04-input-events.md §3</c>). Assigned
/// <c>docs/research/retail-ui/04-input-events.md §3</c>). Assigned
/// by <see cref="UiRoot"/> when the element is added to the tree.
/// </summary>
public uint EventId { get; internal set; }
@ -96,7 +96,7 @@ internal abstract class UiElement
return default;
}
// ── Geometry ────────────────────────────────────────────────────────
// ── Geometry ────────────────────────────────────────────────────────
/// <summary>X in the parent's local pixel space.</summary>
public float Left { get; set; }
public float Top { get; set; }
@ -119,7 +119,7 @@ internal abstract class UiElement
}
}
// ── State flags ─────────────────────────────────────────────────────
// ── State flags ─────────────────────────────────────────────────────
private bool _visible = true;
public bool Visible
{
@ -152,7 +152,7 @@ internal abstract class UiElement
}
/// <summary>
/// If true, <see cref="HitTest"/> skips this element — the event
/// If true, <see cref="HitTest"/> skips this element the event
/// passes through to whatever is behind. Used by decoration widgets
/// (portrait frames, ornamental dividers).
/// </summary>
@ -212,13 +212,13 @@ internal abstract class UiElement
/// <summary>If true, a left-drag starting on this element is delivered to the
/// element (e.g. text selection) instead of moving/resizing an ancestor window.
/// Edge resize on a resizable ancestor still wins — only the interior move /
/// Edge resize on a resizable ancestor still wins only the interior move /
/// drag-drop candidacy is suppressed in favour of the element's own handling.</summary>
public bool CapturesPointerDrag { get; set; }
/// <summary>If true, a left-press-and-move on this element starts a DRAG-DROP
/// (<see cref="UiRoot"/> promotes to BeginDrag) rather than moving a Draggable
/// ancestor window — so an item cell inside the toolbar frame drags the item, not
/// ancestor window so an item cell inside the toolbar frame drags the item, not
/// the window. Distinct from <see cref="CapturesPointerDrag"/> (a self-driven
/// interior drag like text selection, which does NOT promote to BeginDrag). Default
/// false; overridden by drag sources (e.g. an occupied <see cref="UiItemSlot"/>).</summary>
@ -227,7 +227,7 @@ internal abstract class UiElement
/// <summary>If true, a left-press on this element is handled BY the element (it receives the Click
/// on release) instead of being captured as a whole-window move on a Draggable ancestor. Set by
/// interactive leaf widgets (e.g. <see cref="UiButton"/>) so they stay clickable inside a
/// whole-window-Draggable frame like the inventory window — where, without this, the IA-12
/// whole-window-Draggable frame like the inventory window where, without this, the IA-12
/// whole-window-drag swallows the press and the Click is never emitted. Distinct from
/// <see cref="IsDragSource"/> (starts a drag-drop) and <see cref="CapturesPointerDrag"/> (a
/// self-driven interior drag such as text selection). Default false.</summary>
@ -260,7 +260,7 @@ internal abstract class UiElement
ResizeEdges.Left | ResizeEdges.Right | ResizeEdges.Top | ResizeEdges.Bottom;
/// <summary>Edges this element anchors to in its parent. Default Left|Top
/// (pinned top-left, fixed size — no reflow). Left|Right stretches width.</summary>
/// (pinned top-left, fixed size no reflow). Left|Right stretches width.</summary>
private AnchorEdges _anchors = AnchorEdges.Left | AnchorEdges.Top;
/// <summary>Edges this programmatic element anchors to in its parent. Assigning
@ -284,7 +284,7 @@ internal abstract class UiElement
/// </summary>
public UiLayoutPolicy? LayoutPolicy { get; set; }
// ── Tree structure ──────────────────────────────────────────────────
// ── Tree structure ──────────────────────────────────────────────────
public UiElement? Parent { get; private set; }
private readonly List<UiElement> _children = new();
@ -355,7 +355,7 @@ internal abstract class UiElement
/// <summary>
/// True if this widget draws its full appearance itself and REPRODUCES its dat
/// sub-elements procedurally (3-slice caps, button labels, scroll arrows, popup
/// rows…) — so the <see cref="AcDream.App.UI.Layout.LayoutImporter"/> must NOT build
/// rows…) — so the <see cref="AcDream.App.UI.Layout.LayoutImporter"/> must NOT build
/// those dat child elements as separate widgets (they would double-draw and, worse,
/// steal pointer/focus from the behavioral widget). All registered behavioral widgets
/// (Meter/Menu/Button/Scrollbar/Text/Field) return <c>true</c>; the generic container
@ -365,7 +365,7 @@ internal abstract class UiElement
/// </summary>
public virtual bool ConsumesDatChildren => false;
// ── Virtual overrides ───────────────────────────────────────────────
// ── Virtual overrides ───────────────────────────────────────────────
/// <summary>
/// Draw THIS element (not its children). Children are composited by
@ -384,7 +384,7 @@ internal abstract class UiElement
/// <summary>
/// Draw content that must sit ON TOP of the ENTIRE UI, regardless of this
/// element's position in the tree — open menus, dropdowns, tooltips. Called in
/// element's position in the tree open menus, dropdowns, tooltips. Called in
/// a SECOND traversal after the whole tree's <see cref="OnDraw"/> pass, with the
/// same accumulated transform/alpha this element had during its normal draw.
/// Retail spawns popups as ROOT elements (UIElement_Menu::MakePopup) for exactly
@ -425,9 +425,9 @@ internal abstract class UiElement
public virtual object? GetDragPayload() => null;
/// <summary>The texture <see cref="UiRoot"/> paints at the cursor while this element
/// is the drag source: (texture-table slot, width, height). Null = no ghost. Keeps
/// is the drag source: (GL handle, width, height). Null = no ghost. Keeps
/// <see cref="UiRoot"/> item-agnostic. Retail analog: m_dragIcon (decomp 229738).</summary>
public virtual (GpuTextureSlot tex, int w, int h)? GetDragGhost() => null;
public virtual (uint tex, int w, int h)? GetDragGhost() => null;
/// <summary>
/// Notifies the source widget when the root starts or finishes carrying its drag payload.
@ -444,7 +444,7 @@ internal abstract class UiElement
/// </summary>
public virtual string? GetTooltipText() => null;
// ── Framework entry points (internal, called by UiRoot) ─────────────
// ── Framework entry points (internal, called by UiRoot) ─────────────
internal void DrawSelfAndChildren(UiRenderContext ctx)
{
@ -551,7 +551,7 @@ internal abstract class UiElement
return null;
// Children first, in reverse Z-order (topmost first). ClickThrough means
// THIS element is transparent to the pointer — but its children are NOT.
// THIS element is transparent to the pointer but its children are NOT.
// A ClickThrough container (e.g. a UiDatElement panel that hosts the chat
// input / transcript) must still let the pointer reach its behavioral
// children, so the ClickThrough check happens AFTER the child walk, gating
@ -571,7 +571,7 @@ internal abstract class UiElement
return OnHitTest(localX, localY) ? this : null;
}
// ── Anchor layout ────────────────────────────────────────────────────
// ── Anchor layout ────────────────────────────────────────────────────
private bool _anchorCaptured;
private float _amL, _amT, _amR, _amB, _aw0, _ah0;
@ -659,7 +659,7 @@ internal abstract class UiElement
}
/// <summary>Walk up to the owning <see cref="UiRoot"/> (the top of the tree), or null
/// if this element is not attached. Lets a widget reach focus/capture services — e.g.
/// if this element is not attached. Lets a widget reach focus/capture services e.g.
/// a chat input blurring itself (exiting write mode) after submit.</summary>
internal UiRoot? FindRoot()
{
@ -668,8 +668,8 @@ internal abstract class UiElement
return e as UiRoot;
}
/// <summary>Compute an anchored child rect. Left&amp;Right ⇒ stretch width
/// (keep both margins); Right only ⇒ pin to right at fixed width; otherwise
/// <summary>Compute an anchored child rect. Left&amp;Right stretch width
/// (keep both margins); Right only pin to right at fixed width; otherwise
/// pin left at fixed width. Same logic vertically.</summary>
public static (float x, float y, float w, float h) ComputeAnchoredRect(
AnchorEdges a, float mL, float mT, float mR, float mB,