// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Collections/Array.h"
#include "Engine/Platform/Platform.h"
#include "Engine/Platform/CriticalSection.h"
class GPUResource;
class StringBuilder;
///
/// GPU Resources collection container
///
class GPUResourcesCollection
{
private:
CriticalSection _locker;
Array _collection;
public:
///
/// Initializes a new instance of the class.
///
GPUResourcesCollection()
: _collection(1024)
{
}
///
/// Finalizes an instance of the class.
///
~GPUResourcesCollection()
{
}
public:
///
/// Gets the total memory usage (in bytes).
///
/// GPU memory usage (in bytes).
uint64 GetMemoryUsage() const;
///
/// Called when device is being disposed.
///
void OnDeviceDispose();
///
/// Dumps all resources information to the log.
///
void DumpToLog() const;
///
/// Dumps all resources information to the log.
///
void DumpToLog(StringBuilder& output) const;
public:
///
/// Adds the specified resource to the collection.
///
/// The resource.
void Add(GPUResource* resource);
///
/// Removes the specified resource from the collection.
///
/// The resource.
void Remove(GPUResource* resource);
};