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>
36 lines
981 B
C#
36 lines
981 B
C#
namespace AcDream.App.Rendering;
|
|
|
|
/// <summary>
|
|
/// Runs dependency-ordered resource teardown one stage at a time. A failed
|
|
/// stage remains current, so a later <see cref="Advance"/> retries exactly
|
|
/// that owner before any dependent resource can be destroyed.
|
|
/// </summary>
|
|
internal sealed class OrderedResourceTeardown(params Action[] stages)
|
|
{
|
|
private readonly Action[] _stages = stages ?? throw new ArgumentNullException(nameof(stages));
|
|
private int _nextStage;
|
|
private bool _advancing;
|
|
|
|
public bool IsComplete => _nextStage == _stages.Length;
|
|
internal int NextStage => _nextStage;
|
|
|
|
public void Advance()
|
|
{
|
|
if (_advancing || IsComplete)
|
|
return;
|
|
|
|
_advancing = true;
|
|
try
|
|
{
|
|
while (_nextStage < _stages.Length)
|
|
{
|
|
_stages[_nextStage]();
|
|
_nextStage++;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
_advancing = false;
|
|
}
|
|
}
|
|
}
|