Registrations of runtime textures that UI draw data may sample, keyed by an opaque identifier. More...
#include "donner/editor/gui/UiTextureRegistry.h"
Public Member Functions | |
| UiTextureRegistry (const gpu::Device &device, uint32_t retirementFrames=kDefaultRetirementFrames) | |
Constructs a registry bound to device. | |
| ~UiTextureRegistry () | |
| Destructor. Registrations do not own their backing, so nothing is released here. | |
| UiTextureRegistry (const UiTextureRegistry &)=delete | |
| UiTextureRegistry & | operator= (const UiTextureRegistry &)=delete |
| UiTextureRegistry (UiTextureRegistry &&)=delete | |
| UiTextureRegistry & | operator= (UiTextureRegistry &&)=delete |
| gpu::Result< UiTextureId > | registerTexture (const UiTextureDescriptor &descriptor) |
Registers descriptor and returns the identifier to hand ImGui. | |
| gpu::Result< UiTextureBinding > | lookup (UiTextureId id) const |
Resolves id to its registration. | |
| gpu::Status | retire (UiTextureId id) |
Retires the registration id names. | |
| std::vector< UiTextureId > | advanceFrame () |
| Advances one presentation frame and returns the identifiers whose retirement frames have passed, in registration order. | |
| size_t | liveCount () const |
| Number of registrations that lookups still accept. | |
| size_t | retiredCount () const |
| Number of retired registrations still occupying a slot. | |
| uint32_t | retirementFrames () const |
| Frames a retired registration occupies its slot for. | |
Registrations of runtime textures that UI draw data may sample, keyed by an opaque identifier.
A registration records the view, its sampled extent and its alpha interpretation, and binds all three to one device. Registering does not take ownership of the backing: the producer keeps the texture alive, and the registry reports when a retired registration's frames have passed so the producer can release it.
Every lookup revalidates, in release builds too, because the identifier arrives from recorded draw data rather than from the caller that registered it: a null identifier, an identifier whose slot was reused for a later registration, an identifier minted against another device, and a retired registration all fail closed instead of reaching a backend. A view destroyed while its registration is live is caught where the returned UiTextureBinding is consumed, by the generation check the device already runs on every bind group it builds.
Retirement is deferred by frames rather than immediate. retire makes a registration unusable for new draw data at once, but keeps its slot occupied for retirementFrames() calls to advanceFrame, so a frame already recorded against it can still be submitted before the producer releases the backing.
|
explicit |
Constructs a registry bound to device.
| device | Device every registered view must belong to; must outlive the registry. |
| retirementFrames | Frames a retired registration occupies its slot for. |
| std::vector< UiTextureId > donner::editor::UiTextureRegistry::advanceFrame | ( | ) |
Advances one presentation frame and returns the identifiers whose retirement frames have passed, in registration order.
Their backing is no longer reachable through this registry, so the producer may release it. Their slots are reusable, with a bumped generation, from the next registerTexture.
| gpu::Result< UiTextureBinding > donner::editor::UiTextureRegistry::lookup | ( | UiTextureId | id | ) | const |
Resolves id to its registration.
Fails closed with gpu::GpuErrorType::InvalidHandle when id is null, names a slot this registry never handed out, or carries the generation of a registration whose slot has since been reused, and with gpu::GpuErrorType::InvalidState when the registration is retired.
| id | Identifier carried through draw data. |
| gpu::Result< UiTextureId > donner::editor::UiTextureRegistry::registerTexture | ( | const UiTextureDescriptor & | descriptor | ) |
Registers descriptor and returns the identifier to hand ImGui.
Fails closed with gpu::GpuErrorType::InvalidHandle for a null view, gpu::GpuErrorType::DeviceMismatch for a view of another device, and gpu::GpuErrorType::InvalidDescriptor for a zero extent.
| descriptor | View, extent and alpha interpretation to register. |
| gpu::Status donner::editor::UiTextureRegistry::retire | ( | UiTextureId | id | ) |
Retires the registration id names.
Later lookups fail, and the slot is released after retirementFrames() calls to advanceFrame. Fails closed exactly like lookup, except that retiring an already-retired registration is an error rather than a no-op so a double release is reported at its source.
| id | Identifier to retire. |