Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::rg::TargetPool Class Reference

#include <TargetPool.hpp>

Public Member Functions

 TargetPool (GfxDevice &device)
 ~TargetPool ()
 TargetPool (const TargetPool &)=delete
TargetPool & operator= (const TargetPool &)=delete
TargetHandle acquire (const TargetShape &shape)
 Borrow a target of this shape, reusing one or creating it.
void release (TargetHandle handle)
bool holds (TargetHandle handle) const
FramebufferHandle framebufferOf (TargetHandle handle) const
TextureHandle textureOf (TargetHandle handle) const
TextureHandle depthTextureOf (TargetHandle handle) const
TextureHandle gbufferTextureOf (TargetHandle handle) const
TextureHandle albedoTextureOf (TargetHandle handle) const
void age ()
 One tick of the clock every borrowed target is aged against.
void clear ()
u32 count () const
u64 bytes () const
void setIdleByteBudget (u64 bytes)
u64 idleByteBudget () const

Static Public Attributes

static constexpr u32 kIdleTicksBeforeEvict = 120
 Ticks a target may go unborrowed before the pool destroys it.
static constexpr u64 kIdleByteBudget = 256ull * 1024 * 1024
 Bytes of unborrowed targets the pool keeps, whatever their age: past it the longest idle are destroyed.
static constexpr u32 kBudgetGraceTicks = 4
 Ticks unborrowed before a target counts against that budget. More than one, since age runs once per graph and a frame can have several: a target one graph borrows is otherwise idle on the ticks the others take.

Detailed Description

Definition at line 64 of file TargetPool.hpp.

Constructor & Destructor Documentation

◆ TargetPool() [1/2]

esengine::rg::TargetPool::TargetPool ( GfxDevice & device)
explicit

Definition at line 40 of file TargetPool.cpp.

Referenced by TargetPool(), and operator=().

◆ ~TargetPool()

esengine::rg::TargetPool::~TargetPool ( )
default

◆ TargetPool() [2/2]

esengine::rg::TargetPool::TargetPool ( const TargetPool & )
delete

References TargetPool().

Member Function Documentation

◆ acquire()

◆ age()

void esengine::rg::TargetPool::age ( )

One tick of the clock every borrowed target is aged against.

Called once per graph. A target out on loan does not age; one nothing has borrowed for kIdleTicksBeforeEvict ticks is memory held against a chain that was turned off, or a scene that stopped casting shadows, and is destroyed.

Definition at line 143 of file TargetPool.cpp.

References esengine::rg::TargetShape::height, kBudgetGraceTicks, kIdleTicksBeforeEvict, and esengine::rg::TargetShape::width.

◆ albedoTextureOf()

TextureHandle esengine::rg::TargetPool::albedoTextureOf ( TargetHandle handle) const

Definition at line 138 of file TargetPool.cpp.

References esengine::Invalid.

◆ bytes()

u64 esengine::rg::TargetPool::bytes ( ) const

What they cost in GPU memory, so a budget reads bytes rather than a count of things with no common size.

Definition at line 196 of file TargetPool.cpp.

Referenced by setIdleByteBudget().

◆ clear()

void esengine::rg::TargetPool::clear ( )

Drop everything. For shutdown and for device loss, after which the handles the pool holds name nothing.

Definition at line 175 of file TargetPool.cpp.

◆ count()

u32 esengine::rg::TargetPool::count ( ) const

Physical targets currently allocated. Diagnostics and tests.

Definition at line 188 of file TargetPool.cpp.

◆ depthTextureOf()

TextureHandle esengine::rg::TargetPool::depthTextureOf ( TargetHandle handle) const

The depth attachment, for a target that has one — an effect reading the scene's depth samples this. Invalid when the shape carried no depth.

Definition at line 128 of file TargetPool.cpp.

References esengine::Invalid.

◆ framebufferOf()

FramebufferHandle esengine::rg::TargetPool::framebufferOf ( TargetHandle handle) const

Definition at line 118 of file TargetPool.cpp.

References esengine::Default.

◆ gbufferTextureOf()

TextureHandle esengine::rg::TargetPool::gbufferTextureOf ( TargetHandle handle) const

Its second colour attachment, Invalid for a target made without one.

Definition at line 133 of file TargetPool.cpp.

References esengine::Invalid.

◆ holds()

bool esengine::rg::TargetPool::holds ( TargetHandle handle) const

Whether a handle still names a live target — false once it was freed.

Definition at line 114 of file TargetPool.cpp.

◆ idleByteBudget()

u64 esengine::rg::TargetPool::idleByteBudget ( ) const
inline

Definition at line 129 of file TargetPool.hpp.

◆ operator=()

TargetPool & esengine::rg::TargetPool::operator= ( const TargetPool & )
delete

References TargetPool().

◆ release()

void esengine::rg::TargetPool::release ( TargetHandle handle)

Give one back. Borrowing again may hand out the same physical target.

Definition at line 109 of file TargetPool.cpp.

◆ setIdleByteBudget()

void esengine::rg::TargetPool::setIdleByteBudget ( u64 bytes)
inline

Definition at line 128 of file TargetPool.hpp.

References bytes().

◆ textureOf()

TextureHandle esengine::rg::TargetPool::textureOf ( TargetHandle handle) const

Definition at line 123 of file TargetPool.cpp.

References esengine::Invalid.

Member Data Documentation

◆ kBudgetGraceTicks

u32 esengine::rg::TargetPool::kBudgetGraceTicks = 4
staticconstexpr

Ticks unborrowed before a target counts against that budget. More than one, since age runs once per graph and a frame can have several: a target one graph borrows is otherwise idle on the ticks the others take.

Definition at line 133 of file TargetPool.hpp.

Referenced by age().

◆ kIdleByteBudget

u64 esengine::rg::TargetPool::kIdleByteBudget = 256ull * 1024 * 1024
staticconstexpr

Bytes of unborrowed targets the pool keeps, whatever their age: past it the longest idle are destroyed.

Definition at line 126 of file TargetPool.hpp.

◆ kIdleTicksBeforeEvict

u32 esengine::rg::TargetPool::kIdleTicksBeforeEvict = 120
staticconstexpr

Ticks a target may go unborrowed before the pool destroys it.

High on purpose: acquire() resets it, so this bounds only how long a target NOTHING asks for is kept against being asked for again. At a small number a target used by one of several chains would thrash on the ticks the others take.

Definition at line 123 of file TargetPool.hpp.

Referenced by age().


The documentation for this class was generated from the following files:
  • /home/runner/work/estella/estella/src/esengine/renderer/graph/TargetPool.hpp
  • /home/runner/work/estella/estella/src/esengine/renderer/graph/TargetPool.cpp