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,11 +1,11 @@
|
|||
// PortalProjection.cs
|
||||
// PortalProjection.cs
|
||||
//
|
||||
// Phase A8.F: project a cell-local portal polygon to NDC screen space. Homogeneous frustum clip
|
||||
// in CLIP SPACE (before the perspective divide): first the IN-FRONT-OF-EYE half-space (keep where
|
||||
// w > MinW) so a portal straddling the camera does not invert under the divide and the divide
|
||||
// stays bounded away from the w=0 eye singularity, then the 4 SIDE planes (x,y within ±w) so every
|
||||
// stays bounded away from the w=0 eye singularity, then the 4 SIDE planes (x,y within ±w) so every
|
||||
// surviving vertex lands on the screen [-1,1] by construction. The side-plane clip is the R1
|
||||
// void-flap fix (2026-06-05) — see ProjectToNdc.
|
||||
// void-flap fix (2026-06-05) — see ProjectToNdc.
|
||||
//
|
||||
// The clip is NEAR-INDEPENDENT on purpose. We only use the projected x/y for the visibility clip
|
||||
// REGION, so a vertex in front of the eye is meaningful even if it is closer than the projection's
|
||||
|
|
@ -23,7 +23,7 @@ using System.Numerics;
|
|||
|
||||
namespace AcDream.App.Rendering;
|
||||
|
||||
internal static class PortalProjection
|
||||
public static class PortalProjection
|
||||
{
|
||||
internal ref struct ClipPolygonLease
|
||||
{
|
||||
|
|
@ -118,17 +118,17 @@ internal static class PortalProjection
|
|||
Vector4[]? second = null;
|
||||
|
||||
// Homogeneous frustum clip in CLIP SPACE, before the perspective divide. First the
|
||||
// in-front-of-eye half-space (w > MinW) — near-INDEPENDENT, so a portal the camera is
|
||||
// standing in still projects (see header); then the 4 SIDE planes (x,y within ±w). The
|
||||
// in-front-of-eye half-space (w > MinW) — near-INDEPENDENT, so a portal the camera is
|
||||
// standing in still projects (see header); then the 4 SIDE planes (x,y within ±w). The
|
||||
// side clip is the R1 void-flap fix (2026-06-05): without it, a portal WITHIN the near
|
||||
// plane projected small-w verts to wildly off-screen NDC (the probe saw (10.2,-67.4)),
|
||||
// which corrupted the downstream 2D ScreenPolygonClip into an EMPTY region -> OutsideView
|
||||
// empty -> terrain Skip -> the bluish doorway "void". Clipping the side planes here bounds
|
||||
// every surviving vertex to the screen [-1,1] by construction, so a screen-covering doorway
|
||||
// clips to the screen (non-empty) instead of collapsing. The eye plane is clipped FIRST so
|
||||
// all survivors have w > 0, making the side-plane functionals (w ± x, w ± y) well defined.
|
||||
// all survivors have w > 0, making the side-plane functionals (w ± x, w ± y) well defined.
|
||||
// Near/far are intentionally NOT clipped (near-independence). Retail PView::GetClip
|
||||
// (decomp:0x005a4320) projects + frustum-clips the portal poly likewise (research doc A §3.5).
|
||||
// (decomp:0x005a4320) projects + frustum-clips the portal poly likewise (research doc A §3.5).
|
||||
try
|
||||
{
|
||||
second = vectorPool.Rent(capacity);
|
||||
|
|
@ -155,7 +155,7 @@ internal static class PortalProjection
|
|||
(current, output) = (output, current);
|
||||
}
|
||||
|
||||
// Perspective divide → NDC xy. This is the only result allocation.
|
||||
// Perspective divide → NDC xy. This is the only result allocation.
|
||||
var ndc = new Vector2[currentCount];
|
||||
for (int i = 0; i < currentCount; i++)
|
||||
{
|
||||
|
|
@ -174,21 +174,21 @@ internal static class PortalProjection
|
|||
|
||||
/// <summary>Faithful homogeneous projection (retail PrimD3DRender::xformStart + the W=0 clip of
|
||||
/// ACRender::polyClipFinish, decomp 424310 / 702749): transform the portal to clip space and clip
|
||||
/// ONLY the eye plane (w >= 0, EXACT), keeping homogeneous coords — NO perspective divide, NO
|
||||
/// ONLY the eye plane (w >= 0, EXACT), keeping homogeneous coords — NO perspective divide, NO
|
||||
/// frustum side-plane clamp. The screen bound is applied later by <see cref="ClipToRegion"/>
|
||||
/// against the view region (the root region is the full screen), exactly as retail clips the portal
|
||||
/// against the accumulated portal_view rather than fixed side planes.
|
||||
///
|
||||
/// <para>The W=0 clip is exact on purpose (the knife-edge port, 2026-06-11; pseudocode at
|
||||
/// docs/research/2026-06-11-polyclipfinish-w0-clip-pseudocode.md): boundary intersections land
|
||||
/// at w == 0 — homogeneous DIRECTIONS — so a portal the eye is crossing (stair openings, decks)
|
||||
/// at w == 0 — homogeneous DIRECTIONS — so a portal the eye is crossing (stair openings, decks)
|
||||
/// yields the correct UNBOUNDED half-region, which the bounded view-region clip then cuts to the
|
||||
/// screen. The previous EyePlaneW = 1e-4 produced finite ~1e4-NDC boundary verts whose region
|
||||
/// intersections sat at the dedup/merge degeneracy threshold — the climb-strobe class. A w=0
|
||||
/// intersections sat at the dedup/merge degeneracy threshold — the climb-strobe class. A w=0
|
||||
/// vertex can never survive ClipToRegion into its divide (a nonzero direction fails at least one
|
||||
/// edge test of any BOUNDED convex region), so no divide-by-zero path exists; the measure-zero
|
||||
/// corner case is guarded in ClipToRegion. Matches polyClipFinish part 1: clip pass runs only
|
||||
/// when some vertex has w < 0; <3 survivors → reject (empty).</para></summary>
|
||||
/// when some vertex has w < 0; <3 survivors → reject (empty).</para></summary>
|
||||
public static Vector4[] ProjectToClip(IReadOnlyList<Vector3> localPoly, Matrix4x4 cellToWorld, Matrix4x4 viewProj)
|
||||
{
|
||||
using ClipPolygonLease lease = ProjectToClipLease(localPoly, cellToWorld, viewProj);
|
||||
|
|
@ -274,7 +274,7 @@ internal static class PortalProjection
|
|||
/// (CCW convex) with w-aware Sutherland-Hodgman edge tests, then divide the survivors to NDC and
|
||||
/// normalize to CCW. Ports retail ACRender::polyClipFinish's view-region clip (decomp 702749): the
|
||||
/// edge test multiplies through w (which is > 0 after the eye-plane clip) so it never divides a
|
||||
/// near-eye vertex, and the final divide runs only on survivors already bounded to the region —
|
||||
/// near-eye vertex, and the final divide runs only on survivors already bounded to the region —
|
||||
/// stable by construction. Returns <3 verts when the portal does not intersect the region.</summary>
|
||||
public static Vector2[] ClipToRegion(IReadOnlyList<Vector4> subjectClip, IReadOnlyList<Vector2> regionCcwNdc)
|
||||
{
|
||||
|
|
@ -339,7 +339,7 @@ internal static class PortalProjection
|
|||
|
||||
// Homogeneous Sutherland-Hodgman: clip the (w > 0) subject against each CCW edge of the NDC
|
||||
// region. f(P) below is the NDC inside test cross(edge, P_ndc - a) multiplied through P.W,
|
||||
// which is > 0 after the eye-plane clip — so the sign is the NDC sign yet no near-eye vertex
|
||||
// which is > 0 after the eye-plane clip — so the sign is the NDC sign yet no near-eye vertex
|
||||
// is ever divided (retail polyClipFinish, decomp 702749).
|
||||
int regionCount = regionCcwNdc.Count;
|
||||
int capacity = checked(subjectClip.Length + regionCount);
|
||||
|
|
@ -370,7 +370,7 @@ internal static class PortalProjection
|
|||
if (currentCount < 3)
|
||||
return System.Array.Empty<Vector2>();
|
||||
|
||||
// Divide survivors → NDC. They are already inside the bounded region. A w=0
|
||||
// Divide survivors → NDC. They are already inside the bounded region. A w=0
|
||||
// measure-zero corner remains the same empty knife-edge result as the prior path.
|
||||
ndcScratch = vector2Pool.Rent(currentCount);
|
||||
Span<Vector2> ndc = ndcScratch.AsSpan(0, currentCount);
|
||||
|
|
@ -408,8 +408,8 @@ internal static class PortalProjection
|
|||
// Retail copy_view's ~1-pixel vertex merge (see ClipToRegion). Collapses
|
||||
// runs of consecutive near-identical vertices, including across the
|
||||
// wrap-around. A polygon that collapses below 3 distinct vertices is
|
||||
// degenerate (sub-pixel sliver) and returns empty — exactly retail's
|
||||
// "<3 surviving verts → output count 0".
|
||||
// degenerate (sub-pixel sliver) and returns empty — exactly retail's
|
||||
// "<3 surviving verts → output count 0".
|
||||
private const float VertexMergeEpsilonNdc = 2f / 1080f;
|
||||
|
||||
private static int MergeSubPixelVertices(Span<Vector2> poly)
|
||||
|
|
@ -428,7 +428,7 @@ internal static class PortalProjection
|
|||
}
|
||||
poly[kept++] = vertex;
|
||||
}
|
||||
// Wrap-around: last ≈ first.
|
||||
// Wrap-around: last ≈ first.
|
||||
while (kept >= 2)
|
||||
{
|
||||
Vector2 first = poly[0];
|
||||
|
|
@ -442,9 +442,9 @@ internal static class PortalProjection
|
|||
return kept;
|
||||
}
|
||||
|
||||
// One Sutherland-Hodgman half-plane against the directed NDC edge a→b, keeping the CCW-inside
|
||||
// One Sutherland-Hodgman half-plane against the directed NDC edge a→b, keeping the CCW-inside
|
||||
// (left) part of a HOMOGENEOUS polygon. Inside test for vertex P (clip space): the NDC cross
|
||||
// product cross(b-a, P/P.W - a) scaled by P.W (> 0): ex·(P.Y - P.W·a.Y) - ey·(P.X - P.W·a.X) ≥ 0.
|
||||
// product cross(b-a, P/P.W - a) scaled by P.W (> 0): ex·(P.Y - P.W·a.Y) - ey·(P.X - P.W·a.X) ≥ 0.
|
||||
// Crossings interpolate in homogeneous coords (perspective-correct), via the shared Lerp.
|
||||
private static int ClipHomogeneousEdge(
|
||||
ReadOnlySpan<Vector4> polygon,
|
||||
|
|
@ -489,7 +489,7 @@ internal static class PortalProjection
|
|||
if (area2 < 0f) System.Array.Reverse(poly);
|
||||
}
|
||||
|
||||
// Minimum clip-space w (≈ metres in front of the eye) to keep a vertex. Excludes the eye
|
||||
// Minimum clip-space w (≈ metres in front of the eye) to keep a vertex. Excludes the eye
|
||||
// (w=0) singularity and the ~5 cm right at it (bounding the perspective divide), but is
|
||||
// INTENTIONALLY far closer than the projection's 1.0 m near plane so a doorway the camera is
|
||||
// standing in still projects and the cell behind it stays visible. See the file header.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue