feat(render): unify physical residency accounting
This commit is contained in:
parent
1866ea0c6d
commit
3e18fc2730
25 changed files with 642 additions and 48 deletions
|
|
@ -384,6 +384,8 @@ internal sealed class CompositeTextureArrayCache : IDisposable
|
|||
internal long UnownedBytes => _unowned.ResidentBytes;
|
||||
internal int AtlasCount => _atlases.Count;
|
||||
internal long AllocatedBytes => _allocatedBytes;
|
||||
internal long PhysicalBudgetBytes => _physicalBudgetBytes;
|
||||
internal long UnownedBudgetBytes => _unowned.BudgetBytes;
|
||||
internal int FrameUploadCount => _frameUploadCount;
|
||||
internal long FrameUploadBytes => _frameUploadBytes;
|
||||
internal bool CanStartUpload =>
|
||||
|
|
@ -391,6 +393,49 @@ internal sealed class CompositeTextureArrayCache : IDisposable
|
|||
&& _frameUploadCount < _maximumUploadsPerFrame
|
||||
&& (_frameUploadCount == 0 || _frameUploadBytes < _maximumUploadBytesPerFrame);
|
||||
|
||||
internal Residency.ResidencyDomainSnapshot CaptureResidency()
|
||||
{
|
||||
long retiringBytes = 0;
|
||||
long usedBytes = 0;
|
||||
long availableBytes = 0;
|
||||
for (int i = 0; i < _atlases.Count; i++)
|
||||
{
|
||||
Atlas atlas = _atlases[i];
|
||||
if (atlas.ReleaseRequested
|
||||
|| atlas.ReleaseStage != AtlasReleaseStage.Resident)
|
||||
{
|
||||
retiringBytes = checked(
|
||||
retiringBytes + atlas.Resource.Bytes);
|
||||
usedBytes = checked(
|
||||
usedBytes + atlas.Resource.Bytes);
|
||||
continue;
|
||||
}
|
||||
|
||||
long layerBytes = atlas.Resource.Bytes / atlas.Slots.Capacity;
|
||||
usedBytes = checked(
|
||||
usedBytes
|
||||
+ layerBytes * checked(
|
||||
atlas.EntryCount + atlas.PendingRetirements));
|
||||
availableBytes = checked(
|
||||
availableBytes
|
||||
+ layerBytes * atlas.AvailableLayers);
|
||||
}
|
||||
|
||||
return new Residency.ResidencyDomainSnapshot(
|
||||
Residency.ResidencyDomain.CompositeTextures,
|
||||
EntryCount: _entries.Count,
|
||||
OwnerCount: _owners.OwnerCount,
|
||||
Charges: new Residency.ResidencyCharges(
|
||||
GpuRequestedBytes: _pendingAtlasAllocationBytes,
|
||||
GpuResidentBytes: checked(
|
||||
_allocatedBytes - retiringBytes),
|
||||
RetiringBytes: retiringBytes),
|
||||
BudgetBytes: _physicalBudgetBytes,
|
||||
CapacityBytes: _allocatedBytes,
|
||||
UsedBytes: usedBytes,
|
||||
LargestFreeBytes: availableBytes);
|
||||
}
|
||||
|
||||
internal bool CanUpload(long bytes)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(bytes);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue