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:
parent
ceec3bc440
commit
9aaf97e785
334 changed files with 3841 additions and 3661 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
|
@ -20,7 +20,7 @@ namespace AcDream.App.UI;
|
|||
/// Display-only text remains click-through and cannot steal focus or window drag.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
internal sealed class UiText : UiElement, IUiDatStateful
|
||||
public sealed class UiText : UiElement, IUiDatStateful
|
||||
{
|
||||
/// <summary>Optional base-element click notice used by authored text tabs.</summary>
|
||||
public Action? OnClick { get; set; }
|
||||
|
|
@ -30,11 +30,11 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
public uint ElementId { get; set; }
|
||||
|
||||
/// <summary>One display line: pre-formatted text + its colour.</summary>
|
||||
internal readonly record struct Line(string Text, Vector4 Color);
|
||||
public readonly record struct Line(string Text, Vector4 Color);
|
||||
|
||||
/// <summary>A caret position: a line index into the cached line list plus a
|
||||
/// character index (0..line.Text.Length, i.e. a caret slot between glyphs).</summary>
|
||||
internal readonly record struct Pos(int Line, int Col);
|
||||
public readonly record struct Pos(int Line, int Col);
|
||||
|
||||
/// <summary>Provider of the lines to show, oldest-first. Polled each frame.</summary>
|
||||
public Func<IReadOnlyList<Line>> LinesProvider { get; set; } = static () => Array.Empty<Line>();
|
||||
|
|
@ -58,7 +58,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
/// otherwise white (<see cref="Vector4.One"/>).
|
||||
///
|
||||
/// <para>Controllers that supply a per-line color via <see cref="LinesProvider"/>
|
||||
/// (e.g. <c>new UiText.Line(text, explicitColor)</c>) are unaffected — they always
|
||||
/// (e.g. <c>new UiText.Line(text, explicitColor)</c>) are unaffected — they always
|
||||
/// win over this default. This property is only a convenience starting point for
|
||||
/// controllers that want to read the dat color rather than hard-code it.</para>
|
||||
/// </summary>
|
||||
|
|
@ -84,7 +84,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
|
||||
/// <summary>Resolves a dat RenderSurface id to (GL tex handle, pixel width, pixel height).
|
||||
/// Required when <see cref="BackgroundSprite"/> is non-zero.</summary>
|
||||
public Func<uint, (GpuTextureSlot tex, int w, int h)>? SpriteResolve { get; set; }
|
||||
public Func<uint, (uint tex, int w, int h)>? SpriteResolve { get; set; }
|
||||
|
||||
/// <summary>Highlight colour painted behind a selected character span.</summary>
|
||||
public Vector4 SelectionColor { get; set; } = new(0.25f, 0.45f, 0.85f, 0.5f);
|
||||
|
|
@ -138,7 +138,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
/// <summary>Static right-aligned single-line mode: draws the FIRST line right-justified
|
||||
/// within the element rect, vertically centered, with NO scroll/selection machinery.
|
||||
/// Used for value labels in attribute/skill rows where the number must hug the right edge.
|
||||
/// Mutually exclusive with <see cref="Centered"/> — if both are true, Centered takes
|
||||
/// Mutually exclusive with <see cref="Centered"/> — if both are true, Centered takes
|
||||
/// precedence. Pair with <c>ClickThrough = true</c> for non-interactive labels.</summary>
|
||||
public bool RightAligned { get; set; }
|
||||
|
||||
|
|
@ -146,20 +146,20 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
/// Vertical position of the text within the element rect in single-line mode
|
||||
/// (<see cref="Centered"/> or <see cref="RightAligned"/>).
|
||||
/// <list type="bullet">
|
||||
/// <item><description><b>Center</b> (default) — vertically centered, matching the original
|
||||
/// <item><description><b>Center</b> (default) — vertically centered, matching the original
|
||||
/// behavior of the centered/right-aligned paths.</description></item>
|
||||
/// <item><description><b>Top</b> — text is placed at <c>y = Padding</c> (top of the content
|
||||
/// <item><description><b>Top</b> — text is placed at <c>y = Padding</c> (top of the content
|
||||
/// area), so the text sits at the top of the element rather than centering in it.
|
||||
/// Used for footer title elements whose dat box is the full footer height (55 px) but
|
||||
/// the text should render near the top.</description></item>
|
||||
/// <item><description><b>Bottom</b> — text is placed at <c>y = Height - lineHeight - Padding</c>.</description></item>
|
||||
/// <item><description><b>Bottom</b> — text is placed at <c>y = Height - lineHeight - Padding</c>.</description></item>
|
||||
/// </list>
|
||||
/// Only meaningful when <see cref="Centered"/> or <see cref="RightAligned"/> is true.
|
||||
/// Has no effect on the scrollable multi-line path.
|
||||
/// </summary>
|
||||
public VJustify VerticalJustify { get; set; } = VJustify.Center;
|
||||
|
||||
/// <summary>The scroll model — also read by the linked UiScrollbar.</summary>
|
||||
/// <summary>The scroll model — also read by the linked UiScrollbar.</summary>
|
||||
public UiScrollable Scroll { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -179,7 +179,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
|
||||
private const float WheelLines = 1f; // lines advanced per wheel notch (retail = 1 line per notch)
|
||||
|
||||
// ── Cached layout from the last OnDraw, so OnEvent hit-tests the SAME geometry ──
|
||||
// ── Cached layout from the last OnDraw, so OnEvent hit-tests the SAME geometry ──
|
||||
private IReadOnlyList<Line> _lastLines = Array.Empty<Line>();
|
||||
private BitmapFont? _lastFont;
|
||||
private UiDatFont? _lastDatFont;
|
||||
|
|
@ -193,7 +193,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
private bool _drawTextAfterChildren;
|
||||
private bool _honorDatVerticalJustification;
|
||||
|
||||
// ── Selection state ──────────────────────────────────────────────────
|
||||
// ── Selection state ──────────────────────────────────────────────────
|
||||
private Pos? _selAnchor; // where the drag started
|
||||
private Pos? _selCaret; // where the drag currently is
|
||||
private bool _selecting;
|
||||
|
|
@ -325,7 +325,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
|
||||
/// <summary>
|
||||
/// Clamp a scroll offset to [0, max] where max = content-height - view-height
|
||||
/// (never negative — when everything fits, scroll is pinned to 0). Exposed for tests.
|
||||
/// (never negative — when everything fits, scroll is pinned to 0). Exposed for tests.
|
||||
/// </summary>
|
||||
public static float ClampScroll(float scroll, float contentHeight, float viewHeight)
|
||||
{
|
||||
|
|
@ -340,14 +340,14 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
if (BackgroundSprite != 0 && SpriteResolve is { } sr)
|
||||
{
|
||||
var (tex, tw, th) = sr(BackgroundSprite);
|
||||
if (tex.IsAssigned && tw != 0 && th != 0)
|
||||
if (tex != 0 && tw != 0 && th != 0)
|
||||
ctx.DrawSprite(tex, 0, 0, Width, Height, 0, 0, Width / tw, Height / th, Vector4.One);
|
||||
}
|
||||
|
||||
// Background must draw UNDER the transcript text. DrawStringDat emits into the
|
||||
// sprite bucket which flushes BEFORE rects, so a DrawRect background would wash
|
||||
// over the text. DrawFill routes the background through the sprite bucket too,
|
||||
// submitted first → text on top.
|
||||
// submitted first → text on top.
|
||||
ctx.DrawFill(0, 0, Width, Height, BackgroundColor);
|
||||
|
||||
if (!_drawTextAfterChildren)
|
||||
|
|
@ -520,7 +520,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
hx = lineX + bitmapFont!.MeasureWidth(text.Substring(0, c0));
|
||||
hw = bitmapFont.MeasureWidth(text.Substring(c0, c1 - c0));
|
||||
}
|
||||
// Highlight sits BEHIND the line's text → sprite bucket, submitted
|
||||
// Highlight sits BEHIND the line's text → sprite bucket, submitted
|
||||
// before this line's DrawStringDat.
|
||||
ctx.DrawFill(hx, y, hw, lh, SelectionColor);
|
||||
}
|
||||
|
|
@ -572,7 +572,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
if (!Selectable && !WheelScrollEnabled) return false;
|
||||
// Silk wheel +Y = scroll up = reveal older = toward the TOP = decrease ScrollY.
|
||||
// ScrollByLines sign: +down/newer, -up/older.
|
||||
// e.Data0 > 0 → wheel up → want older → ScrollByLines with negative lines.
|
||||
// e.Data0 > 0 → wheel up → want older → ScrollByLines with negative lines.
|
||||
Scroll.ScrollByLines((int)(-e.Data0 * WheelLines));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -616,7 +616,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
|| Keyboard.IsKeyPressed(Silk.NET.Input.Key.ControlRight));
|
||||
if (ctrl && key == Silk.NET.Input.Key.C)
|
||||
{
|
||||
// Only touch the clipboard when there's a selection — an empty
|
||||
// Only touch the clipboard when there's a selection — an empty
|
||||
// copy must NOT clobber what the user previously copied.
|
||||
if (Keyboard is not null)
|
||||
{
|
||||
|
|
@ -636,7 +636,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
return false;
|
||||
}
|
||||
|
||||
// ── Selection helpers ────────────────────────────────────────────────
|
||||
// ── Selection helpers ────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Select the entire cached transcript (Ctrl+A).</summary>
|
||||
private void SelectAll()
|
||||
|
|
@ -670,7 +670,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
return SelectedText(_lastLines, start, end);
|
||||
}
|
||||
|
||||
// ── Pure, testable logic (no GL / no font texture) ───────────────────
|
||||
// ── Pure, testable logic (no GL / no font texture) ───────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Compute the Y offset (local space) for a single line in the Centered/RightAligned
|
||||
|
|
@ -731,7 +731,7 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
/// <paramref name="end"/> (inclusive of start.Col, exclusive of end.Col) from
|
||||
/// <paramref name="lines"/>. Multi-line selections are joined with "\n":
|
||||
/// the first line from start.Col to its end, whole middle lines, and the last
|
||||
/// line up to end.Col. Pure — unit-testable without GL.
|
||||
/// line up to end.Col. Pure — unit-testable without GL.
|
||||
/// </summary>
|
||||
public static string SelectedText(IReadOnlyList<Line> lines, Pos start, Pos end)
|
||||
{
|
||||
|
|
@ -870,8 +870,8 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
/// The caret column for a horizontal position <paramref name="x"/> (already
|
||||
/// adjusted for the left padding, so x=0 is the start of the text). Walks the
|
||||
/// string accumulating each glyph's advance and snaps the caret to whichever
|
||||
/// side of the glyph midpoint <paramref name="x"/> falls on — natural
|
||||
/// Windows-like caret placement. Pure — unit-testable with a synthetic advance.
|
||||
/// side of the glyph midpoint <paramref name="x"/> falls on — natural
|
||||
/// Windows-like caret placement. Pure — unit-testable with a synthetic advance.
|
||||
/// </summary>
|
||||
/// <param name="text">The line text.</param>
|
||||
/// <param name="advanceOf">Per-character advance (pixels) lookup.</param>
|
||||
|
|
@ -888,6 +888,6 @@ internal sealed class UiText : UiElement, IUiDatStateful
|
|||
if (x < mid) return i; // caret sits before this glyph
|
||||
cursor += adv;
|
||||
}
|
||||
return text.Length; // past the last glyph → end caret
|
||||
return text.Length; // past the last glyph → end caret
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue