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:
parent
3971997689
commit
749e8ceeb1
225 changed files with 29107 additions and 3914 deletions
|
|
@ -141,10 +141,10 @@ public class LandblockLoaderTests
|
|||
var idsB = entitiesLbB.Select(e => e.Id).ToArray();
|
||||
Assert.Empty(idsA.Intersect(idsB));
|
||||
|
||||
// The namespace top byte is 0xC0 for stabs (distinct from 0x80 scenery,
|
||||
// 0x40 interior, low-range live entities).
|
||||
Assert.All(idsA, id => Assert.Equal(0xC0u, (id >> 24) & 0xFFu));
|
||||
Assert.All(idsB, id => Assert.Equal(0xC0u, (id >> 24) & 0xFFu));
|
||||
// The namespace top nibble is 0xC for stabs (distinct from 0x8
|
||||
// scenery, 0x4 interior, and low-range live entities).
|
||||
Assert.All(idsA, id => Assert.True(LandblockStaticEntityIdAllocator.IsInNamespace(id)));
|
||||
Assert.All(idsB, id => Assert.True(LandblockStaticEntityIdAllocator.IsInNamespace(id)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -186,17 +186,34 @@ public class LandblockLoaderTests
|
|||
Assert.Equal(1u, entities[0].Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildEntitiesFromInfo_MoreThan255EntriesStayInTheOwningLandblockRange()
|
||||
{
|
||||
var info = new LandBlockInfo();
|
||||
for (uint i = 0; i < 300u; i++)
|
||||
info.Objects.Add(new Stab { Id = 0x01000001u, Frame = new Frame() });
|
||||
|
||||
IReadOnlyList<WorldEntity> entities =
|
||||
LandblockLoader.BuildEntitiesFromInfo(info, landblockId: 0xA9B40000u);
|
||||
|
||||
Assert.Equal(300, entities.Count);
|
||||
Assert.Equal(300, entities.Select(entity => entity.Id).Distinct().Count());
|
||||
Assert.All(entities, entity =>
|
||||
Assert.True(LandblockStaticEntityIdAllocator.IsInNamespace(entity.Id)));
|
||||
Assert.True(entities[^1].Id < LandblockStaticEntityIdAllocator.Base(0xA9u, 0xB5u));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildEntitiesFromInfo_NamespacedIdOverflowFailsBeforeCrossLandblockAlias()
|
||||
{
|
||||
var info = new LandBlockInfo();
|
||||
for (uint i = 0; i < 256u; i++)
|
||||
for (uint i = 0; i <= LandblockStaticEntityIdAllocator.MaxCounter + 1u; i++)
|
||||
info.Objects.Add(new Stab { Id = 0x01000001u, Frame = new Frame() });
|
||||
|
||||
InvalidDataException error = Assert.Throws<InvalidDataException>(
|
||||
() => LandblockLoader.BuildEntitiesFromInfo(info, landblockId: 0xA9B40000u));
|
||||
|
||||
Assert.Contains("255-entry", error.Message, StringComparison.Ordinal);
|
||||
Assert.Contains("4096-entry", error.Message, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue