pub struct InstanceBuffer {
desc: InstanceStreamDesc,
buffer: Option<Buffer>,
capacity: u32,
staging: StagingBuffer,
}Expand description
A reused vertex buffer holding one frame’s packed instance records.
The buffer grows geometrically and is reused between frames, so a steady
scene allocates nothing. Bytes reach it through a StagingBuffer, the
same path the camera and frame globals take.
Fields§
§desc: InstanceStreamDescWhere the stream binds and how wide one record is.
buffer: Option<Buffer>The buffer holding the last upload, allocated on the first one.
capacity: u32How many records the buffer can hold.
staging: StagingBufferThe staging buffers the uploads pass through.
Implementations§
Source§impl InstanceBuffer
impl InstanceBuffer
Sourcepub fn new(desc: InstanceStreamDesc) -> Self
pub fn new(desc: InstanceStreamDesc) -> Self
Create an empty stream for desc, allocating no GPU buffer until the
first upload.
§Panics
If desc names a stride that is not a multiple of
[wgpu::VERTEX_ALIGNMENT], which a vertex-buffer layout cannot declare.
Sourcepub fn buffer(&self) -> Option<&Buffer>
pub fn buffer(&self) -> Option<&Buffer>
The buffer holding the last upload, or None before the first one.
Sourcepub fn upload(
&mut self,
device: &Device,
encoder: &mut CommandEncoder,
records: &[u8],
)
pub fn upload( &mut self, device: &Device, encoder: &mut CommandEncoder, records: &[u8], )
Upload records as this frame’s instance stream.
A stream with no stride uploads nothing, and so does an empty one: a family with no visible instances binds no buffer, exactly as one that declares no stream does.
§Panics
If records.len() is not a whole number of records.
Auto Trait Implementations§
impl !RefUnwindSafe for InstanceBuffer
impl !UnwindSafe for InstanceBuffer
impl Forget for InstanceBuffer
impl Freeze for InstanceBuffer
impl Send for InstanceBuffer
impl Sync for InstanceBuffer
impl Unpin for InstanceBuffer
impl UnsafeUnpin for InstanceBuffer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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