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,76 @@
using AcDream.App.Rendering.Wb;
using Chorizite.Core.Render.Enums;
using Silk.NET.OpenGL;
namespace AcDream.App.Tests.Rendering.Wb;
public sealed class TextureAtlasCapacityTests
{
[Theory]
[InlineData(128, 128, 32)]
[InlineData(256, 256, 24)]
[InlineData(512, 512, 6)]
[InlineData(1024, 1024, 1)]
public void RgbaCapacityTargetsEightMiBIncludingMipChain(
int width,
int height,
int expected)
{
Assert.Equal(
expected,
TextureAtlasManager.CalculateInitialCapacity(width, height, TextureFormat.RGBA8));
}
[Fact]
public void SmallCompressedLayersRemainCountCapped()
{
Assert.Equal(
TextureAtlasManager.MaximumArrayLayers,
TextureAtlasManager.CalculateInitialCapacity(32, 32, TextureFormat.DXT1));
}
[Fact]
public void DirectUploadAcceptsExactRgbaPayload()
{
ManagedGLTextureArray.ValidateUploadPayload(
TextureFormat.RGBA8, 2, 2, 16, PixelFormat.Rgba, PixelType.UnsignedByte);
}
[Theory]
[InlineData(15)]
[InlineData(17)]
public void DirectUploadRejectsNonExactPayloadLength(int bytes)
{
Assert.Throws<ArgumentException>(() =>
ManagedGLTextureArray.ValidateUploadPayload(
TextureFormat.RGBA8, 2, 2, bytes, PixelFormat.Rgba, PixelType.UnsignedByte));
}
[Fact]
public void DirectUploadRejectsMismatchedTransferTuple()
{
Assert.Throws<ArgumentException>(() =>
ManagedGLTextureArray.ValidateUploadPayload(
TextureFormat.RGBA8, 2, 2, 16, PixelFormat.Rgb, PixelType.UnsignedByte));
Assert.Throws<ArgumentException>(() =>
ManagedGLTextureArray.ValidateUploadPayload(
TextureFormat.RGBA8, 2, 2, 16, PixelFormat.Rgba, PixelType.Float));
}
[Fact]
public void CompressedUploadRejectsUncompressedDescriptorOverride()
{
int bytes = ManagedGLTextureArray.CalculateExpectedDataSize(TextureFormat.DXT1, 4, 4);
Assert.Throws<ArgumentException>(() =>
ManagedGLTextureArray.ValidateUploadPayload(
TextureFormat.DXT1, 4, 4, bytes, PixelFormat.Rgba, PixelType.UnsignedByte));
}
[Fact]
public void RgbPayloadUsesTightlyPackedRows()
{
Assert.Equal(18, ManagedGLTextureArray.CalculateExpectedDataSize(TextureFormat.RGB8, 3, 2));
ManagedGLTextureArray.ValidateUploadPayload(
TextureFormat.RGB8, 3, 2, 18, PixelFormat.Rgb, PixelType.UnsignedByte);
}
}