Draws one frame of UI draw data through donner::gpu.
More...
#include "donner/editor/gui/ImGuiRuntimeRenderer.h"
Public Member Functions | |
| std::weak_ptr< const void > | retirementLifetime () const |
| Owner token for deferred registration release; expires before renderer fields are destroyed. | |
| ~ImGuiRuntimeRenderer () | |
| Destructor. | |
| ImGuiRuntimeRenderer (const ImGuiRuntimeRenderer &)=delete | |
| ImGuiRuntimeRenderer & | operator= (const ImGuiRuntimeRenderer &)=delete |
| ImGuiRuntimeRenderer (ImGuiRuntimeRenderer &&)=delete | |
| ImGuiRuntimeRenderer & | operator= (ImGuiRuntimeRenderer &&)=delete |
| gpu::Status | buildFontAtlas (ImFontAtlas &atlas) |
Uploads atlas as the font texture, registers it, and publishes its identifier as the atlas texture id. | |
| gpu::Status | render (const ImDrawData &drawData, gpu::RenderPassEncoder &pass, const gpu::Extent2d &targetSizePx) |
Records drawData into pass. | |
| std::vector< UiTextureId > | advanceFrame () |
| Advances one presentation frame: releases the registrations whose retirement frames have passed and drops the bind group cached for each, so a cache entry and its device bind group do not outlive the registration they were built for. | |
| void | retainTextureBackingUntilReleased (UiTextureId id, gpu::Texture texture, gpu::TextureView view) |
| Transfers backing handles for a retired registration until its exact generation is released. | |
| size_t | retainedTextureBackingCountForTest () const |
| Number of retired texture backings still held. Test accessor. | |
| void | resetRendererState () |
| Drops the cached per-texture bind groups and the recorded pipeline selection, so the next render rebinds from scratch. | |
| size_t | cachedBindingCount () const |
| Number of bind groups currently cached, one per registration drawn since the last reset. | |
| void | install () |
| Publishes this renderer on the current ImGui context, so UI code that owns a texture can reach the registry its draw commands are resolved through without every panel being handed one. | |
| void | uninstall () |
| Stops publishing this renderer on the current ImGui context, if it is the published one. | |
| UiTextureId | fontAtlasTexture () const |
| Identifier of the registered font atlas, null until buildFontAtlas succeeds. | |
| UiTextureRegistry & | registry () const |
| Registry this renderer resolves draw commands through. | |
| gpu::Device & | device () const |
| Device this renderer draws on. A texture registered for it must belong to this device, which is not necessarily the device its pixels were rendered on. | |
| uint64_t | vertexCapacityBytes () const |
| Bytes currently allocated for vertices. | |
| uint64_t | indexCapacityBytes () const |
| Bytes currently allocated for indices. | |
Static Public Member Functions | |
| static gpu::Result< std::unique_ptr< ImGuiRuntimeRenderer > > | Create (gpu::Device &device, UiTextureRegistry ®istry, gpu::TextureFormat targetFormat) |
Creates a renderer drawing into targetFormat attachments. | |
Draws one frame of UI draw data through donner::gpu.
The renderer owns the compiled UI draw program, one pipeline per alpha interpretation, the per-frame vertex and index buffers, the projection uniform, the sampler, and the font atlas it registers. It resolves the texture of every draw command through a UiTextureRegistry, so a command naming a stale, foreign or retired registration is refused before any GPU work is recorded rather than reaching a backend as an unchecked address.
Vertex and index storage grows to fit a frame and never shrinks within a frame, which matches how the UI layer itself grows its draw lists. Growth is bounded: a frame needing more than kMaxVertexBytes or kMaxIndexBytes is refused with gpu::GpuErrorType::LimitExceeded instead of allocating whatever the draw data asked for.
| std::vector< UiTextureId > donner::editor::ImGuiRuntimeRenderer::advanceFrame | ( | ) |
Advances one presentation frame: releases the registrations whose retirement frames have passed and drops the bind group cached for each, so a cache entry and its device bind group do not outlive the registration they were built for.
Returns the released identifiers so the caller can drop whatever backing it held for them.
| gpu::Status donner::editor::ImGuiRuntimeRenderer::buildFontAtlas | ( | ImFontAtlas & | atlas | ) |
Uploads atlas as the font texture, registers it, and publishes its identifier as the atlas texture id.
Replaces and retires a previously built atlas, so rebuilding after a font change does not strand the old registration.
| atlas | Font atlas whose RGBA32 pixels are uploaded. |
|
static |
Creates a renderer drawing into targetFormat attachments.
| device | Device that owns every resource created here; must outlive the renderer. |
| registry | Registry every draw command's texture is resolved through; must outlive the renderer. |
| targetFormat | Color attachment format the pipelines are built for. |
| void donner::editor::ImGuiRuntimeRenderer::install | ( | ) |
Publishes this renderer on the current ImGui context, so UI code that owns a texture can reach the registry its draw commands are resolved through without every panel being handed one.
Transitional: the renderer is held in its own pointer rather than the context's renderer-backend slot, because UI code that still calls the previous backend's functions would read whatever occupies that slot as its own data type. This reverts to the idiomatic slot once the last caller of the previous backend is gone.
The caller keeps ownership; uninstall must run before the renderer is destroyed.
| gpu::Status donner::editor::ImGuiRuntimeRenderer::render | ( | const ImDrawData & | drawData, |
| gpu::RenderPassEncoder & | pass, | ||
| const gpu::Extent2d & | targetSizePx ) |
Records drawData into pass.
Nothing is recorded for empty draw data or a degenerate framebuffer.
A command this renderer cannot record is skipped and the rest of the frame is still recorded; the first such failure is returned once the frame is complete. A draw naming a texture the registry refuses, or carrying a user callback other than the render-state reset, therefore costs that draw rather than the whole interface, and still reports why. A failure that leaves the pass unusable for the commands after it - exceeding the upload bounds, or a failed state rebind - ends the frame instead.
| drawData | Draw data for the frame. |
| pass | Open render pass whose attachment matches the renderer's target format. |
| targetSizePx | Attachment extent in device pixels; scissor rectangles are clamped to it. |
| void donner::editor::ImGuiRuntimeRenderer::resetRendererState | ( | ) |
Drops the cached per-texture bind groups and the recorded pipeline selection, so the next render rebinds from scratch.
The buffers and their capacity are retained.