pub struct AtlasRenderer { /* private fields */ }Expand description
The GPU home for glyph pixels: replays glifo’s recorded atlas commands
into the atlas array’s own layers, and services the two pixel drains that
have to be ordered around them.
Owned for the life of a renderer, beside the AtlasArray it writes rather
than inside it — the array is a texture a scene pass samples, this is the
machinery a replay pass needs, and most renderers never take the replay
path at all. See the module doc’s Rendering into the atlas for the three
orderings this type exists to keep.
Nothing here is reached by the frame path until the text backend turns
glifo’s atlas cacher on; a renderer that holds one and drives it every
frame submits nothing on any frame that missed no glyph
(AtlasRenderReport::is_empty).
Implementations§
Source§impl AtlasRenderer
impl AtlasRenderer
Sourcepub fn new(device: &Device, caps: &TierCaps) -> Self
pub fn new(device: &Device, caps: &TierCaps) -> Self
An atlas renderer for caps’ adapter.
The coverage texture is created at its minimum height and grown by the first page that needs more, the same growth-only rule every other resource texture in this crate follows.
Sourcepub fn alpha_texture_size(&self) -> (u32, u32)
pub fn alpha_texture_size(&self) -> (u32, u32)
The coverage texture’s current extent in texels.
Sourcepub fn instance_capacity(&self) -> u64
pub fn instance_capacity(&self) -> u64
The instance buffer’s current capacity in bytes.
Sourcepub fn clear_rect(
&self,
queue: &Queue,
atlas: &AtlasArray,
rect: PendingClearRect,
) -> bool
pub fn clear_rect( &self, queue: &Queue, atlas: &AtlasArray, rect: PendingClearRect, ) -> bool
Zero one evicted rectangle, answering whether the array took it.
A queue write, not a scissored pass, for AtlasArray::clear_region’s
reason — and issued through the queue rather than an encoder so that it
is guaranteed to land before any pass of the same submit, which is what
lets a rectangle freed this frame be drawn into this frame.
Sourcepub fn upload_pixmap(
&self,
queue: &Queue,
atlas: &AtlasArray,
upload: &PendingBitmapUpload,
) -> bool
pub fn upload_pixmap( &self, queue: &Queue, atlas: &AtlasArray, upload: &PendingBitmapUpload, ) -> bool
Write one already-rasterized glyph pixmap into its slot, answering whether the array took it.
The slot’s extent is what is written, not the pixmap’s: a pixmap whose dimensions disagree with the slot it was allocated for would be written at the wrong stride and smear across the page, so the mismatch is refused here rather than handed to the queue.
Sourcepub fn render_page(
&mut self,
device: &Device,
queue: &Queue,
pipeline: &RenderPipeline,
atlas: &AtlasArray,
layer: u32,
page: &mut AtlasPageBuffers,
timestamps: FrameTimestamps<'_>,
) -> Result<u32, EngineError>
pub fn render_page( &mut self, device: &Device, queue: &Queue, pipeline: &RenderPipeline, atlas: &AtlasArray, layer: u32, page: &mut AtlasPageBuffers, timestamps: FrameTimestamps<'_>, ) -> Result<u32, EngineError>
Draw one page’s lowered replay into array layer layer, on a command
encoder of this method’s own, submitted before it returns.
Returns how many instances were drawn — zero for an empty page, which costs no submit at all.
timestamps charges this pass to EngineSpan::Prepass — the atlas
replay’s own recording site, one own-encoder submit per dirty page (see
this module’s header), so several pages in one frame are several passes
summed into the one span. The fresh pair is asked for only once the
empty-page early return is behind us, so a page with nothing to draw
never spends a query pair on a pass that was never opened.
§Errors
EngineError::AtlasError when the array has no layer layer;
EngineError::AlphaCapacity when the page’s coverage is past what a
resource texture of this adapter’s dimension can hold. Both leave the
atlas exactly as it was — nothing is recorded before either is checked.
Sourcepub fn render_pending<L>(
&mut self,
device: &Device,
queue: &Queue,
pipeline: &RenderPipeline,
atlas: &AtlasArray,
glyphs: &mut GlyphAtlas,
timestamps: FrameTimestamps<'_>,
lower: L,
) -> AtlasRenderReport
pub fn render_pending<L>( &mut self, device: &Device, queue: &Queue, pipeline: &RenderPipeline, atlas: &AtlasArray, glyphs: &mut GlyphAtlas, timestamps: FrameTimestamps<'_>, lower: L, ) -> AtlasRenderReport
Service every drain glyphs has pending and replay every page it
dirtied, strictly ahead of the caller’s own scene pass.
The order is the contract: evicted rectangles are zeroed, then bitmap
pixmaps are written, then each dirty page’s commands are lowered by
lower and drawn. lower answers false for a page it declines — a
command stream carrying a shape this tier has no lowering for, which is
how a colour glyph goes missing rather than landing wrong — and the
page is counted in AtlasRenderReport::refused and left undrawn.
pipeline must be the one built from
super::pipelines::atlas_strip_desc: a bind group is built against
the pipeline’s own derived layout, so another variant’s is rejected even
where the two layouts are structurally identical.
timestamps is passed straight through to Self::render_page for
each dirty page replayed — see that method’s docs for the EngineSpan
it charges to and why an empty page spends no query pair on it.