Skip to main content

AtlasRenderer

Struct AtlasRenderer 

Source
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

Source

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.

Source

pub fn alpha_texture_size(&self) -> (u32, u32)

The coverage texture’s current extent in texels.

Source

pub fn instance_capacity(&self) -> u64

The instance buffer’s current capacity in bytes.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for AtlasRenderer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,