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

@ -2,6 +2,7 @@ using System.Numerics;
using AcDream.Core.Terrain;
using DatReaderWriter;
using DatReaderWriter.DBObjs;
using AcDream.Core.Content;
using DatReaderWriter.Types;
namespace AcDream.Core.Meshing;
@ -28,7 +29,7 @@ public static class CellMesh
/// <see cref="GfxObjSubMesh.Translucency"/>. When null (e.g. offline tests)
/// all sub-meshes default to <see cref="TranslucencyKind.Opaque"/>.
/// </param>
public static IReadOnlyList<GfxObjSubMesh> Build(EnvCell envCell, CellStruct cellStruct, DatCollection? dats = null)
public static IReadOnlyList<GfxObjSubMesh> Build(EnvCell envCell, CellStruct cellStruct, IDatObjectSource? dats = null)
{
// Group output vertices and indices per surface dat id.
var perSurface = new Dictionary<uint, (List<Vertex> Vertices, List<uint> Indices, Dictionary<(int pos, int uv), uint> Dedupe)>();

View file

@ -1,5 +1,6 @@
using DatReaderWriter;
using DatReaderWriter.DBObjs;
using AcDream.Core.Content;
using DatReaderWriter.Enums;
namespace AcDream.Core.Meshing;
@ -66,7 +67,7 @@ public static class GfxObjDegradeResolver
/// this; tests use the callback overload below for easy fakes.
/// </summary>
public static bool TryResolveCloseGfxObj(
DatCollection dats,
IDatObjectSource dats,
uint gfxObjId,
out uint resolvedId,
out GfxObj? resolvedGfxObj)
@ -156,7 +157,7 @@ public static class GfxObjDegradeResolver
/// slot1 Id=0 MaxDist=FLT_MAX}). Callers that hydrate static geometry (always viewed at
/// distance &gt; 0) skip such GfxObjs.
/// </summary>
public static bool IsRuntimeHiddenMarker(DatCollection dats, uint gfxObjId)
public static bool IsRuntimeHiddenMarker(IDatObjectSource dats, uint gfxObjId)
=> IsRuntimeHiddenMarker(
id => dats.Get<GfxObj>(id),
id => dats.Get<GfxObjDegradeInfo>(id),

View file

@ -2,6 +2,7 @@ using System.Numerics;
using AcDream.Core.Terrain;
using DatReaderWriter;
using DatReaderWriter.DBObjs;
using AcDream.Core.Content;
using DatReaderWriter.Enums;
namespace AcDream.Core.Meshing;
@ -50,7 +51,7 @@ public static class GfxObjMesh
/// normals (and potentially different UVs via <c>NegUVIndices</c>).
/// </para>
/// </remarks>
public static IReadOnlyList<GfxObjSubMesh> Build(GfxObj gfxObj, DatCollection? dats = null)
public static IReadOnlyList<GfxObjSubMesh> Build(GfxObj gfxObj, IDatObjectSource? dats = null)
{
// One bucket per (surface-index, isNeg) pair. Negative-side triangles
// always land in a different bucket than their positive counterparts

View file

@ -2,6 +2,7 @@ using DatReaderWriter;
using DatReaderWriter.DBObjs;
using DatReaderWriter.Types;
using AcDream.Core.Physics;
using AcDream.Core.Content;
namespace AcDream.Core.Meshing;
@ -75,7 +76,7 @@ public static class MotionResolver
/// </summary>
public static IdleCycle? GetIdleCycle(
Setup setup,
DatCollection dats,
IDatObjectSource dats,
IAnimationLoader animationLoader,
uint? motionTableIdOverride = null,
ushort? stanceOverride = null,
@ -123,7 +124,7 @@ public static class MotionResolver
public static AnimationFrame? GetIdleFrame(
Setup setup,
DatCollection dats,
IDatObjectSource dats,
IAnimationLoader animationLoader,
uint? motionTableIdOverride = null,
ushort? stanceOverride = null,
@ -148,7 +149,7 @@ public static class MotionResolver
/// </summary>
private static (Animation, AnimData)? ResolveIdleCycleInternal(
Setup setup,
DatCollection dats,
IDatObjectSource dats,
IAnimationLoader animationLoader,
uint? motionTableIdOverride,
ushort? stanceOverride,