#include <ResourcePool.h>
Inherits AZ::RHI::MultiDeviceObject.
Inherited by AZ::RHI::BufferPoolBase, AZ::RHI::ImagePoolBase, AZ::RHI::QueryPool, and AZ::RHI::ShaderResourceGroupPool.
|
| AZ_RTTI (ResourcePool, "{BAE5442C-A312-4133-AE80-1200753A7C3E}", MultiDeviceObject) |
|
virtual void | Shutdown () override=0 |
| Shuts down the pool. This method will shutdown all resources associated with the pool.
|
|
template<typename ResourceType > |
void | ForEach (AZStd::function< void(ResourceType &)> callback) |
|
template<typename ResourceType > |
void | ForEach (AZStd::function< void(const ResourceType &)> callback) const |
|
uint32_t | GetResourceCount () const |
| Returns the number of resources in the pool.
|
|
virtual const ResourcePoolDescriptor & | GetDescriptor () const =0 |
| Returns the resource pool descriptor.
|
|
| AZ_RTTI (MultiDeviceObject, "{17D34F71-944C-4AF5-9823-627474C4C0A6}", Object) |
|
bool | IsInitialized () const |
| Returns whether the device object is initialized.
|
|
AZ_FORCE_INLINE bool | IsDeviceSet (int deviceIndex) const |
|
MultiDevice::DeviceMask | GetDeviceMask () const |
|
| AZ_RTTI (Object, "{E43378F1-2331-4173-94B8-990ED20E6003}") |
|
void | SetName (const Name &name) |
| Sets the name of the object.
|
|
const Name & | GetName () const |
| Returns the name set on the object by SetName.
|
|
uint32_t | use_count () |
| Returns the current use count of the object.
|
|
|
using | PlatformMethod = AZStd::function< RHI::ResultCode()> |
| //!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//
|
|
|
ResultCode | Init (MultiDevice::DeviceMask deviceMask, const PlatformMethod &initMethod) |
|
ResultCode | InitResource (Resource *resource, const PlatformMethod &initResourceMethod) |
|
bool | ValidateIsRegistered (const Resource *resource) const |
|
bool | ValidateIsUnregistered (const Resource *resource) const |
|
bool | ValidateIsInitialized () const |
| Validates that the resource pool is initialized and ready to service requests.
|
|
void | Init (MultiDevice::DeviceMask deviceMask) |
| The derived class should call this method to assign the device.
|
|
template<typename T > |
AZ_FORCE_INLINE void | IterateDevices (T callback) |
| Helper method that will iterate over all selected devices and call the provided callback.
|
|
template<typename T , typename U > |
AZ_FORCE_INLINE decltype(auto) | IterateObjects (U callback) |
|
template<typename T , typename U > |
AZ_FORCE_INLINE decltype(auto) | IterateObjects (U callback) const |
|
template<typename T > |
AZ_FORCE_INLINE Ptr< T > | GetDeviceObject (int deviceIndex) const |
|
void | add_ref () const |
|
void | release () const |
|
|
template<typename T > |
static AZ_FORCE_INLINE void | IterateDevices (MultiDevice::DeviceMask deviceMask, T callback) |
|
AZStd::unordered_map< int, Ptr< DeviceObject > > | m_deviceObjects |
| A map of all device-specific objects, indexed by the device index.
|
|
AZStd::atomic_int | m_useCount = 0 |
|
A base class for multi-device resource pools. This class facilitates registration of multi-device resources into the pool, and allows iterating child resource instances.
◆ PlatformMethod
//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//
A simple functor that returns a result code.
◆ ForEach()
template<typename ResourceType >
void AZ::RHI::ResourcePool::ForEach |
( |
AZStd::function< void(ResourceType &)> |
callback | ) |
|
Loops through every resource matching the provided resource type (RTTI casting is used) and calls the provided callback method. Both methods are thread-safe with respect to other Init calls. A shared_mutex is used to guard the internal registry. This means that multiple iterations can be done without blocking each other, but a resource Init / Shutdown will serialize with this method.
◆ GetDescriptor()
◆ Init()
ResultCode AZ::RHI::ResourcePool::Init |
( |
MultiDevice::DeviceMask |
deviceMask, |
|
|
const PlatformMethod & |
initMethod |
|
) |
| |
|
protected |
Validates the pool for initialization, calls the provided init method (which wraps the platform-specific resource init call). If the platform init fails, the resource pool is shutdown and an error code is returned.
◆ InitResource()
ResultCode AZ::RHI::ResourcePool::InitResource |
( |
Resource * |
resource, |
|
|
const PlatformMethod & |
initResourceMethod |
|
) |
| |
|
protected |
Validates the state of resource, calls the provided init method, and registers the resource with the pool. If validation or the internal platform init method fail, the resource is not registered and an error code is returned.
◆ Shutdown()
virtual void AZ::RHI::ResourcePool::Shutdown |
( |
| ) |
|
|
overridepure virtual |
◆ ValidateIsRegistered()
bool AZ::RHI::ResourcePool::ValidateIsRegistered |
( |
const Resource * |
resource | ) |
const |
|
protected |
Validates the resource is registered / unregistered with the pool, and that it not null. In non-release builds this will issue a warning. Non-release builds will branch and fail the call if validation fails, but this should be treated as a bug, because release will disable validation.
The documentation for this class was generated from the following file:
- Gems/Atom/RHI/Code/Include/Atom/RHI/ResourcePool.h