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>
198 lines
6.8 KiB
C#
198 lines
6.8 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace AcDream.App.Studio;
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// UiDumpModel — POCOs for docs/research/2026-06-25-retail-ui-layout-dump.json
|
|
//
|
|
// Schema (v1):
|
|
// { "version":1, "panels":[ { "id":int, "slug":string, "title":string,
|
|
// "bucket":string, "parent_slug":string|null,
|
|
// "width":int, "height":int,
|
|
// "nodes":[ { "traversal_index":int, "element_id":int,
|
|
// "layout_id":int, "parent_layout_id":int|null,
|
|
// "parent_traversal_index":int|null, "base_layout_id":int,
|
|
// "rect":{x,y,width,height},
|
|
// "widget_kind":"Group"|"Sprite"|"Button"|"Scrollbar"|"Slider",
|
|
// "state_set":{ "default_image":{image_id,alpha_image_id}|null,
|
|
// "states":[{state_id,image:{...}}] }
|
|
// } ] } ] }
|
|
//
|
|
// All ids in the dump are DECIMAL ints (e.g. element_id=268435925 = 0x100001D5,
|
|
// image_id=100693194 = 0x060074CA). Cast to uint before use in dat/GL APIs.
|
|
//
|
|
// Rect coordinates are ABSOLUTE (screen-space origin = panel's design position
|
|
// in retail layout, NOT relative to the parent). DumpLayout.Load converts them
|
|
// to parent-relative when building the UiElement tree.
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Top-level container for the retail UI layout dump.</summary>
|
|
public sealed class UiDump
|
|
{
|
|
[JsonPropertyName("version")]
|
|
public int Version { get; set; }
|
|
|
|
[JsonPropertyName("panels")]
|
|
public List<DumpPanel> Panels { get; set; } = new();
|
|
}
|
|
|
|
/// <summary>One panel (window) exported from the retail UI.</summary>
|
|
public sealed class DumpPanel
|
|
{
|
|
[JsonPropertyName("id")]
|
|
public long Id { get; set; }
|
|
|
|
[JsonPropertyName("slug")]
|
|
public string Slug { get; set; } = "";
|
|
|
|
[JsonPropertyName("title")]
|
|
public string Title { get; set; } = "";
|
|
|
|
[JsonPropertyName("bucket")]
|
|
public string Bucket { get; set; } = "";
|
|
|
|
[JsonPropertyName("parent_slug")]
|
|
public string? ParentSlug { get; set; }
|
|
|
|
[JsonPropertyName("width")]
|
|
public float Width { get; set; }
|
|
|
|
[JsonPropertyName("height")]
|
|
public float Height { get; set; }
|
|
|
|
[JsonPropertyName("nodes")]
|
|
public List<DumpNode> Nodes { get; set; } = new();
|
|
}
|
|
|
|
/// <summary>One element node within a panel's traversal list.</summary>
|
|
public sealed class DumpNode
|
|
{
|
|
[JsonPropertyName("traversal_index")]
|
|
public int TraversalIndex { get; set; }
|
|
|
|
[JsonPropertyName("element_id")]
|
|
public long ElementId { get; set; }
|
|
|
|
[JsonPropertyName("layout_id")]
|
|
public long LayoutId { get; set; }
|
|
|
|
[JsonPropertyName("parent_layout_id")]
|
|
public long? ParentLayoutId { get; set; }
|
|
|
|
[JsonPropertyName("parent_traversal_index")]
|
|
public int? ParentTraversalIndex { get; set; }
|
|
|
|
[JsonPropertyName("base_layout_id")]
|
|
public long BaseLayoutId { get; set; }
|
|
|
|
[JsonPropertyName("rect")]
|
|
public DumpRect Rect { get; set; } = new();
|
|
|
|
[JsonPropertyName("widget_kind")]
|
|
public string WidgetKind { get; set; } = "Group";
|
|
|
|
[JsonPropertyName("state_set")]
|
|
public DumpStateSet StateSet { get; set; } = new();
|
|
}
|
|
|
|
/// <summary>Absolute screen-space rect (see comment above — must subtract parent rect for UiElement).</summary>
|
|
public sealed class DumpRect
|
|
{
|
|
[JsonPropertyName("x")]
|
|
public float X { get; set; }
|
|
|
|
[JsonPropertyName("y")]
|
|
public float Y { get; set; }
|
|
|
|
[JsonPropertyName("width")]
|
|
public float Width { get; set; }
|
|
|
|
[JsonPropertyName("height")]
|
|
public float Height { get; set; }
|
|
}
|
|
|
|
/// <summary>State set for a node — default image plus per-state overrides.</summary>
|
|
public sealed class DumpStateSet
|
|
{
|
|
[JsonPropertyName("default_image")]
|
|
public DumpImage? DefaultImage { get; set; }
|
|
|
|
[JsonPropertyName("states")]
|
|
public List<DumpState> States { get; set; } = new();
|
|
}
|
|
|
|
/// <summary>Image reference (RenderSurface dat id + optional separate alpha surface).</summary>
|
|
public sealed class DumpImage
|
|
{
|
|
[JsonPropertyName("image_id")]
|
|
public long ImageId { get; set; }
|
|
|
|
[JsonPropertyName("alpha_image_id")]
|
|
public long? AlphaImageId { get; set; }
|
|
}
|
|
|
|
/// <summary>A named state override.</summary>
|
|
public sealed class DumpState
|
|
{
|
|
[JsonPropertyName("state_id")]
|
|
public int StateId { get; set; }
|
|
|
|
[JsonPropertyName("image")]
|
|
public DumpImage Image { get; set; } = new();
|
|
}
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// Helper statics
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Parsing helpers for the retail UI dump JSON.
|
|
/// </summary>
|
|
public static class UiDumpModel
|
|
{
|
|
private static readonly JsonSerializerOptions _opts = new()
|
|
{
|
|
PropertyNameCaseInsensitive = true,
|
|
AllowTrailingCommas = true,
|
|
ReadCommentHandling = JsonCommentHandling.Skip,
|
|
};
|
|
|
|
/// <summary>Parse the full dump from a file path. Returns null on failure.</summary>
|
|
public static UiDump? Parse(string path)
|
|
{
|
|
try
|
|
{
|
|
using var stream = File.OpenRead(path);
|
|
return JsonSerializer.Deserialize<UiDump>(stream, _opts);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the list of slugs in the dump (for smoke-testing every panel).
|
|
/// Returns an empty list if the file cannot be parsed.
|
|
/// </summary>
|
|
public static IReadOnlyList<string> ListSlugs(string path)
|
|
{
|
|
var dump = Parse(path);
|
|
if (dump is null) return Array.Empty<string>();
|
|
return dump.Panels.Select(p => p.Slug).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Pick the sprite id to use for a node: prefer default_image.image_id;
|
|
/// fall back to states[0].image.image_id; return 0 if neither exists.
|
|
/// </summary>
|
|
public static uint PickImageId(DumpNode node)
|
|
{
|
|
if (node.StateSet.DefaultImage is { ImageId: > 0 } di)
|
|
return (uint)di.ImageId;
|
|
if (node.StateSet.States.Count > 0 && node.StateSet.States[0].Image.ImageId > 0)
|
|
return (uint)node.StateSet.States[0].Image.ImageId;
|
|
return 0u;
|
|
}
|
|
}
|