pub struct HostBuffer { /* private fields */ }Expand description
HostBuffer bump-allocates per-draw uniforms and transient vertex data.
Each frame writes into CPU scratch; Self::flush copies touched blocks
with one queue.write_buffer each. wgpu stages those writes, so the ring
needs no fences. A 3-frame ring of persistent buffers means warm frames
create nothing — the cost that matters most on wasm.
Uniforms bind once per block via a dynamic offset. Vertex data (stencil
fans, stroke strips) lands in a second family of blocks. All uploads go
through the alloc/flush seam so a mapped staging backend can replace
this implementation without touching call sites.
Implementations§
Source§impl HostBuffer
impl HostBuffer
Sourcepub fn new(device: &Device) -> Self
pub fn new(device: &Device) -> Self
new creates an empty host buffer for device.
Uniform stride is at least the per-draw record size and at least the
device’s min_uniform_buffer_offset_alignment.
Sourcepub fn bind_group_layout(&self) -> &BindGroupLayout
pub fn bind_group_layout(&self) -> &BindGroupLayout
bind_group_layout returns the group-0 layout for per-draw uniforms.
Binding 0 is a dynamic-offset uniform buffer. Pipeline layouts are built from this layout.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
begin_frame rotates to the next arena and resets its cursors.
Blocks are retained so warm frames never create buffers. Trailing unused blocks from a spike drain after a few idle ring passes so a recurring large mesh does not recreate them every frame.