perf(streaming): reserve destination reveal capacity

Join destination scheduling to the canonical reveal generation, protect its share across every typed frame-budget dimension, and prevent stale work from clearing a replacement reservation. Remove forced incomplete materialization and project retail's centered portal wait cue while the authored tunnel remains active.

Tests: Release build clean; 91 focused reservation/reveal tests; full solution 8,158 passed, 5 skipped.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-24 19:39:23 +02:00
parent 98f1ac8934
commit 2ff8f844b0
33 changed files with 870 additions and 230 deletions

View file

@ -46,22 +46,23 @@ public sealed class LocalPlayerTeleportControllerTests
harness.Controller.OfferDestination(
destination,
teleportTimestampAdvanced: true);
Assert.Empty(harness.Streaming.PriorityWrites);
Assert.Empty(harness.Streaming.Reservations);
harness.Controller.OnTeleportStarted(7);
Assert.Equal(1, harness.Input.EndCount);
Assert.Equal(1, harness.Mode.EnterPortalCount);
Assert.Equal(Matrix4x4.Identity, harness.Presentation.BeginProjection);
Assert.Equal((0x2021FFFFu, LocalPlayerTeleportController.NearRingRadius),
Assert.Single(harness.Streaming.PriorityWrites));
Assert.Equal(
(1L, 0x20210001u, WorldRevealReadinessBarrier.OutdoorNeighborhoodRadius),
Assert.Single(harness.Streaming.Reservations));
Assert.True(harness.Reveal.Snapshot.IsActive);
Assert.Equal(WorldRevealKind.Portal, harness.Reveal.Snapshot.Kind);
harness.Controller.OfferDestination(
destination,
teleportTimestampAdvanced: false);
Assert.Single(harness.Streaming.PriorityWrites);
Assert.Single(harness.Streaming.Reservations);
}
[Fact]
@ -89,7 +90,7 @@ public sealed class LocalPlayerTeleportControllerTests
Assert.True(harness.Controller.IsActive);
Assert.Equal(0x20210001u, harness.Controller.ActiveDestinationCell);
Assert.NotNull(harness.Presentation.BeginProjection);
Assert.Single(harness.Streaming.PriorityWrites);
Assert.Single(harness.Streaming.Reservations);
}
[Fact]
@ -105,14 +106,14 @@ public sealed class LocalPlayerTeleportControllerTests
teleportTimestampAdvanced: true);
Assert.Equal(0u, harness.Controller.ActiveDestinationCell);
Assert.Empty(harness.Streaming.PriorityWrites);
Assert.Empty(harness.Streaming.Reservations);
harness.Mode.Controller = new PlayerMovementController(new PhysicsEngine());
harness.Mode.Controller.SetPosition(Vector3.Zero, 0x20210001u, Vector3.Zero);
harness.Controller.Tick(0.016f);
Assert.Equal(0x20210001u, harness.Controller.ActiveDestinationCell);
Assert.Single(harness.Streaming.PriorityWrites);
Assert.Single(harness.Streaming.Reservations);
}
[Fact]
@ -158,7 +159,6 @@ public sealed class LocalPlayerTeleportControllerTests
Assert.Empty(harness.Streaming.Recenters);
Assert.Equal(new Vector3(20f, 30f, 4f), harness.Placement.Position);
Assert.Equal(0x20210123u, harness.Placement.CellId);
Assert.False(harness.Placement.Forced);
}
[Fact]
@ -188,7 +188,7 @@ public sealed class LocalPlayerTeleportControllerTests
}
[Fact]
public void ReadinessHold_UsesWallClockAndForcesExactlyAtTenSeconds()
public void ReadinessHold_NeverRevealsIncompleteWorldAndShowsWaitCueAfterFiveSeconds()
{
var harness = new Harness(worldReady: false);
harness.Controller.OnTeleportStarted(5);
@ -197,15 +197,18 @@ public sealed class LocalPlayerTeleportControllerTests
teleportTimestampAdvanced: true);
harness.Presentation.EmitPlaceWhenReady = true;
harness.Controller.Tick(9.5f);
harness.Controller.Tick(4.9f);
Assert.False(Assert.Single(harness.Presentation.WorldReadyValues));
Assert.False(harness.Presentation.WaitCueValues[^1]);
Assert.Equal(default, harness.Placement.Position);
harness.Controller.Tick(0.5f);
harness.Controller.Tick(0.1f);
harness.Controller.Tick(30f);
Assert.True(harness.Presentation.WorldReadyValues[^1]);
Assert.True(harness.Placement.Forced);
Assert.Equal(new Vector3(1f, 2f, 3f), harness.Placement.Position);
Assert.All(harness.Presentation.WorldReadyValues, Assert.False);
Assert.True(harness.Presentation.WaitCueValues[^1]);
Assert.Equal(default, harness.Placement.Position);
Assert.True(harness.Reveal.WaitCueShown);
}
[Fact]
@ -223,7 +226,6 @@ public sealed class LocalPlayerTeleportControllerTests
harness.Controller.Tick(0.016f);
Assert.True(Index(order, "placement") < Index(order, "[world-reveal] event=materialized"));
Assert.True(Index(order, "[world-reveal] event=materialized") < Index(order, "priority-clear"));
Assert.Equal(1, harness.Reveal.PortalMaterializationCount);
}
@ -249,6 +251,8 @@ public sealed class LocalPlayerTeleportControllerTests
Assert.False(harness.Controller.IsActive);
Assert.Equal(0u, harness.Controller.ActiveDestinationCell);
Assert.Equal(1, harness.Session.LoginCompleteCount);
Assert.True(harness.Reveal.Snapshot.Completed);
Assert.False(harness.Reveal.Snapshot.Cancelled);
}
[Fact]
@ -261,7 +265,7 @@ public sealed class LocalPlayerTeleportControllerTests
teleportTimestampAdvanced: true);
harness.Controller.OnTeleportStarted(11);
harness.Controller.Tick(LocalPlayerTeleportController.MaximumWorldHoldSeconds);
harness.Controller.Tick(30f);
Assert.Equal(default, harness.Placement.Position);
Assert.Equal(0u, harness.Controller.ActiveDestinationCell);
@ -318,7 +322,7 @@ public sealed class LocalPlayerTeleportControllerTests
harness.Controller.OfferDestination(
Position(0x20210001u, 20, 1f, 2f, 3f),
teleportTimestampAdvanced: true);
harness.Streaming.PriorityClearCount = 0;
harness.Streaming.ReservationEnds.Clear();
harness.Placement.OnPlace = () => harness.Controller.OnTeleportStarted(21);
harness.Presentation.Enqueue(TeleportAnimEvent.Place);
@ -327,7 +331,7 @@ public sealed class LocalPlayerTeleportControllerTests
Assert.True(harness.Controller.IsActive);
Assert.Equal(0u, harness.Controller.ActiveDestinationCell);
Assert.Equal(0, harness.Reveal.PortalMaterializationCount);
Assert.Equal(1, harness.Streaming.PriorityClearCount);
Assert.Single(harness.Streaming.ReservationEnds);
}
[Fact]
@ -418,7 +422,7 @@ public sealed class LocalPlayerTeleportControllerTests
var position = new Vector3(12f, 24f, 6f);
Quaternion rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, 0.5f);
placement.Place(position, cell, rotation, forced: false);
placement.Place(position, cell, rotation);
Assert.Equal(entity.Position, controllerSlot.Controller.Position);
Assert.Equal(entity.ParentCellId, controllerSlot.Controller.CellId);
@ -560,7 +564,8 @@ public sealed class LocalPlayerTeleportControllerTests
prepareCompositeTextures: (_, _) => { },
invalidateCompositeTextures: () => { },
isSpawnClaimUnhydratable: _ => false,
log: order.Add);
log: order.Add,
streaming: Streaming);
Controller = new LocalPlayerTeleportController(
Authority,
Input,
@ -619,7 +624,9 @@ public sealed class LocalPlayerTeleportControllerTests
}
}
private sealed class FakeStreaming : ILocalPlayerTeleportStreamingOperations
private sealed class FakeStreaming
: ILocalPlayerTeleportStreamingOperations,
IWorldRevealStreamingScheduler
{
private readonly List<string> _order;
@ -636,9 +643,10 @@ public sealed class LocalPlayerTeleportControllerTests
public bool RecenterPending;
public bool ResetResult = true;
public bool LastResetWasSessionEnding;
public int PriorityClearCount;
public readonly List<(int X, int Y, bool Sealed)> Recenters = new();
public readonly List<(uint Landblock, int Radius)> PriorityWrites = new();
public readonly List<(long Generation, uint Cell, int Radius)>
Reservations = new();
public readonly List<long> ReservationEnds = new();
public bool BeginRecenter(int x, int y, bool isSealedDungeon)
{
@ -655,13 +663,17 @@ public sealed class LocalPlayerTeleportControllerTests
public bool IsSealedDungeon(uint cellId) =>
(cellId & 0xFFFFu) >= 0x0100u;
public void SetPriority(uint landblockId, int radius) =>
PriorityWrites.Add((landblockId, radius));
public void BeginDestinationReservation(
long revealGeneration,
uint destinationCell,
int requiredRenderRadius) =>
Reservations.Add(
(revealGeneration, destinationCell, requiredRenderRadius));
public void ClearPriority()
public void EndDestinationReservation(long revealGeneration)
{
PriorityClearCount++;
_order.Add("priority-clear");
ReservationEnds.Add(revealGeneration);
_order.Add("reservation-end");
}
}
@ -674,16 +686,14 @@ public sealed class LocalPlayerTeleportControllerTests
public Vector3 Position;
public uint CellId;
public Quaternion Rotation;
public bool Forced;
public Action? OnPlace;
public void Place(Vector3 position, uint cellId, Quaternion rotation, bool forced)
public void Place(Vector3 position, uint cellId, Quaternion rotation)
{
_order.Add("placement");
Position = position;
CellId = cellId;
Rotation = rotation;
Forced = forced;
OnPlace?.Invoke();
}
}
@ -731,6 +741,7 @@ public sealed class LocalPlayerTeleportControllerTests
public Matrix4x4? BeginProjection;
public bool EmitPlaceWhenReady;
public readonly List<bool> WorldReadyValues = new();
public readonly List<bool> WaitCueValues = new();
public int DisposeFailuresRemaining;
public int DisposeCount;
@ -760,6 +771,7 @@ public sealed class LocalPlayerTeleportControllerTests
public void TickTunnel(float deltaSeconds) => _order.Add("tunnel-tick");
public void EnterTunnel() => IsPortalViewportVisible = true;
public void ExitTunnel() => IsPortalViewportVisible = false;
public void SetWaitCue(bool visible) => WaitCueValues.Add(visible);
public void Reset()
{