29 template <
typename Factory, std::derived_from<RHIObject> T>
40 template <
typename Factory,
typename T>
52 template <
typename U = T>
56 throw std::runtime_error(
"RHIHandle::Get called on an invalid handle");
59 throw std::runtime_error(
"RHIHandle::Get got nullptr");
60 return static_cast<U*
>(ptr);
84 template <
typename Factory,
typename T>
147 template <
typename Base = RHIObject>
161 template <
typename U,
typename...
Args>
173 template <
typename U = Base>
178 return reinterpret_cast<U*
>(
obj);
201 class RHIApplication;
202 template <
typename T>
204 template <
typename T>
208 template <
typename T>
210 template <
typename T>
General Purpose Allocator (GPA) interface.
Definition Allocator.hpp:24
Atomic, bounded object pool of fixed allocation sizes. Being a sibling to AtomicStack - key differenc...
Definition AtomicPool.hpp:18
void Destruct(T *ptr)
Destructs the object pointed to by ptr and returns it to the pool.
Definition AtomicPool.hpp:99
T * Construct(Args &&... args)
Constructs an object of type T in the pool with the given arguments.
Definition AtomicPool.hpp:87
void Collect()
Destruct all allocated objects in the pool, collecting garbage.
Definition AtomicPool.hpp:132
Definition Device.hpp:188
Handle type for RHI Objects.
Definition Details.hpp:42
bool IsValid() const
Check if the handle is valid (i.e. associated with a Factory and not kInvalidHandle)
Definition Details.hpp:74
constexpr Handle operator()() const
Definition Details.hpp:64
bool operator==(const RHIHandle &other) const
Definition Details.hpp:67
U * Get() const
Retrieves the underlying RHIObject pointer. It is undefined behavior to use the returned pointer afte...
Definition Details.hpp:53
T * operator->() const
Definition Details.hpp:62
void Invalidate()
Resets the handle to an invalid state. After calling this, the handle is no longer associated with an...
Definition Details.hpp:79
Handle mHandle
Definition Details.hpp:46
Factory * mFactory
Definition Details.hpp:45
constexpr T * operator*() noexcept
Definition Details.hpp:66
Thread-safe type-erased handle dereference facility for RHI Objects.
Definition Details.hpp:149
Core::AtomicPool< PointerType > mPool
Definition Details.hpp:153
RHIObjectPool(Core::Allocator *allocator)
Definition Details.hpp:156
static U * GetObjectPtr(Handle handle) noexcept
Retrieves the raw pointer to the object within the storage.
Definition Details.hpp:174
Core::UniquePtr< Base > PointerType
Definition Details.hpp:150
Core::Allocator * mAllocator
Definition Details.hpp:152
void Destroy()
Destroys all objects in the pool.
Definition Details.hpp:191
Handle CreateObject(Args &&... args)
Creates specified RHIObject of derived type T and retrieves its handle.
Definition Details.hpp:162
void DestroyObject(Handle handle)
Destroys the object associated with the given handle, and frees the handle for reuse.
Definition Details.hpp:183
Base class for all RHI objects.
Definition Details.hpp:16
RHIObject & operator=(const RHIObject &)=delete
RHIObject(RHIObject const &)=delete
virtual ~RHIObject()=default
RHIObject & operator=(RHIObject &&)=delete
RHIObject(RHIObject &&)=delete
Scoped move-only RAII handle wrapper for RHI Objects.
Definition Details.hpp:86
RHIScopedHandle & operator=(RHIScopedHandle &&other) noexcept
Definition Details.hpp:100
RHIScopedHandle(const RHIScopedHandle &)=delete
RHIScopedHandle(RHIScopedHandle &&other) noexcept
Definition Details.hpp:96
void Reset()
Destructs the underlying RHIObject, and invalidates the scoped handle.
Definition Details.hpp:127
RHIScopedHandle(Factory *factory, Handle handle)
Definition Details.hpp:95
~RHIScopedHandle()
Definition Details.hpp:137
RHIScopedHandle & operator=(const RHIScopedHandle &)=delete
RHIHandle< Factory, T > Release()
Releases the underlying RHIHandle, invalidating the scoped handle. NOTE: This may leak the resource i...
Definition Details.hpp:118
RHIScopedHandle()=default
RHIHandle< Factory, T > View() const
Returns a non-owning view of the underlying RHIHandle.
Definition Details.hpp:113
void * pointer
Definition Allocator.hpp:7
std::unique_ptr< T, Deleter > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:166
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:149
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:4
uintptr_t Handle
Definition Details.hpp:8
static constexpr size_t kRHIObjectPoolMaxSize
Definition Details.hpp:143
static constexpr Handle kInvalidHandle
Definition Details.hpp:9
Custom deleter for Foundation::Core::UniquePtr and Foundation::Core::SharedPtr that uses a Foundation...
Definition Allocator.hpp:117
Provides type traits for types derived from RHIObject.
Definition Details.hpp:30