The user watched far terrain visibly assemble after portal space exits.
The reveal gate was NOT missing a hold — Slice E's hold mechanism is
correct and already in place. The hold was measuring the wrong domain:
it opened at a hardcoded 3x3 landblock neighbourhood (~192 m) while the
visible world extends to the fog end (~2,189 m at the shipped High
preset, inside a 2,304 m Far window). An 11.4:1 ratio.
Retail's equivalent ratio is 1:1 BY CONSTRUCTION. `LScape` owns one
`mid_width x mid_width` array of `CLandBlock*` (`LScape::SetMidRadius`
@0x00504C00, `LScape::update_block` @0x005063A0), `mid_radius` is
assigned directly from the user's `Render.LandscapeDrawDistance`
preference (`SmartBox::SetRegion` @0x004531F0; values
`Render_LandscapeDrawDistance_Values` @0x007CA988 = {3,5,8,11,15,25},
default 8 — both byte-verified against the PDB-paired 2013 binary), and
that same square is simultaneously the prefetched set
(`LScape::PreFetchCells` @0x00505660), the drawn set (`block_draw_list`
over the same array), and the set the simulation blocks on
(`CellManager::blocking_for_cells`). There is no retail configuration in
which the client streams farther than it gates, because there is only
one number.
So the fix derives rather than duplicates. Four coupled parts, which is
why this is one commit and not four — D1 without D2 hangs the client and
D2 without D1 is dead code:
D1 `WorldRevealReadinessBarrier` takes a live `Func<StreamingRevealWindow>`
and stops being static: outdoor requires `FarRadius`, indoor still 0
(retail's `CEnvCell::PreFetchCells` @0x0052D1E0 arm). Read per
evaluation, never captured — the radii are runtime mutable through
Settings, and retail's answer to a mid-hold radius change is to reset,
re-radius, and re-arm the blocking prefetch at the NEW value
(`SmartBox::set_mid_radius` @0x00453180). `OutdoorNeighborhoodRadius`
is deleted; there is no constant left to drift.
D2 `StreamingController.IsRenderNeighborhoodResident` becomes tiered,
because acdream's loaded landscape is: inside `NearRadius`,
`IsNearTier && IsRenderReady`; out to `FarRadius`, `IsRenderReady` only.
Without this the fix cannot work at all — nothing outside the Near ring
is ever promoted, so any radius above `NearRadius` was unsatisfiable and
would have held the reveal forever. Proof obligation P1 (a Far-tier
landblock genuinely satisfies `IsRenderReady`) is now a test driven
through the real `PublicationKind.Far` pipeline against a real
`LandblockSpawnAdapter`, not an inference.
D7 `RuntimeWorldTransitState.AcknowledgeDestinationReadiness` re-derived
`indoor ? 0 : 1` and failed `invalid-readiness-shape` on any other
value, so changing the radius alone would have looked like "the fix
hangs the client". It is now a SHAPE invariant (`indoor => 0`,
`outdoor => >= 1`). Runtime does not own the graphical host's streaming
configuration and must not learn it; plumbing App radii into Runtime to
preserve the strict equality is exactly the assert-a-mechanism-that-does-
not-exist failure C5b was built to stop. Both non-graphical producers
keep emitting their centre-ring token and stay legal, annotated in place.
D6 `PhysicsEngine.IsNeighborhoodTerrainResident` rebuilt a full-map
`HashSet` on every call, every frame of every hold. At radius 1 that was
invisible; at radius 12 (625 ring members) it violates Slice I1's
0 B/resolve standard. Now an engine-owned scratch set, cleared in place;
measured at 0 bytes over 1,000 warmed radius-12 queries.
Also: the destination reservation opens at exactly the gate's radius and
reopens on the same generation when the radius changes mid-hold (retail
has one square for both, and no concept of prioritising an inner ring
differently). Composite warmup deliberately stays `NearRadius`-scoped —
the composite domain is entity-scoped and Far builds carry no entities,
so widening it would walk the outer window to warm nothing.
`ACDREAM_PROBE_REVEAL_RADIUS` is a measurement probe in a diagnostic
owner (CLAUDE.md rule 5) so the connected route can be run A/B on one
binary; it is NOT a user-facing prefetch knob, since a low setting would
reintroduce the decoupling this slice exists to close.
Register: AD-2 amended with the derived window, the two-tier split, and
the four new retail anchors. AP-149 FILED for the residual this does not
close — the outer ring accepts terrain-only publication where retail
requires LandBlockInfo and every building EnvCell, so a distant building
can still pop in at Far-ring distances. Do not let a later closeout
claim parity.
Docs: `ACDREAM_STREAM_RADIUS`'s CLAUDE.md description was wrong on every
clause (the default is unset, not 2; it forces `NearRadius`; it is
silently discarded by any Settings save) — corrected, since that is the
file every session reads. `reference_two_tier_streaming.md` corrected in
four ways, including "Far tier = terrain only": Far also publishes
terrain COLLISION, which is precisely what makes this fix viable.
#280's issue text had the right conclusion from a wrong premise (it
names a view-distance setting acdream does not have) — corrected, and
the missing Viewing Distance option filed separately as #326, with #327
(DDD progress readout) and #328 (hardcoded 5000 f far plane vs retail's
byte-verified 4000) filed alongside.
Expect LONGER holds and the "In Portal Space - Please Wait..." cue on
recalls MORE often. That is convergence toward retail, not away from it:
retail emits the byte-identical string for the whole duration of a
blocked prefetch and polls at 5 s intervals. The failure condition is
non-convergence, not duration.
Gates: Release build 0 errors. Complete suite 11,178 passed / 4 skipped
/ 0 failed, against a re-measured 11,142 / 4 / 0 baseline at 9ee9c1a1 —
+36, reconciled exactly as 36 new tests (App +23, Runtime +10, Core +3),
zero deleted, zero newly skipped. Nine discriminating tests
sabotage-verified in both directions. The connected/visual gate is
batched into C5's matrix; its recipe, its three positive artifacts, and
its required recall leg are written into the campaign plan.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
240 lines
8.6 KiB
C#
240 lines
8.6 KiB
C#
using AcDream.App.Streaming;
|
|
using AcDream.Core.Physics;
|
|
using AcDream.Core.World;
|
|
using AcDream.Runtime.World;
|
|
using DatReaderWriter.DBObjs;
|
|
|
|
namespace AcDream.App.Tests.Streaming;
|
|
|
|
/// <summary>
|
|
/// #280 end-to-end: the derived reveal window, the tiered render predicate,
|
|
/// the terrain-residency gate, the destination reservation, and the loosened
|
|
/// Runtime shape invariant, wired together with the REAL
|
|
/// <see cref="StreamingController"/>, <see cref="GpuWorldState"/>, and
|
|
/// <see cref="PhysicsEngine"/> rather than fakes.
|
|
///
|
|
/// <para>
|
|
/// This is the test that fails if any single piece is missing: raising the
|
|
/// radius without the tier-aware predicate hangs forever (T2), and loosening
|
|
/// neither the Runtime invariant nor the predicate makes
|
|
/// <c>AcknowledgeDestinationReadiness</c> fail
|
|
/// <c>invalid-readiness-shape</c> (T1).
|
|
/// </para>
|
|
/// </summary>
|
|
public sealed class WorldRevealDerivedWindowIntegrationTests
|
|
{
|
|
private const int CenterX = 0x40;
|
|
private const int CenterY = 0x40;
|
|
private const uint DestinationCell = (uint)CenterX << 24
|
|
| (uint)CenterY << 16
|
|
| 0x0021u;
|
|
|
|
[Theory]
|
|
[InlineData(1, 2)]
|
|
[InlineData(2, 4)]
|
|
public void OutdoorReveal_HoldsUntilTheWholeDerivedWindowIsPublished(
|
|
int nearRadius,
|
|
int farRadius)
|
|
{
|
|
var world = new GpuWorldState();
|
|
var physics = new PhysicsEngine();
|
|
var transit = new RuntimeWorldTransitState();
|
|
var streaming = new RecordingReservations();
|
|
StreamingController controller = CreateController(
|
|
world,
|
|
nearRadius,
|
|
farRadius);
|
|
WorldRevealCoordinator coordinator = CreateCoordinator(
|
|
transit,
|
|
controller,
|
|
physics,
|
|
streaming);
|
|
|
|
long generation = coordinator.BeginLogin(DestinationCell);
|
|
|
|
// The reservation opens on the same square the gate measures.
|
|
Assert.Equal(
|
|
(generation, DestinationCell, farRadius),
|
|
Assert.Single(streaming.Begins));
|
|
|
|
// Publish the Near window only. Pre-#280 this was the entire gate; it
|
|
// must no longer be enough.
|
|
for (int radius = 0; radius <= nearRadius; radius++)
|
|
PublishRing(world, physics, radius, LandblockStreamTier.Near);
|
|
Assert.False(coordinator.Evaluate(DestinationCell).IsReady);
|
|
|
|
// Fill the outer rings with Far-tier terrain publication, one ring at
|
|
// a time, so the hold is proven to track the outer boundary and not
|
|
// just the first missing member.
|
|
for (int radius = nearRadius + 1; radius < farRadius; radius++)
|
|
{
|
|
PublishRing(world, physics, radius, LandblockStreamTier.Far);
|
|
Assert.False(coordinator.Evaluate(DestinationCell).IsReady);
|
|
}
|
|
|
|
PublishRing(world, physics, farRadius, LandblockStreamTier.Far);
|
|
WorldRevealReadinessSnapshot ready =
|
|
coordinator.Evaluate(DestinationCell);
|
|
|
|
Assert.True(ready.IsReady);
|
|
Assert.Equal(farRadius, ready.RequiredRenderRadius);
|
|
Assert.Equal(nearRadius, ready.RequiredNearRadius);
|
|
// The loosened Runtime shape invariant accepted the derived radius.
|
|
Assert.Equal(0, transit.Snapshot.InvariantFailureCount);
|
|
Assert.True(transit.Snapshot.IsReady);
|
|
}
|
|
|
|
/// <summary>
|
|
/// P7/§9-8: login and portal share the barrier, so first login gets the
|
|
/// same widened gate. Asserted through the production readiness predicate
|
|
/// the login auto-entry context calls.
|
|
/// </summary>
|
|
[Fact]
|
|
public void LoginReveal_UsesTheSameWidenedGateAsPortalArrival()
|
|
{
|
|
const int nearRadius = 1;
|
|
const int farRadius = 3;
|
|
var world = new GpuWorldState();
|
|
var physics = new PhysicsEngine();
|
|
var transit = new RuntimeWorldTransitState();
|
|
StreamingController controller = CreateController(
|
|
world,
|
|
nearRadius,
|
|
farRadius);
|
|
WorldRevealCoordinator coordinator = CreateCoordinator(
|
|
transit,
|
|
controller,
|
|
physics,
|
|
streaming: null);
|
|
|
|
coordinator.BeginLogin(DestinationCell);
|
|
for (int radius = 0; radius < farRadius; radius++)
|
|
{
|
|
PublishRing(
|
|
world,
|
|
physics,
|
|
radius,
|
|
radius <= nearRadius
|
|
? LandblockStreamTier.Near
|
|
: LandblockStreamTier.Far);
|
|
}
|
|
|
|
Assert.False(coordinator.Evaluate(DestinationCell).IsReady);
|
|
|
|
PublishRing(world, physics, farRadius, LandblockStreamTier.Far);
|
|
|
|
Assert.True(coordinator.Evaluate(DestinationCell).IsReady);
|
|
Assert.Equal(0, transit.Snapshot.InvariantFailureCount);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indoor destinations keep retail's EnvCell arm: no landscape ring at
|
|
/// all, regardless of how wide the streaming window is.
|
|
/// </summary>
|
|
[Fact]
|
|
public void IndoorReveal_IgnoresTheStreamingWindowEntirely()
|
|
{
|
|
const uint indoorCell = (uint)CenterX << 24
|
|
| (uint)CenterY << 16
|
|
| 0x0100u;
|
|
var world = new GpuWorldState();
|
|
var physics = new PhysicsEngine();
|
|
var transit = new RuntimeWorldTransitState();
|
|
StreamingController controller = CreateController(world, 2, 6);
|
|
WorldRevealCoordinator coordinator = CreateCoordinator(
|
|
transit,
|
|
controller,
|
|
physics,
|
|
streaming: null);
|
|
|
|
coordinator.BeginLogin(indoorCell);
|
|
Assert.False(coordinator.Evaluate(indoorCell).IsReady);
|
|
|
|
// Only the destination's own landblock, at Near tier.
|
|
PublishRing(world, physics, 0, LandblockStreamTier.Near);
|
|
WorldRevealReadinessSnapshot snapshot = coordinator.Evaluate(indoorCell);
|
|
|
|
Assert.True(snapshot.IsRenderNeighborhoodReady);
|
|
Assert.Equal(0, snapshot.RequiredRenderRadius);
|
|
Assert.Equal(0, transit.Snapshot.InvariantFailureCount);
|
|
}
|
|
|
|
private sealed class RecordingReservations : IWorldRevealStreamingScheduler
|
|
{
|
|
public List<(long Generation, uint Cell, int Radius)> Begins { get; } = [];
|
|
public List<long> Ends { get; } = [];
|
|
|
|
public void BeginDestinationReservation(
|
|
long revealGeneration,
|
|
uint destinationCell,
|
|
int requiredRenderRadius) =>
|
|
Begins.Add((revealGeneration, destinationCell, requiredRenderRadius));
|
|
|
|
public void EndDestinationReservation(long revealGeneration) =>
|
|
Ends.Add(revealGeneration);
|
|
}
|
|
|
|
private static WorldRevealCoordinator CreateCoordinator(
|
|
RuntimeWorldTransitState transit,
|
|
StreamingController controller,
|
|
PhysicsEngine physics,
|
|
IWorldRevealStreamingScheduler? streaming) =>
|
|
new(
|
|
transit,
|
|
() => new StreamingRevealWindow(
|
|
controller.NearRadius,
|
|
controller.FarRadius),
|
|
controller.IsRenderNeighborhoodResident,
|
|
physics.IsSpawnCellReady,
|
|
physics.IsNeighborhoodTerrainResident,
|
|
() => true,
|
|
(_, _) => { },
|
|
() => { },
|
|
_ => false,
|
|
streaming: streaming);
|
|
|
|
private static StreamingController CreateController(
|
|
GpuWorldState state,
|
|
int nearRadius,
|
|
int farRadius) =>
|
|
new(
|
|
(_, _, _) => { },
|
|
(_, _) => { },
|
|
_ => Array.Empty<LandblockStreamResult>(),
|
|
(_, _) => { },
|
|
state,
|
|
nearRadius: nearRadius,
|
|
farRadius: farRadius);
|
|
|
|
private static void PublishRing(
|
|
GpuWorldState world,
|
|
PhysicsEngine physics,
|
|
int radius,
|
|
LandblockStreamTier tier)
|
|
{
|
|
for (int dx = -radius; dx <= radius; dx++)
|
|
for (int dy = -radius; dy <= radius; dy++)
|
|
{
|
|
if (Math.Abs(dx) != radius && Math.Abs(dy) != radius)
|
|
continue;
|
|
|
|
uint id = ((uint)(CenterX + dx) << 24)
|
|
| ((uint)(CenterY + dy) << 16)
|
|
| 0xFFFFu;
|
|
world.AddLandblock(
|
|
new LoadedLandblock(id, new LandBlock(), Array.Empty<WorldEntity>()),
|
|
tier: tier);
|
|
// The Far tier publishes terrain COLLISION as well as terrain
|
|
// render (LandblockPhysicsPublisher, reached for
|
|
// PublicationKind.Far), which is what makes the outer arm of the
|
|
// reveal gate satisfiable on the collision side too.
|
|
physics.AddLandblock(
|
|
id,
|
|
new TerrainSurface(new byte[81], new float[256]),
|
|
Array.Empty<CellSurface>(),
|
|
Array.Empty<PortalPlane>(),
|
|
worldOffsetX: 0f,
|
|
worldOffsetY: 0f);
|
|
}
|
|
}
|
|
}
|