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

@ -149,6 +149,58 @@ public class StreamingControllerPriorityApplyTests
Assert.Equal(3, applied.Count);
}
[Fact]
public void DeferredCompaction_ApplyFailureRetainsExactResultWithoutReplayingCommittedPrefix()
{
uint priority = StreamingRegion.EncodeLandblockIdForTest(169, 180);
uint first = StreamingRegion.EncodeLandblockIdForTest(169, 182);
uint retry = StreamingRegion.EncodeLandblockIdForTest(169, 183);
uint last = StreamingRegion.EncodeLandblockIdForTest(169, 184);
var outbox = new Queue<LandblockStreamResult>(
[
LoadedOf(first),
LoadedOf(retry),
LoadedOf(last),
]);
var applied = new List<uint>();
bool failRetryOnce = true;
var ctrl = new StreamingController(
enqueueLoad: (_, _) => { },
enqueueUnload: _ => { },
drainCompletions: max =>
{
var batch = new List<LandblockStreamResult>();
while (batch.Count < max && outbox.Count > 0)
batch.Add(outbox.Dequeue());
return batch;
},
applyTerrain: (build, _) =>
{
if (build.LandblockId == retry && failRetryOnce)
{
failRetryOnce = false;
throw new InvalidOperationException("synthetic upload failure");
}
applied.Add(build.LandblockId);
},
state: new GpuWorldState(),
nearRadius: 4,
farRadius: 12)
{
MaxCompletionsPerFrame = 3,
PriorityLandblockId = priority,
};
Assert.Throws<InvalidOperationException>(() => ctrl.Tick(169, 180));
Assert.Equal([first], applied);
Assert.Equal(2, ctrl.DeferredApplyBacklog);
ctrl.Tick(169, 180);
Assert.Equal([first, retry, last], applied);
Assert.Equal(0, ctrl.DeferredApplyBacklog);
}
[Fact]
public void ForceReloadWindow_DiscardsBufferedCompletionsFromOldWindow()
{