fix(rendering): bound portal resource lifetime

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>
This commit is contained in:
Erik 2026-07-18 21:35:16 +02:00
parent 3971997689
commit 749e8ceeb1
225 changed files with 29107 additions and 3914 deletions

View file

@ -0,0 +1,46 @@
using AcDream.Core.World;
namespace AcDream.Core.Tests.World;
public sealed class LandblockStaticEntityIdAllocatorTests
{
[Fact]
public void Base_PreservesFullCoordinatesAndStabNamespace()
{
var bases = new HashSet<uint>();
for (uint y = 0; y <= 255; y++)
for (uint x = 0; x <= 255; x++)
{
uint value = LandblockStaticEntityIdAllocator.Base(x, y);
Assert.True(LandblockStaticEntityIdAllocator.IsInNamespace(value));
Assert.True(bases.Add(value), $"duplicate base for ({x},{y})");
}
}
[Fact]
public void MaximumCounterDoesNotAliasAdjacentLandblock()
{
for (uint y = 0; y < 255; y++)
{
uint current = LandblockStaticEntityIdAllocator.Base(0, y);
uint next = LandblockStaticEntityIdAllocator.Base(0, y + 1);
Assert.True(current + LandblockStaticEntityIdAllocator.MaxCounter < next);
}
}
[Fact]
public void Allocate_AcceptsLastCounterThenFailsBeforeNamespaceWrap()
{
uint counter = LandblockStaticEntityIdAllocator.MaxCounter;
uint last = LandblockStaticEntityIdAllocator.Allocate(0xA9u, 0xB4u, ref counter);
Assert.Equal(
LandblockStaticEntityIdAllocator.Base(0xA9u, 0xB4u)
+ LandblockStaticEntityIdAllocator.MaxCounter,
last);
InvalidDataException error = Assert.Throws<InvalidDataException>(
() => LandblockStaticEntityIdAllocator.Allocate(0xA9u, 0xB4u, ref counter));
Assert.Contains("4096-entry", error.Message, StringComparison.Ordinal);
}
}