30 template <
typename Factory, std::derived_from<RHIObject> T>
41 template <
typename Factory,
typename T>
53 template <
typename U = T>
54 [[nodiscard]] U*
Get()
const
58 CHECK_MSG(ptr,
"RHIHandle::Get got nullptr");
59 return static_cast<U*
>(ptr);
64 constexpr operator bool() const noexcept {
return IsValid(); }
83 template <
typename Factory,
typename T>
145 template <
typename Base = RHIObject>
159 template <
typename U,
typename... Args>
162 Base* obj = Core::ConstructBase<Base, U>(
mAllocator, std::forward<Args>(args)...);
172 template <
typename U = Base>
177 return reinterpret_cast<U*
>(obj);
200 class RHIApplication;
201 template <
typename T>
203 template <
typename T>
207 template <
typename T>
209 template <
typename T>
#define CHECK_MSG(expr, format_str,...)
Allocator interface (noexcept)
Definition Allocator.hpp:29
Mutex-protected, dynamically sized object pool with stable object pointers.
Definition AtomicPool.hpp:160
T * Construct(Args &&... args)
Constructs an object of type T in the pool with the given arguments.
Definition AtomicPool.hpp:180
void Destruct(T *ptr)
Destructs the object pointed to by ptr and releases its storage.
Definition AtomicPool.hpp:189
void Collect()
Destructs all allocated objects in the pool.
Definition AtomicPool.hpp:211
Definition Device.hpp:246
Handle type for RHI Objects.
Definition Details.hpp:43
bool IsValid() const
Check if the handle is valid (i.e. associated with a Factory and not kInvalidHandle)
Definition Details.hpp:73
constexpr Handle operator()() const
Definition Details.hpp:63
bool operator==(const RHIHandle &other) const
Definition Details.hpp:66
U * Get() const
Retrieves the underlying RHIObject pointer. It is undefined behavior to use the returned pointer afte...
Definition Details.hpp:54
T * operator->() const
Definition Details.hpp:61
void Invalidate()
Resets the handle to an invalid state. After calling this, the handle is no longer associated with an...
Definition Details.hpp:78
Handle mHandle
Definition Details.hpp:47
Factory * mFactory
Definition Details.hpp:46
constexpr T * operator*() noexcept
Definition Details.hpp:65
Thread-safe type-erased handle dereference facility for RHI Objects.
Definition Details.hpp:147
RHIObjectPool(Core::Allocator *allocator)
Definition Details.hpp:154
static U * GetObjectPtr(Handle handle) noexcept
Retrieves the raw pointer to the object within the storage.
Definition Details.hpp:173
Core::DynamicPool< PointerType > mPool
Definition Details.hpp:151
Core::UniquePtr< Base > PointerType
Definition Details.hpp:148
Core::Allocator * mAllocator
Definition Details.hpp:150
void Destroy()
Destroys all objects in the pool.
Definition Details.hpp:190
Handle CreateObject(Args &&... args)
Creates specified RHIObject of derived type T and retrieves its handle.
Definition Details.hpp:160
void DestroyObject(Handle handle)
Destroys the object associated with the given handle, and frees the handle for reuse.
Definition Details.hpp:182
Base class for all RHI objects.
Definition Details.hpp:17
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:85
RHIScopedHandle & operator=(RHIScopedHandle &&other) noexcept
Definition Details.hpp:99
RHIScopedHandle(const RHIScopedHandle &)=delete
RHIScopedHandle(RHIScopedHandle &&other) noexcept
Definition Details.hpp:95
void Reset()
Destructs the underlying RHIObject, and invalidates the scoped handle.
Definition Details.hpp:126
RHIScopedHandle(Factory *factory, Handle handle)
Definition Details.hpp:94
~RHIScopedHandle()
Definition Details.hpp:136
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:117
RHIScopedHandle()=default
RHIHandle< Factory, T > View() const
Returns a non-owning view of the underlying RHIHandle.
Definition Details.hpp:112
void * pointer
Definition Allocator.hpp:8
std::unique_ptr< T, Deleter > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:180
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:3
uintptr_t Handle
Definition Details.hpp:9
static constexpr Handle kInvalidHandle
Definition Details.hpp:10
Custom deleter for Foundation::Core::UniquePtr and Foundation::Core::SharedPtr that uses a Foundation...
Definition Allocator.hpp:131
Provides type traits for types derived from RHIObject.
Definition Details.hpp:31