Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gfx::handle_impl< Base, T > Class Template Reference

#include <handle_impl.h>

Inheritance diagram for gfx::handle_impl< Base, T >:
gfx::ievictable

Public Types

using ptr = std::shared_ptr<Base>
 
using uptr = std::unique_ptr<Base>
 
using weak_ptr = std::weak_ptr<Base>
 
using handle_type_t = T
 
using base_type = Base
 

Public Member Functions

 handle_impl ()=default
 
 handle_impl (const handle_impl &)=delete
 
auto operator= (const handle_impl &) -> handle_impl &=delete
 
 handle_impl (handle_impl &&)=delete
 
auto operator= (handle_impl &&) -> handle_impl &=delete
 
 ~handle_impl () override
 
void dispose ()
 
auto is_valid () const -> bool
 
auto native_handle () const -> T
 
void set_name (const hpp::string_view &_name)
 
auto on_evict () -> std::uint64_t override
 Release the GPU handle. Returns the number of GPU bytes freed. Must be idempotent.
 
auto on_restore () -> bool override
 Recreate the GPU handle from the CPU backing. Returns true on success.
 
auto gpu_size () const -> std::uint64_t override
 Approximate GPU footprint of the resource in bytes.
 
- Public Member Functions inherited from gfx::ievictable
 ievictable ()=default
 
 ievictable (const ievictable &)=delete
 
auto operator= (const ievictable &) -> ievictable &=delete
 
 ievictable (ievictable &&)=delete
 
auto operator= (ievictable &&) -> ievictable &=delete
 
virtual ~ievictable ()=default
 
auto get_evict_class () const -> evict_class
 
auto get_evict_state () const -> evict_state
 
auto get_last_use_frame () const -> std::uint64_t
 
auto get_use_count () const -> std::uint64_t
 
void touch () const noexcept
 

Static Public Member Functions

static auto invalid_handle () -> T
 

Protected Member Functions

auto fallback_handle () const -> T
 
auto get_fallback_handle () const -> T
 
void make_evictable (std::uint64_t gpu_bytes, std::function< bool(Base &)> restore_fn, evict_class cls=evict_class::evictable)
 
void make_evictable_deferred (std::uint64_t gpu_bytes, std::function< bool(Base &)> restore_fn, evict_class cls=evict_class::evictable)
 

Protected Attributes

handle_ = invalid_handle()
 
std::function< bool(Base &)> restore_fn_
 
std::uint64_t gpu_size_ = 0
 
- Protected Attributes inherited from gfx::ievictable
std::uint64_t last_use_frame_ {0}
 Frame the resource was last used on (heuristic, written from touch).
 
std::uint64_t use_count_ {0}
 Number of times the resource was used (heuristic, written from touch).
 
evict_state evict_state_ {evict_state::resident}
 Current residency state. Written by the owning resource during evict/restore.
 
evict_class evict_class_ {evict_class::non_evictable}
 Eligibility class. Set once when the resource opts into eviction.
 

Detailed Description

template<typename Base, typename T>
class gfx::handle_impl< Base, T >

Definition at line 13 of file handle_impl.h.

Member Typedef Documentation

◆ base_type

template<typename Base , typename T >
using gfx::handle_impl< Base, T >::base_type = Base

Definition at line 21 of file handle_impl.h.

◆ handle_type_t

template<typename Base , typename T >
using gfx::handle_impl< Base, T >::handle_type_t = T

Definition at line 20 of file handle_impl.h.

◆ ptr

template<typename Base , typename T >
using gfx::handle_impl< Base, T >::ptr = std::shared_ptr<Base>

Definition at line 16 of file handle_impl.h.

◆ uptr

template<typename Base , typename T >
using gfx::handle_impl< Base, T >::uptr = std::unique_ptr<Base>

Definition at line 17 of file handle_impl.h.

◆ weak_ptr

template<typename Base , typename T >
using gfx::handle_impl< Base, T >::weak_ptr = std::weak_ptr<Base>

Definition at line 18 of file handle_impl.h.

Constructor & Destructor Documentation

◆ handle_impl() [1/3]

template<typename Base , typename T >
gfx::handle_impl< Base, T >::handle_impl ( )
default

◆ handle_impl() [2/3]

template<typename Base , typename T >
gfx::handle_impl< Base, T >::handle_impl ( const handle_impl< Base, T > & )
delete

◆ handle_impl() [3/3]

template<typename Base , typename T >
gfx::handle_impl< Base, T >::handle_impl ( handle_impl< Base, T > && )
delete

◆ ~handle_impl()

template<typename Base , typename T >
gfx::handle_impl< Base, T >::~handle_impl ( )
inlineoverride

Definition at line 29 of file handle_impl.h.

Member Function Documentation

◆ dispose()

template<typename Base , typename T >
void gfx::handle_impl< Base, T >::dispose ( )
inline

Definition at line 38 of file handle_impl.h.

◆ fallback_handle()

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::fallback_handle ( ) const -> T
inlineprotected

Definition at line 112 of file handle_impl.h.

◆ get_fallback_handle()

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::get_fallback_handle ( ) const -> T
inlineprotected

Definition at line 117 of file handle_impl.h.

◆ gpu_size()

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::gpu_size ( ) const -> std::uint64_t
inlinenodiscardoverridevirtual

Approximate GPU footprint of the resource in bytes.

Implements gfx::ievictable.

Definition at line 106 of file handle_impl.h.

◆ invalid_handle()

template<typename Base , typename T >
static auto gfx::handle_impl< Base, T >::invalid_handle ( ) -> T
inlinestatic

Definition at line 68 of file handle_impl.h.

◆ is_valid()

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::is_valid ( ) const -> bool
inlinenodiscard

Definition at line 48 of file handle_impl.h.

◆ make_evictable()

template<typename Base , typename T >
void gfx::handle_impl< Base, T >::make_evictable ( std::uint64_t gpu_bytes,
std::function< bool(Base &)> restore_fn,
evict_class cls = evict_class::evictable )
inlineprotected

Opt the resource into the eviction system. Call once, after the GPU handle is created and a CPU-side backing exists. restore_fn recreates the handle from that backing and returns true on success. Resources that never call this stay evict_class::non_evictable and incur no tracking cost.

Definition at line 125 of file handle_impl.h.

◆ make_evictable_deferred()

template<typename Base , typename T >
void gfx::handle_impl< Base, T >::make_evictable_deferred ( std::uint64_t gpu_bytes,
std::function< bool(Base &)> restore_fn,
evict_class cls = evict_class::evictable )
inlineprotected

Opt in with CPU backing but no GPU handle yet (create skipped or deferred). Restored on the next native_handle access via the same path as post-eviction restore.

Definition at line 142 of file handle_impl.h.

◆ native_handle()

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::native_handle ( ) const -> T
inline

Definition at line 53 of file handle_impl.h.

◆ on_evict()

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::on_evict ( ) -> std::uint64_t
inlineoverridevirtual

Release the GPU handle. Returns the number of GPU bytes freed. Must be idempotent.

Implements gfx::ievictable.

Definition at line 79 of file handle_impl.h.

◆ on_restore()

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::on_restore ( ) -> bool
inlineoverridevirtual

Recreate the GPU handle from the CPU backing. Returns true on success.

Implements gfx::ievictable.

Definition at line 95 of file handle_impl.h.

◆ operator=() [1/2]

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::operator= ( const handle_impl< Base, T > & ) -> handle_impl &=delete
delete

◆ operator=() [2/2]

template<typename Base , typename T >
auto gfx::handle_impl< Base, T >::operator= ( handle_impl< Base, T > && ) -> handle_impl &=delete
delete

◆ set_name()

template<typename Base , typename T >
void gfx::handle_impl< Base, T >::set_name ( const hpp::string_view & _name)
inline

Definition at line 74 of file handle_impl.h.

Member Data Documentation

◆ gpu_size_

template<typename Base , typename T >
std::uint64_t gfx::handle_impl< Base, T >::gpu_size_ = 0
protected

Definition at line 159 of file handle_impl.h.

◆ handle_

template<typename Base , typename T >
T gfx::handle_impl< Base, T >::handle_ = invalid_handle()
protected

Definition at line 157 of file handle_impl.h.

◆ restore_fn_

template<typename Base , typename T >
std::function<bool(Base&)> gfx::handle_impl< Base, T >::restore_fn_
protected

Definition at line 158 of file handle_impl.h.


The documentation for this class was generated from the following file: