pub struct Buffer { /* private fields */ }Expand description
A GPU buffer that can act on itself — built via
BufferBuilder, never constructed
directly. Carries its own device/queue access internally, so writing to
it doesn’t need a &wgpu::Queue threaded in from the caller.
Opaque by design: there’s no way to reach the underlying wgpu::Buffer
from outside this crate. Binding one into a bind group goes through
BindGroupBuilder, which accepts
&Buffer directly.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn write(&self, data: &[u8])
pub fn write(&self, data: &[u8])
Overwrites this buffer’s contents with data, starting at offset 0.
Sourcepub fn write_at(&self, offset: u64, data: &[u8])
pub fn write_at(&self, offset: u64, data: &[u8])
Writes data into this buffer at a byte offset — for updating one
element of a DynamicBuffer without touching the others. Prefer
DynamicBuffer::write_element, which computes the offset for you
from the buffer’s own stride.
Sourcepub fn read(&self) -> impl SpawnableFuture<Vec<u8>>
pub fn read(&self) -> impl SpawnableFuture<Vec<u8>>
Copies this buffer’s current contents back to the CPU. The copy itself is submitted eagerly, right away — do not call mid-frame; call after presenting or outside of frame encoding. Only the wait for the GPU to finish mapping it is deferred into the returned future.
This doesn’t run itself — drive it with
AsyncEventWriter::spawn to
get the result delivered as an event, or
BackgroundTasks::spawn_async
directly if you’d rather hold onto a
TaskHandle and poll it yourself.
Auto Trait Implementations§
impl !RefUnwindSafe for Buffer
impl !UnwindSafe for Buffer
impl Freeze for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
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> Component for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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