feat(render #53): EntityClassificationCache skeleton + first test
Adds CachedBatch, EntityCacheEntry, and EntityClassificationCache with just TryGet (returns false on empty). The skeleton compiles and the first test (TryGet_EmptyCache_ReturnsFalse) passes. Subsequent tasks add Populate, InvalidateEntity, InvalidateLandblock, and the dispatcher integration. Per spec design Section 6.1. Note: CachedBatch / EntityCacheEntry / EntityClassificationCache are internal (not public as the plan snippet showed). Their members transitively reference the internal GroupKey type, so promoting them to public produces CS0051 inconsistent-accessibility errors. The cache is dispatcher-internal coordination state anyway, and the AcDream.App csproj already exposes internals to AcDream.Core.Tests via InternalsVisibleTo, so the test sees everything it needs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c02405cbb7
commit
773e9703da
3 changed files with 123 additions and 0 deletions
39
src/AcDream.App/Rendering/Wb/CachedBatch.cs
Normal file
39
src/AcDream.App/Rendering/Wb/CachedBatch.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace AcDream.App.Rendering.Wb;
|
||||
|
||||
/// <summary>
|
||||
/// Per-(entity, partIdx, batchIdx) classification result, stored flat inside
|
||||
/// <see cref="EntityCacheEntry.Batches"/>. For Setup multi-part MeshRefs each
|
||||
/// subPart contributes its own <see cref="CachedBatch"/> entries, with
|
||||
/// <see cref="RestPose"/> already containing the
|
||||
/// <c>subPart.PartTransform * meshRef.PartTransform</c> product.
|
||||
///
|
||||
/// Accessibility: <c>internal</c> because <see cref="GroupKey"/> is
|
||||
/// <c>internal</c> and shows up in this struct's constructor / <c>Deconstruct</c>
|
||||
/// signature. The cache itself is dispatcher-internal coordination state;
|
||||
/// <see cref="InternalsVisibleTo"/> on <c>AcDream.App</c> exposes the type to
|
||||
/// <c>AcDream.Core.Tests</c>.
|
||||
/// </summary>
|
||||
internal readonly record struct CachedBatch(
|
||||
GroupKey Key,
|
||||
ulong BindlessTextureHandle,
|
||||
Matrix4x4 RestPose);
|
||||
|
||||
/// <summary>
|
||||
/// One entity's cached classification. <see cref="Batches"/> is flat across
|
||||
/// (partIdx, batchIdx) and ordered as <c>WbDrawDispatcher.ClassifyBatches</c>
|
||||
/// produced them. <see cref="LandblockHint"/> lets
|
||||
/// <see cref="EntityClassificationCache.InvalidateLandblock"/> sweep entries
|
||||
/// efficiently when a landblock demotes or unloads.
|
||||
///
|
||||
/// Accessibility: <c>internal</c> for the same reason as <see cref="CachedBatch"/>
|
||||
/// — its <see cref="Batches"/> property is <c>CachedBatch[]</c>, which
|
||||
/// transitively involves <see cref="GroupKey"/>.
|
||||
/// </summary>
|
||||
internal sealed class EntityCacheEntry
|
||||
{
|
||||
public required uint EntityId { get; init; }
|
||||
public required uint LandblockHint { get; init; }
|
||||
public required CachedBatch[] Batches { get; init; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue