pub struct InstancedRectRenderer { /* private fields */ }Expand description
A frame-scoped collector of InstanceRect data and a flusher that
issues a single instanced draw call.
§Usage
- Call
pushonce per rectangle to append to the batch. - Call
flushto upload the instance buffer and issue onedraw_indexed(0..6, 0, 0..n)call. - Call
clearat the start of the next frame (or after flush).
Implementations§
Source§impl InstancedRectRenderer
impl InstancedRectRenderer
Sourcepub fn new(initial_capacity: usize) -> Self
pub fn new(initial_capacity: usize) -> Self
Create a renderer pre-allocated for initial_capacity instances.
Sourcepub fn push(&mut self, inst: InstanceRect)
pub fn push(&mut self, inst: InstanceRect)
Append one rectangle instance to the pending batch.
Sourcepub fn flush(
&mut self,
device: &Device,
queue: &Queue,
encoder: &mut CommandEncoder,
pipeline: &InstancedRectPipeline,
globals_bind_group: &BindGroup,
screen_view: &TextureView,
screen_resolve: Option<&TextureView>,
viewport_w: u32,
viewport_h: u32,
) -> Result<u32, UiError>
pub fn flush( &mut self, device: &Device, queue: &Queue, encoder: &mut CommandEncoder, pipeline: &InstancedRectPipeline, globals_bind_group: &BindGroup, screen_view: &TextureView, screen_resolve: Option<&TextureView>, viewport_w: u32, viewport_h: u32, ) -> Result<u32, UiError>
Upload the instance buffer and issue a single instanced draw call.
Opens a render pass on encoder, uses LoadOp::Load so existing frame
content is preserved. The scissor is set to the full viewport.
Returns the number of draw calls issued (0 if empty, 1 otherwise).
§Errors
Returns UiError::Render if buffer creation fails.
Auto Trait Implementations§
impl !RefUnwindSafe for InstancedRectRenderer
impl !UnwindSafe for InstancedRectRenderer
impl Freeze for InstancedRectRenderer
impl Send for InstancedRectRenderer
impl Sync for InstancedRectRenderer
impl Unpin for InstancedRectRenderer
impl UnsafeUnpin for InstancedRectRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more