Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RHI::MultiDeviceResourcePool Class Referenceabstract

#include <MultiDeviceResourcePool.h>

Inherits AZ::RHI::MultiDeviceObject.

Inherited by AZ::RHI::MultiDeviceQueryPool.

Public Member Functions

 AZ_RTTI (MultiDeviceResourcePool, "{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 ResourcePoolDescriptorGetDescriptor () const =0
 Returns the resource pool descriptor.
 
- Public Member Functions inherited from AZ::RHI::MultiDeviceObject
 AZ_RTTI (MultiDeviceObject, "{17D34F71-944C-4AF5-9823-627474C4C0A6}", Object)
 
bool IsInitialized () const
 Returns whether the device object is initialized.
 
MultiDevice::DeviceMask GetDeviceMask () const
 
- Public Member Functions inherited from AZ::RHI::Object
 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.
 

Protected Types

using PlatformMethod = AZStd::function< RHI::ResultCode()>
 //!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//
 

Protected Member Functions

ResultCode Init (MultiDevice::DeviceMask deviceMask, const PlatformMethod &initMethod)
 
ResultCode InitResource (MultiDeviceResource *resource, const PlatformMethod &initResourceMethod)
 
bool ValidateIsRegistered (const MultiDeviceResource *resource) const
 
bool ValidateIsUnregistered (const MultiDeviceResource *resource) const
 
bool ValidateIsInitialized () const
 Validates that the resource pool is initialized and ready to service requests.
 
- Protected Member Functions inherited from AZ::RHI::MultiDeviceObject
void Init (MultiDevice::DeviceMask deviceMask)
 The derived class should call this method to assign the device.
 
void Shutdown () override
 Clears the current bound device to null.
 
template<typename T >
void IterateDevices (T callback)
 Helper method that will iterate over all selected devices and call the provided callback.
 
- Protected Member Functions inherited from AZ::RHI::Object
void add_ref () const
 
void release () const
 

Friends

class MultiDeviceResource
 

Additional Inherited Members

- Protected Attributes inherited from AZ::RHI::Object
AZStd::atomic_int m_useCount = 0
 

Detailed Description

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.

Member Typedef Documentation

◆ PlatformMethod

using AZ::RHI::MultiDeviceResourcePool::PlatformMethod = AZStd::function<RHI::ResultCode()>
protected

//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//!//

A simple functor that returns a result code.

Member Function Documentation

◆ ForEach()

template<typename ResourceType >
void AZ::RHI::MultiDeviceResourcePool::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()

virtual const ResourcePoolDescriptor & AZ::RHI::MultiDeviceResourcePool::GetDescriptor ( ) const
pure virtual

Returns the resource pool descriptor.

Implemented in AZ::RHI::MultiDeviceQueryPool.

◆ Init()

ResultCode AZ::RHI::MultiDeviceResourcePool::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::MultiDeviceResourcePool::InitResource ( MultiDeviceResource 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::MultiDeviceResourcePool::Shutdown ( )
overridepure virtual

Shuts down the pool. This method will shutdown all resources associated with the pool.

Reimplemented from AZ::RHI::MultiDeviceObject.

Implemented in AZ::RHI::MultiDeviceQueryPool.

◆ ValidateIsRegistered()

bool AZ::RHI::MultiDeviceResourcePool::ValidateIsRegistered ( const MultiDeviceResource 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: