Separate logical ownership, render publication, and GPU retirement across live entities, landblocks, particles, textures, mesh arenas, portal/UI teardown, and per-frame scratch storage. Add bounded DAT/texture caches, upload budgets, three-frame fence retirement, exact-incarnation appearance reconciliation, frame pacing, and extensive lifetime conformance coverage.\n\nThe seven-destination connected route now cuts peak working/private memory roughly in half, returns Caul to 125-153 FPS locally, and produces no WER or AMD reset.\n\nCo-authored-by: OpenAI Codex <codex@openai.com>
112 lines
3.6 KiB
C#
112 lines
3.6 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Rendering.Wb;
|
|
using AcDream.Core.World;
|
|
|
|
namespace AcDream.App.Tests.Rendering.Wb;
|
|
|
|
public sealed class WbDrawDispatcherCompositeWarmupTests
|
|
{
|
|
private const uint Destination = 0x1234FFFFu;
|
|
|
|
[Fact]
|
|
public void NewlyPublishedEntitySnapshotRequiresRebuildAfterPriorSnapshotWasReady()
|
|
{
|
|
IReadOnlyList<WorldEntity> emptyReadySnapshot = Array.Empty<WorldEntity>();
|
|
IReadOnlyList<WorldEntity> publishedDestinationSnapshot =
|
|
[CreateEntity(parentCell: Destination, withPalette: true)];
|
|
|
|
Assert.True(WbDrawDispatcher.RequiresCompositeWarmupRebuild(
|
|
emptyReadySnapshot,
|
|
Destination,
|
|
currentRadius: 0,
|
|
currentGeneration: 0,
|
|
publishedDestinationSnapshot,
|
|
nextGeneration: 1,
|
|
Destination,
|
|
nextRadius: 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void MutatedStableEntityViewRequiresRebuildWhenGenerationChanges()
|
|
{
|
|
IReadOnlyList<WorldEntity> stableView = new List<WorldEntity>();
|
|
|
|
Assert.True(WbDrawDispatcher.RequiresCompositeWarmupRebuild(
|
|
stableView,
|
|
Destination,
|
|
currentRadius: 0,
|
|
currentGeneration: 41,
|
|
stableView,
|
|
nextGeneration: 42,
|
|
Destination,
|
|
nextRadius: 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void PaletteEntityInsideDestinationRadiusIsCandidate()
|
|
{
|
|
WorldEntity entity = CreateEntity(parentCell: 0x1235FFFEu, withPalette: true);
|
|
|
|
Assert.True(WbDrawDispatcher.IsCompositeWarmupCandidate(entity, Destination, radius: 1));
|
|
}
|
|
|
|
[Fact]
|
|
public void EntityOutsideDestinationRadiusIsExcluded()
|
|
{
|
|
WorldEntity entity = CreateEntity(parentCell: 0x1236FFFEu, withPalette: true);
|
|
|
|
Assert.False(WbDrawDispatcher.IsCompositeWarmupCandidate(entity, Destination, radius: 1));
|
|
}
|
|
|
|
[Fact]
|
|
public void CellLessEntityIsExcludedFromKnownDestination()
|
|
{
|
|
WorldEntity entity = CreateEntity(parentCell: null, withPalette: true);
|
|
|
|
Assert.False(WbDrawDispatcher.IsCompositeWarmupCandidate(entity, Destination, radius: 1));
|
|
}
|
|
|
|
[Fact]
|
|
public void SameLandblockIndoorCellIsCandidateAtZeroRadius()
|
|
{
|
|
WorldEntity entity = CreateEntity(parentCell: 0x1234012Au, withPalette: true);
|
|
|
|
Assert.True(WbDrawDispatcher.IsCompositeWarmupCandidate(entity, Destination, radius: 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void EntityWithoutPaletteOrSurfaceOverridesIsExcluded()
|
|
{
|
|
WorldEntity entity = CreateEntity(parentCell: Destination, withPalette: false);
|
|
|
|
Assert.False(WbDrawDispatcher.IsCompositeWarmupCandidate(entity, Destination, radius: 0));
|
|
}
|
|
|
|
[Fact]
|
|
public void SurfaceOverrideEntityIsCandidateWithoutPalette()
|
|
{
|
|
WorldEntity entity = CreateEntity(parentCell: Destination, withPalette: false);
|
|
entity.MeshRefs =
|
|
[
|
|
new MeshRef(0x01000001u, Matrix4x4.Identity)
|
|
{
|
|
SurfaceOverrides = new Dictionary<uint, uint> { [0x08000001u] = 0x05000001u },
|
|
},
|
|
];
|
|
|
|
Assert.True(WbDrawDispatcher.IsCompositeWarmupCandidate(entity, Destination, radius: 0));
|
|
}
|
|
|
|
private static WorldEntity CreateEntity(uint? parentCell, bool withPalette) => new()
|
|
{
|
|
Id = 1,
|
|
SourceGfxObjOrSetupId = 0x01000001u,
|
|
Position = Vector3.Zero,
|
|
Rotation = Quaternion.Identity,
|
|
MeshRefs = [new MeshRef(0x01000001u, Matrix4x4.Identity)],
|
|
ParentCellId = parentCell,
|
|
PaletteOverride = withPalette
|
|
? new PaletteOverride(0x04000001u, Array.Empty<PaletteOverride.SubPaletteRange>())
|
|
: null,
|
|
};
|
|
}
|