The first commit converted the four members the issue named and left the other sites alone, reasoning that none had been observed failing. A 20-run complete-solution baseline disproved that within minutes: run 2 LiveEntityRuntimeTests.AnimationView_HotSpatialTraversal… run 14 StaticRenderProjectionJournalTests.ActiveAnimatedSynchronization… run 18 StaticRenderProjectionJournalTests.ActiveAnimatedSynchronization… run 19 CurrentRenderSceneOracleTests.SurfaceOverrideFingerprint… Both new names are the same shape as the four — one warm call, then a thousand-iteration loop inside the measured window — and neither had been recorded anywhere. "Not observed failing" only ever meant "not yet observed", and leaving known-shape sites in place would have guaranteed the acceptance gate failed. Run 19 is the sharper lesson: the issue named `SurfaceOverrideFingerprint_DictionaryHotPathAllocatesNothing`, and the first commit converted a *different* test in that same file, so the actually-named member was still on the old shape. Matching by file was not matching by test. Every strict-zero site in the assembly is now on the probe — ten tests. Two came out stricter rather than merely steadier: `StaticRenderProjectionJournalTests` was measuring a synchronise whose journal does **not** coalesce. Repeating it grew the journal by 1,000 entries per call — 192,000 by the end of a probe run — so the steady state the test claimed to measure did not exist and the single-call window had been hiding it. Its step is now the whole frame cycle, synchronise *and* drain, which puts `DrainTo` inside the measured window for the first time and asserts the journal ends empty. `RetailInboundEventDispatcherTests` asserted a hard-coded 1,001 callbacks. It now counts its own dispatches and pins the callback count against that, so the assertion still proves the fast path ran the callback every time without being coupled to a loop bound that no longer exists. Left alone deliberately: the four sites asserting a tolerance rather than zero — `CellViewDedupTests` and `PortalProjectionTests`. Their ceilings already absorb this noise and none has flaked; changing a bound in either direction is a separate decision from fixing a measurement. Worth noting that `PortalProjectionTests`' ceiling exists explicitly to tolerate "a tiered-JIT/ArrayPool bookkeeping transition ... to the first measured batch", which is exactly what the probe removes, so it could probably be tightened to zero now — recorded in the issue rather than done here. Solution build 0 warnings / 0 errors; App suite 3,941 passed / 3 skipped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
178 lines
5.7 KiB
C#
178 lines
5.7 KiB
C#
using AcDream.App.Rendering.Scene;
|
|
|
|
namespace AcDream.App.Tests.Rendering;
|
|
|
|
public sealed class RenderFrameRouteOwnerSelectorTests
|
|
{
|
|
private static readonly RenderSceneGeneration Generation =
|
|
RenderSceneGeneration.FromRaw(1);
|
|
|
|
[Fact]
|
|
public void ReplaceAndUnionUseExactRouteIdentityAndDeduplicateOwners()
|
|
{
|
|
var exchange = new RenderFrameExchange();
|
|
PublishRoutes(exchange, sequence: 1);
|
|
RenderFrameView view = exchange.BorrowLatest(Generation, 1);
|
|
var owners = new HashSet<uint> { 999 };
|
|
|
|
RenderFrameRouteOwnerSelector.Replace(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.LandscapeOutdoorStatic,
|
|
routeIndex: 0,
|
|
cellId: 0);
|
|
RenderFrameRouteOwnerSelector.Union(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.LandscapeOutsideDynamic,
|
|
routeIndex: 0,
|
|
cellId: 0);
|
|
|
|
Assert.Equal([10u, 20u, 30u], owners.Order());
|
|
exchange.Release(in view);
|
|
}
|
|
|
|
[Fact]
|
|
public void ExceptRouteRemovesOwnersAcrossEveryRangeOfThatRoute()
|
|
{
|
|
var exchange = new RenderFrameExchange();
|
|
PublishRoutes(exchange, sequence: 1);
|
|
RenderFrameView view = exchange.BorrowLatest(Generation, 1);
|
|
var owners = new HashSet<uint>();
|
|
|
|
RenderFrameRouteOwnerSelector.Replace(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.DynamicLast,
|
|
routeIndex: 0,
|
|
cellId: 0);
|
|
RenderFrameRouteOwnerSelector.ExceptRoute(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.LandscapeOutsideDynamic);
|
|
|
|
Assert.Equal([50u], owners);
|
|
exchange.Release(in view);
|
|
}
|
|
|
|
[Fact]
|
|
public void MissingRouteClearsOnReplaceAndDoesNotMutateOnUnion()
|
|
{
|
|
var exchange = new RenderFrameExchange();
|
|
PublishRoutes(exchange, sequence: 1);
|
|
RenderFrameView view = exchange.BorrowLatest(Generation, 1);
|
|
var owners = new HashSet<uint> { 10, 20 };
|
|
|
|
RenderFrameRouteOwnerSelector.Union(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.LookInObject,
|
|
routeIndex: 9,
|
|
cellId: 0x01010009);
|
|
Assert.Equal([10u, 20u], owners.Order());
|
|
|
|
RenderFrameRouteOwnerSelector.Replace(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.LookInObject,
|
|
routeIndex: 9,
|
|
cellId: 0x01010009);
|
|
Assert.Empty(owners);
|
|
exchange.Release(in view);
|
|
}
|
|
|
|
[Fact]
|
|
public void WarmSelectionAllocatesNothing()
|
|
{
|
|
var exchange = new RenderFrameExchange();
|
|
PublishRoutes(exchange, sequence: 1);
|
|
RenderFrameView view = exchange.BorrowLatest(Generation, 1);
|
|
var owners = new HashSet<uint>();
|
|
owners.EnsureCapacity(16);
|
|
|
|
// #250: warmed once, then measured a 1,000-iteration loop written
|
|
// inline — the shape on-stack replacement rewrites mid-measurement.
|
|
RenderFrameView captured = view;
|
|
ZeroAllocationProbe.AssertAllocatesNothing(
|
|
"RenderFrameRouteOwnerSelector.SelectOwners",
|
|
() => SelectOwners(owners, in captured));
|
|
|
|
Assert.Equal([50u], owners);
|
|
exchange.Release(in view);
|
|
}
|
|
|
|
private static void SelectOwners(
|
|
HashSet<uint> owners,
|
|
in RenderFrameView view)
|
|
{
|
|
RenderFrameRouteOwnerSelector.Replace(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.DynamicLast,
|
|
routeIndex: 0,
|
|
cellId: 0);
|
|
RenderFrameRouteOwnerSelector.ExceptRoute(
|
|
owners,
|
|
in view,
|
|
RenderFrameCandidateRoute.LandscapeOutsideDynamic);
|
|
}
|
|
|
|
private static void PublishRoutes(
|
|
RenderFrameExchange exchange,
|
|
ulong sequence)
|
|
{
|
|
RenderProjectionRecord owner10 = Projection(1, 10);
|
|
RenderProjectionRecord owner20 = Projection(2, 20);
|
|
RenderProjectionRecord owner30 = Projection(3, 30);
|
|
RenderProjectionRecord owner40 = Projection(4, 40);
|
|
RenderProjectionRecord owner50 = Projection(5, 50);
|
|
RenderProjectionRecord anonymous = Projection(6, 0);
|
|
RenderFrameWriter writer =
|
|
exchange.BeginBuild(Generation, sequence);
|
|
writer.AddRouteRange(
|
|
RenderFrameCandidateRoute.LandscapeOutdoorStatic,
|
|
0,
|
|
0,
|
|
[owner10, owner20, anonymous]);
|
|
writer.AddRouteRange(
|
|
RenderFrameCandidateRoute.LandscapeOutsideDynamic,
|
|
0,
|
|
0,
|
|
[owner20, owner30]);
|
|
writer.AddRouteRange(
|
|
RenderFrameCandidateRoute.LandscapeOutsideDynamic,
|
|
1,
|
|
0,
|
|
[owner40]);
|
|
writer.AddRouteRange(
|
|
RenderFrameCandidateRoute.DynamicLast,
|
|
0,
|
|
0,
|
|
[owner20, owner40, owner50]);
|
|
writer.SetSourceDigest(
|
|
new RenderSceneDigest(
|
|
Generation,
|
|
default,
|
|
default));
|
|
writer.Publish();
|
|
}
|
|
|
|
private static RenderProjectionRecord Projection(
|
|
ulong projectionId,
|
|
uint localEntityId) =>
|
|
new()
|
|
{
|
|
Id = RenderProjectionId.FromRaw(projectionId),
|
|
OwnerIncarnation = RenderOwnerIncarnation.FromRaw(1),
|
|
Source = new RenderSourceMetadata(
|
|
LocalEntityId: localEntityId,
|
|
ServerGuid: 0,
|
|
SourceId: 0,
|
|
ParentCellId: 0,
|
|
EffectCellId: 0,
|
|
BuildingShellAnchorCellId: 0,
|
|
TransformFingerprint: default,
|
|
GeometryFingerprint: default,
|
|
AppearanceFingerprint: default),
|
|
};
|
|
}
|