acdream/tests/AcDream.Content.Tests
Erik 60bc313917 perf(content): CellStruct clone guard, solid-color texture cache, drop double ToList (2026-07-24 audit review)
Three small verified MeshExtractor.cs fixes from an allocation audit:

- CellStruct clip-map clone guard: the CellStruct polygon-surface path
  cloned decoded texture data unconditionally before applying clip-map
  transparency, even though the comment above it says "if we got this
  from the cache, we need to clone it." The GfxObj path already had the
  correct pattern (clone only when textureDataIsCached). Wired the same
  textureDataIsCached flag through CellStruct's TryGet/GetOrCreate/
  RetainOrUse call sites and gated the clone on it, matching GfxObj
  exactly — freshly-decoded arrays (the common case) now skip a
  redundant clone + BlockCopy.

- Solid-color texture cache: isSolid surfaces (Base1Solid / NoPos-
  stippled polys) allocated a fresh 32x32 RGBA array (4 KiB) on every
  polygon, even for repeated colors. Added a MeshExtractor-scoped
  ConcurrentDictionary<uint, byte[]> keyed by packed ARGB, bounded by
  distinct colors observed (a few hundred at most) rather than call
  volume. Traced every downstream consumer of the solid-color array
  (clip-map clone-guard, translucency clone-guard, GL upload, pak
  serialization) — none currently mutate a solid-color array in place,
  since isSolid is mutually exclusive with the texture-decode branch
  those guards live in — but wired textureDataIsCached = true at both
  call sites anyway so the existing clone-before-mutate machinery
  protects the shared array if that ever changes.

- Dropped the redundant .ToList() on both _dats.ResolveId(...) calls:
  DatCollectionAdapter.ResolveId already returns a materialized List<T>
  typed as IEnumerable; the immediate .OrderByDescending().FirstOrDefault()
  enumerates once, so the extra copy was pure waste.

Added SolidColorTextureCacheTests (dat-gated, matching suite convention)
exercising the new cache directly via internal visibility.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit e9f9d7539966cc26343e45d653a751c5d1045810)
2026-07-24 11:49:46 +02:00
..
Vfx fix(rendering): bound portal resource lifetime 2026-07-18 21:35:16 +02:00
AcDream.Content.Tests.csproj test(pipeline): MP1b - live-vs-pak equivalence suite (dat-gated) 2026-07-05 21:33:32 +02:00
BoundedDatObjectCacheTests.cs fix(rendering): bound portal resource lifetime 2026-07-18 21:35:16 +02:00
ContentConformanceDats.cs test(pipeline): MP1b - live-vs-pak equivalence suite (dat-gated) 2026-07-05 21:33:32 +02:00
Crc32Tests.cs fix(pipeline): MP1b review - pak format/reader hardening 2026-07-05 22:08:59 +02:00
DecodedTextureCacheTests.cs fix(rendering): bound portal resource lifetime 2026-07-18 21:35:16 +02:00
ObjectMeshDataEquality.cs fix(pipeline): MP1b review - pak format/reader hardening 2026-07-05 22:08:59 +02:00
ObjectMeshDataSerializerTests.cs feat(pipeline): MP1b - ObjectMeshData binary serializer (deterministic round-trip) 2026-07-05 21:19:02 +02:00
PakEquivalenceTests.cs refactor(pipeline): MP1b review - unify DatCollectionAdapter + TOC/log test gaps 2026-07-05 22:18:30 +02:00
PakFormatTests.cs feat(pipeline): MP1b - pak key + header/TOC primitives 2026-07-05 21:14:10 +02:00
PakKeyTests.cs feat(pipeline): MP1b - pak key + header/TOC primitives 2026-07-05 21:14:10 +02:00
PakRoundTripTests.cs refactor(pipeline): MP1b review - unify DatCollectionAdapter + TOC/log test gaps 2026-07-05 22:18:30 +02:00
SolidColorTextureCacheTests.cs perf(content): CellStruct clone guard, solid-color texture cache, drop double ToList (2026-07-24 audit review) 2026-07-24 11:49:46 +02:00