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,11 +1,11 @@
using System;
using System;
using System.Numerics;
using AcDream.App.UI.Layout;
namespace AcDream.App.UI;
/// <summary>
/// Generic dat-widget button — the production replacement for any dat element of
/// Generic dat-widget button the production replacement for any dat element of
/// Type 1 (UIElement_Button, registered via RegisterElementClass(1, UIElement_Button::Create)
/// @ acclient_2013_pseudo_c.txt:125828).
///
@ -21,7 +21,7 @@ namespace AcDream.App.UI;
/// <para>
/// State selection: picks <see cref="ElementInfo.DefaultStateName"/> if set, then
/// "Normal" if the element has a Normal state sprite, then falls back to the unnamed
/// DirectState ("" key) — identical to <see cref="UiDatElement"/>.
/// DirectState ("" key) identical to <see cref="UiDatElement"/>.
/// </para>
///
/// <para>
@ -30,12 +30,12 @@ namespace AcDream.App.UI;
/// earlier dev-scaffold widget with no dat sprites.
/// </para>
/// </summary>
internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStateful
public sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStateful
{
private readonly ElementInfo _info;
private readonly ElementInfo _mediaInfo;
private readonly FaceSegment[] _faceSegments;
private readonly Func<uint, (GpuTextureSlot tex, int w, int h)> _resolve;
private readonly Func<uint, (uint tex, int w, int h)> _resolve;
private readonly HashSet<uint> _availableStates = new();
private bool _pressed;
private bool _pointerOver;
@ -103,7 +103,7 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
public LabelAlignment LabelAlign { get; set; } = LabelAlignment.Center;
/// <summary>Label horizontal alignment options.</summary>
internal enum LabelAlignment { Center, Left }
public enum LabelAlignment { Center, Left }
public bool ToggleBehavior { get; }
public bool RolloverEnabled { get; }
@ -123,7 +123,7 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
}
/// <summary>
/// Active state name, runtime-settable (e.g. Max/Min toggling Normal ↔ Minimized).
/// Active state name, runtime-settable (e.g. Max/Min toggling Normal Minimized).
/// Matches <see cref="UiDatElement.ActiveState"/>.
/// </summary>
public string ActiveState { get; set; } = "";
@ -198,11 +198,11 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
}
/// <param name="info">Merged <see cref="ElementInfo"/> for this element.</param>
/// <param name="resolve">Dat file-id → (GL texture handle, native px width, native px height).
/// <param name="resolve">Dat file-id (GL texture handle, native px width, native px height).
/// Returns (0,0,0) when the texture is not yet uploaded.</param>
public UiButton(
ElementInfo info,
Func<uint, (GpuTextureSlot tex, int w, int h)> resolve,
Func<uint, (uint tex, int w, int h)> resolve,
ElementInfo? mediaInfo = null,
IReadOnlyList<ElementInfo>? faceSegments = null)
{
@ -212,7 +212,7 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
? []
: faceSegments.Select(static segment => new FaceSegment(segment)).ToArray();
_resolve = resolve;
ClickThrough = false; // buttons are interactive — opt OUT of click-through
ClickThrough = false; // buttons are interactive opt OUT of click-through
// Visual transitions can select only states with an actual button face.
// Retail layouts commonly declare an empty Normal_pressed descriptor while
@ -254,7 +254,7 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
/// procedurally, so the importer must not build the button's children as widgets.</summary>
public override bool ConsumesDatChildren => true;
/// <summary>A button is interactive — it must receive its Click even inside a whole-window-Draggable
/// <summary>A button is interactive it must receive its Click even inside a whole-window-Draggable
/// frame (e.g. the paperdoll "Slots" toggle in the inventory window), so it opts out of the
/// IA-12 whole-window-drag that would otherwise swallow the press.</summary>
public override bool HandlesClick => true;
@ -282,9 +282,9 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
if (file != 0)
{
var (tex, tw, th) = _resolve(file);
if (tex.IsAssigned && tw != 0 && th != 0)
if (tex != 0 && tw != 0 && th != 0)
{
// Tiled draw — same call shape as UiDatElement.OnDraw (UV-repeat; GL_REPEAT-wrapped
// Tiled draw same call shape as UiDatElement.OnDraw (UV-repeat; GL_REPEAT-wrapped
// UI texture). Matches ImgTex::TileCSI; no Stretch mode exists.
float faceWidth = FaceWidth > 0f ? FaceWidth : Width;
float faceHeight = FaceHeight > 0f ? FaceHeight : Height;
@ -312,7 +312,7 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
if (dragSprite != 0)
{
var (tex, _, _) = _resolve(dragSprite);
if (tex.IsAssigned)
if (tex != 0)
ctx.DrawSprite(tex, 0f, 0f, Width, Height, 0f, 0f, 1f, 1f, Vector4.One);
}
}
@ -322,7 +322,7 @@ internal sealed class UiButton : UiElement, IUiGlobalTimeListener, IUiDatStatefu
if (file == 0 || rect.Width <= 0 || rect.Height <= 0)
return;
var (texture, textureWidth, textureHeight) = _resolve(file);
if (!texture.IsAssigned || textureWidth == 0 || textureHeight == 0)
if (texture == 0 || textureWidth == 0 || textureHeight == 0)
return;
// Same tiled/cropped media path as UiDatElement. Segment geometry is