public void CalculateStats([NativeTypeName("StatInfo&")] ref D3D12MA_StatInfo outStats) { ZeroMemory(Unsafe.AsPointer(ref outStats), (nuint)sizeof(D3D12MA_StatInfo)); outStats.AllocationSizeMin = UINT64_MAX; outStats.UnusedRangeSizeMin = UINT64_MAX; using D3D12MA_MutexLockRead @lock = new(ref m_Mutex, m_useMutex != 0); for (D3D12MA_Allocation *alloc = m_AllocationList.Front(); alloc != null; alloc = D3D12MA_IntrusiveLinkedList <D3D12MA_Allocation> .GetNext(alloc)) { ulong size = alloc->GetSize(); ++outStats.BlockCount; ++outStats.AllocationCount; outStats.UsedBytes += size; if (size > outStats.AllocationSizeMax) { outStats.AllocationSizeMax = size; } if (size < outStats.AllocationSizeMin) { outStats.AllocationSizeMin = size; } } }
/// <summary>Writes JSON array with the list of allocations.</summary> public void BuildStatsString([NativeTypeName("JsonWriter&")] ref D3D12MA_JsonWriter json) { using D3D12MA_MutexLockRead @lock = new(ref m_Mutex, m_useMutex != 0); json.BeginArray(); for (D3D12MA_Allocation *alloc = m_AllocationList.Front(); alloc != null; alloc = D3D12MA_IntrusiveLinkedList <D3D12MA_Allocation> .GetNext(alloc)) { json.BeginObject(true); json.AddAllocationToObject(alloc); json.EndObject(); } json.EndArray(); }