Replace scheduler-quantized software sleeps with a reusable Windows high-resolution deadline timer, expose pacing in the frame profiler, and make shutdown wake every persistent mesh worker without losing the shared signal. Preserve retail alpha order while using a stable radix, skip duplicate deferred-alpha SSBO packing, pack light sets, cache static selection descriptors, and retire historical material groups at the whole-frame boundary. The fixed dense-Caul sample improved from roughly 9-12 ms CPU to 5.3-6.2 ms without reducing visual quality. Release build succeeds with zero warnings and all 6,300 tests pass with five intentional skips. Three independent retail, architecture, and adversarial reviews are clean; the post-review connected route remains pending because local ACE is offline. Co-authored-by: OpenAI Codex <codex@openai.com>
58 lines
2.5 KiB
C#
58 lines
2.5 KiB
C#
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.
|
|
/// <see cref="LocalSortCenter"/> preserves the authored GfxObj key used by
|
|
/// retail's delayed-alpha viewer-distance ordering on cache hits.
|
|
/// <see cref="Group"/> is a registration-checked fast handle into the
|
|
/// dispatcher's bounded group table; a retired or synthetic entry falls back
|
|
/// to key lookup and refreshes this array entry.
|
|
///
|
|
/// 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,
|
|
Vector3 LocalSortCenter = default,
|
|
WbDrawDispatcher.InstanceGroup? Group = null,
|
|
long GroupRegistration = 0);
|
|
|
|
/// <summary>
|
|
/// Immutable retail-picking descriptor for one static entity part. The cache
|
|
/// stores only authored identity and rest pose; the current entity transform
|
|
/// and the selection system's live frustum/geometry verdict remain per-frame.
|
|
/// </summary>
|
|
internal readonly record struct CachedSelectionPart(
|
|
int PartIndex,
|
|
uint GfxObjId,
|
|
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; }
|
|
public CachedSelectionPart[] SelectionParts { get; init; } = [];
|
|
}
|