22 const auto*
bytes =
static_cast<const std::uint8_t*
>(data);
23 return std::make_shared<std::vector<std::uint8_t>>(
bytes,
bytes +
size);
35 static_cast<std::uint32_t
>((*bgfx_ref)->size()),
183 std::uint32_t min_age_frames = 0,
184 std::uint32_t max_evictions = 0) ->
stats;
214void set_budget(
const budget_state& budget, std::uint64_t used_bytes);
void note_pending_allocation(std::uint64_t bytes)
auto is_supported() -> bool
void restore_resource(ievictable *resource)
auto make_backing_ref(const backing_buffer &backing) -> const memory_view *
auto current_budget() -> budget_state
auto evict() -> stats
Run a single eviction pass using the config supplied to init.
auto get_stats() -> stats
Snapshot the current statistics.
auto restore_all() -> stats
auto debug_simulate_budget(std::uint64_t target_free_bytes) -> std::uint64_t
std::shared_ptr< std::vector< std::uint8_t > > backing_buffer
auto debug_consume_memory(std::uint64_t bytes) -> std::uint64_t
auto evict_bytes(std::uint64_t free_bytes, strategy strat, std::uint32_t min_age_frames, std::uint32_t max_evictions) -> stats
constexpr auto to_string(reclaim_result r) -> const char *
Human-readable name for reclaim_result (for diagnostics / logging).
auto evict_all() -> stats
void set_budget(const budget_state &budget, std::uint64_t used_bytes)
void register_resource(ievictable *resource)
Begin tracking a resource (assumed resident). Called from handle_impl::make_evictable.
auto would_allocation_fit(std::uint64_t bytes) -> bool
void register_evicted_resource(ievictable *resource)
auto peek_pending_release_bytes() -> std::uint64_t
auto make_backing(const void *data, std::uint32_t size) -> backing_buffer
void clear_queued_allocations()
auto debug_consumed_bytes() -> std::uint64_t
Total bytes currently reserved by debug_consume_memory.
auto init(const config &cfg) -> init_status
auto peek_external_queued_bytes() -> std::uint64_t
strategy
Selection policy used by a sweep to choose eviction victims.
@ lfu
Least frequently used first (smallest use count).
@ lru
Least recently used first (smallest last-use frame).
@ age_ttl
Every resource idle for longer than config::max_idle_frames.
@ largest_first
Largest resources first (fastest headroom recovery).
void release_backing_ref(void *, void *user_data)
reclaim_kind
Controls whether reclaim_for pumps the GPU command buffer after evicting.
void debug_release_memory()
init_status
Result of init. Determines whether the system tracks resources at all.
@ failed
Initialization failed (graphics not ready).
@ ok
Initialized and active.
@ unsupported
Backend does not report a GPU memory budget; eviction is disabled.
@ unnecessary
Eviction is not needed for this backend (driver manages residency).
auto peek_queued_bytes() -> std::uint64_t
void set_frame(std::uint64_t frame)
Set the global frame counter (call once per presented frame).
void advance_frame()
Advance the global frame counter by one.
auto reclaim_for(std::uint64_t bytes, reclaim_kind kind) -> reclaim_result
void unregister_resource(ievictable *resource)
Stop tracking a resource. Called from handle_impl's destructor.
@ insufficient
Eviction could not free enough room; the allocation may exhaust device memory.
@ headroom
Already enough headroom; nothing was done.
@ reclaimed
Eviction (and possibly a command-buffer pump) freed enough room.
const memory_view * make_ref(const void *_data, uint32_t _size, release_fn _releaseFn, void *_userData)
std::uint64_t soft_budget_bytes
std::uint64_t hard_limit_bytes
std::uint64_t safety_margin_bytes
std::uint64_t target_bytes
Configuration for a single eviction pass.
std::uint64_t target_bytes
Evict down to this watermark (<= budget) to provide hysteresis. 0 falls back to budget_bytes.
strategy strat
Victim selection policy.
std::uint64_t budget_bytes
std::uint32_t max_idle_frames
For strategy::age_ttl: evict anything idle for more than this many frames.
std::uint32_t min_age_frames
Never evict a resource used within this many frames (anti-thrash protection).
std::uint32_t max_evictions
Maximum number of resources to evict in a single pass (bounds latency). 0 means unlimited.
Cumulative and last-pass statistics reported by the eviction system.
double last_pass_ms
Duration of the most recent sweep in milliseconds.
std::uint64_t last_pass_evicted
Resources evicted by the most recent sweep.
std::uint64_t evicted_bytes
GPU bytes currently reclaimed.
std::uint64_t last_pass_scanned
Candidates considered by the most recent sweep.
std::uint64_t budget_used_bytes
Metric compared against the budget (e.g. GPU mem used).
std::uint64_t target_bytes
Watermark the driver evicts down to.
std::uint64_t resident_bytes
GPU bytes currently resident.
double last_restore_ms
Duration of the most recent restore in milliseconds.
std::uint64_t total_restores
Lifetime number of restores.
std::uint64_t total_evictions
Lifetime number of evictions.
std::uint64_t total_bytes_evicted
Lifetime GPU bytes evicted.
std::uint64_t last_pass_freed_bytes
GPU bytes reclaimed by the most recent sweep.
std::uint64_t evicted_count
Resources currently evicted.
std::uint64_t failed_restores
Restores that failed to recreate a handle.
std::uint64_t pending_release_bytes
Destroys queued in bgfx but not yet reflected in gpuMemoryUsed.
std::uint64_t total_bytes_restored
Lifetime GPU bytes restored.
std::uint64_t resident_count
Resources currently resident on the GPU.
std::uint64_t budget_bytes
Active budget reported by the driver (0 = none).
std::uint64_t thrash_events
Restores within min_age_frames of their eviction.
std::uint64_t registered_count
Total tracked resources (resident + evicted).