Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gfx::ievictable Class Referenceabstract

#include <evictable.h>

Inheritance diagram for gfx::ievictable:
gfx::handle_impl< frame_buffer, frame_buffer_handle > gfx::handle_impl< index_buffer, index_buffer_handle > gfx::handle_impl< program, program_handle > gfx::handle_impl< shader, shader_handle > gfx::handle_impl< texture, texture_handle > gfx::handle_impl< uniform, uniform_handle > gfx::handle_impl< vertex_buffer, vertex_buffer_handle > gfx::handle_impl< Base, T >

Public Member Functions

 ievictable ()=default
 
 ievictable (const ievictable &)=delete
 
auto operator= (const ievictable &) -> ievictable &=delete
 
 ievictable (ievictable &&)=delete
 
auto operator= (ievictable &&) -> ievictable &=delete
 
virtual ~ievictable ()=default
 
virtual auto on_evict () -> std::uint64_t=0
 Release the GPU handle. Returns the number of GPU bytes freed. Must be idempotent.
 
virtual auto on_restore () -> bool=0
 Recreate the GPU handle from the CPU backing. Returns true on success.
 
virtual auto gpu_size () const -> std::uint64_t=0
 Approximate GPU footprint of the resource in bytes.
 
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
 

Protected Attributes

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.
 

Friends

class eviction_registry
 

Detailed Description

Abstract contract for a GPU resource that can release its GPU memory (evict) and later recreate it from a retained CPU-side backing (restore).

Threading contract: touch, eviction and restore all run on the graphics API (render) thread, so the per-resource bookkeeping below needs no synchronization. The only cross-thread access is registration/unregistration during resource create/destroy on worker threads, which the eviction_registry serializes with its own mutex.

Definition at line 38 of file evictable.h.

Constructor & Destructor Documentation

◆ ievictable() [1/3]

gfx::ievictable::ievictable ( )
default

◆ ievictable() [2/3]

gfx::ievictable::ievictable ( const ievictable & )
delete

◆ ievictable() [3/3]

gfx::ievictable::ievictable ( ievictable && )
delete

◆ ~ievictable()

virtual gfx::ievictable::~ievictable ( )
virtualdefault

Member Function Documentation

◆ get_evict_class()

auto gfx::ievictable::get_evict_class ( ) const -> evict_class
inlinenodiscard

Definition at line 57 of file evictable.h.

◆ get_evict_state()

auto gfx::ievictable::get_evict_state ( ) const -> evict_state
inlinenodiscard

Definition at line 62 of file evictable.h.

◆ get_last_use_frame()

auto gfx::ievictable::get_last_use_frame ( ) const -> std::uint64_t
inlinenodiscard

Definition at line 67 of file evictable.h.

◆ get_use_count()

auto gfx::ievictable::get_use_count ( ) const -> std::uint64_t
inlinenodiscard

Definition at line 72 of file evictable.h.

◆ gpu_size()

◆ on_evict()

◆ on_restore()

◆ operator=() [1/2]

auto gfx::ievictable::operator= ( const ievictable & ) -> ievictable &=delete
delete

◆ operator=() [2/2]

auto gfx::ievictable::operator= ( ievictable && ) -> ievictable &=delete
delete

◆ touch()

void gfx::ievictable::touch ( ) const
inlinenoexcept

Hot path: mark the resource as used on the current frame. Must be called on the render thread (it is reached only through native_handle during submission). Strategies read these counters during a sweep, also on the render thread.

Definition at line 80 of file evictable.h.

Friends And Related Symbol Documentation

◆ eviction_registry

friend class eviction_registry
friend

Definition at line 102 of file evictable.h.

Member Data Documentation

◆ evict_class_

evict_class gfx::ievictable::evict_class_ {evict_class::non_evictable}
protected

Eligibility class. Set once when the resource opts into eviction.

Definition at line 94 of file evictable.h.

◆ evict_state_

evict_state gfx::ievictable::evict_state_ {evict_state::resident}
protected

Current residency state. Written by the owning resource during evict/restore.

Definition at line 92 of file evictable.h.

◆ last_use_frame_

std::uint64_t gfx::ievictable::last_use_frame_ {0}
mutableprotected

Frame the resource was last used on (heuristic, written from touch).

Definition at line 88 of file evictable.h.

◆ use_count_

std::uint64_t gfx::ievictable::use_count_ {0}
mutableprotected

Number of times the resource was used (heuristic, written from touch).

Definition at line 90 of file evictable.h.


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