|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
#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. | |
Definition at line 64 of file TargetPool.hpp.
|
explicit |
Definition at line 40 of file TargetPool.cpp.
Referenced by TargetPool(), and operator=().
|
default |
|
delete |
References TargetPool().
| TargetHandle esengine::rg::TargetPool::acquire | ( | const TargetShape & | shape | ) |
Borrow a target of this shape, reusing one or creating it.
Definition at line 55 of file TargetPool.cpp.
References esengine::FramebufferSpec::colorFormat, esengine::Framebuffer::create(), esengine::FramebufferSpec::depthStencil, esengine::rg::TargetShape::depthStencil, ES_LOG_ERROR, esengine::rg::TargetShape::format, esengine::FramebufferSpec::gbuffer, esengine::rg::TargetShape::gbuffer, esengine::FramebufferSpec::height, esengine::rg::TargetShape::height, esengine::rg::kNoTarget, esengine::FramebufferSpec::linearFilter, esengine::rg::TargetShape::linearFilter, esengine::FramebufferSpec::samples, esengine::rg::TargetShape::samples, esengine::FramebufferSpec::storage, esengine::rg::TargetShape::storage, esengine::FramebufferSpec::width, and esengine::rg::TargetShape::width.
| 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.
| TextureHandle esengine::rg::TargetPool::albedoTextureOf | ( | TargetHandle | handle | ) | const |
Definition at line 138 of file TargetPool.cpp.
References esengine::Invalid.
| 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().
| 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.
| u32 esengine::rg::TargetPool::count | ( | ) | const |
Physical targets currently allocated. Diagnostics and tests.
Definition at line 188 of file TargetPool.cpp.
| 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.
| FramebufferHandle esengine::rg::TargetPool::framebufferOf | ( | TargetHandle | handle | ) | const |
Definition at line 118 of file TargetPool.cpp.
References esengine::Default.
| 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.
| 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.
|
inline |
Definition at line 129 of file TargetPool.hpp.
|
delete |
References TargetPool().
| 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.
|
inline |
Definition at line 128 of file TargetPool.hpp.
References bytes().
| TextureHandle esengine::rg::TargetPool::textureOf | ( | TargetHandle | handle | ) | const |
Definition at line 123 of file TargetPool.cpp.
References esengine::Invalid.
|
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().
|
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.
|
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().