perf(rendering): reconcile only changed attachments

This commit is contained in:
Erik 2026-07-25 05:18:33 +02:00
parent 6b56f4bef2
commit b9cbf5e040
8 changed files with 246 additions and 14 deletions

View file

@ -28,6 +28,7 @@ public sealed class EntityEffectPoseRegistry :
public bool[] PartAvailable = Array.Empty<bool>();
public uint CellId;
public ulong LifetimeVersion;
public ulong ChangeVersion;
}
private readonly Dictionary<uint, PoseRecord> _poses = new();
@ -112,7 +113,10 @@ public sealed class EntityEffectPoseRegistry :
}
if (changed)
{
record.ChangeVersion++;
EffectPoseChanged?.Invoke(entity.Id);
}
}
public void Publish(
@ -142,7 +146,10 @@ public sealed class EntityEffectPoseRegistry :
record.CellId = cellId;
changed |= CopyParts(record, partLocal, availability);
if (changed)
{
record.ChangeVersion++;
EffectPoseChanged?.Invoke(localEntityId);
}
}
/// <summary>Refresh only the moving root while retaining current part poses.</summary>
@ -159,6 +166,7 @@ public sealed class EntityEffectPoseRegistry :
record.RootWorld = rootWorld;
record.CellId = cellId;
record.ChangeVersion++;
EffectPoseChanged?.Invoke(entity.Id);
return true;
}
@ -258,6 +266,16 @@ public sealed class EntityEffectPoseRegistry :
? record.LifetimeVersion
: 0UL;
/// <summary>
/// Monotonic version of the current lifetime's root, part, availability,
/// or cell pose. Synchronous presentation owners use it to avoid repeating
/// a derived composition when the published parent pose is unchanged.
/// </summary>
public ulong GetPoseChangeVersion(uint localEntityId) =>
_poses.TryGetValue(localEntityId, out PoseRecord? record)
? record.ChangeVersion
: 0UL;
private ulong NextLifetimeVersion()
{
_nextLifetimeVersion++;