perf(streaming): cursor publication across frame budgets
This commit is contained in:
parent
bb16f74fd4
commit
98f1ac8934
32 changed files with 2215 additions and 823 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.App.Rendering.Wb;
|
||||
using DatReaderWriter.DBObjs;
|
||||
using DatReaderWriter.Types;
|
||||
|
|
@ -86,6 +87,43 @@ public class BuildingLoaderTests
|
|||
Assert.Equal(new SortedSet<uint> { 1, 2 }, ids); // sequential 1, 2
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RetainedPublication_AdvancesOneBuildingAndCommitsCellStampsAtomically()
|
||||
{
|
||||
LandBlockInfo info = MakeInfo(
|
||||
(0x02000001u, new[] { 0x0150u }),
|
||||
(0x02000002u, new[] { 0x0160u }));
|
||||
LoadedCell cell150 = MinimalCell(0xA9B40150u);
|
||||
LoadedCell cell160 = MinimalCell(0xA9B40160u);
|
||||
var cells = new Dictionary<uint, LoadedCell>
|
||||
{
|
||||
[cell150.CellId] = cell150,
|
||||
[cell160.CellId] = cell160,
|
||||
};
|
||||
|
||||
BuildingRegistryPublication publication =
|
||||
BuildingLoader.PreparePublication(info, 0xA9B40000u, cells);
|
||||
|
||||
Assert.False(publication.PreparationCommitted);
|
||||
Assert.False(BuildingLoader.AdvancePreparationOne(publication));
|
||||
Assert.Equal(1, publication.BuildingCursor);
|
||||
Assert.Equal(1, publication.Registry.Count);
|
||||
Assert.Null(cell150.BuildingId);
|
||||
Assert.Null(cell160.BuildingId);
|
||||
|
||||
Assert.True(BuildingLoader.AdvancePreparationOne(publication));
|
||||
Assert.Equal(2, publication.BuildingCursor);
|
||||
Assert.Equal(2, publication.Registry.Count);
|
||||
Assert.Null(cell150.BuildingId);
|
||||
Assert.Null(cell160.BuildingId);
|
||||
|
||||
BuildingLoader.CommitPublication(publication);
|
||||
|
||||
Assert.Equal(1u, cell150.BuildingId);
|
||||
Assert.Equal(2u, cell160.BuildingId);
|
||||
Assert.True(publication.PublicationCommitted);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Build_StampsLoadedCellBuildingId()
|
||||
{
|
||||
|
|
@ -166,4 +204,16 @@ public class BuildingLoaderTests
|
|||
Assert.Equal(new Vector3(9, 12, 33), b.PortalBounds.Min);
|
||||
Assert.Equal(new Vector3(17, 25, 39), b.PortalBounds.Max);
|
||||
}
|
||||
|
||||
private static LoadedCell MinimalCell(uint cellId) => new()
|
||||
{
|
||||
CellId = cellId,
|
||||
Portals = new List<AcDream.App.Rendering.CellPortalInfo>(),
|
||||
PortalPolygons = new List<Vector3[]>(),
|
||||
WorldTransform = Matrix4x4.Identity,
|
||||
InverseWorldTransform = Matrix4x4.Identity,
|
||||
LocalBoundsMin = new Vector3(-5, -5, -5),
|
||||
LocalBoundsMax = new Vector3(5, 5, 5),
|
||||
ClipPlanes = new List<AcDream.App.Rendering.PortalClipPlane>(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue