pub struct Buffer { /* private fields */ }Expand description
Represents a GPU buffer.
Implementations§
Source§impl Buffer
impl Buffer
pub fn usage(&self) -> BufferUsage
pub fn size(&self) -> u64
Sourcepub fn resize(&mut self, size: u64) -> Result<(), BufferError>
pub fn resize(&mut self, size: u64) -> Result<(), BufferError>
Resizes the buffer to the specified size.
Due to the nature of GPU buffers, this will create a new buffer and copy the existing data into it IF: \
- The old buffer has usage [BufferUsages::COPY_SRC] and [BufferUsages::MAP_READ].
Otherwise, it will simply resize the buffer without copying the data.
Sourcepub fn write_cmd(&self, src: &Buffer, encoder: &mut CommandBuffer)
pub fn write_cmd(&self, src: &Buffer, encoder: &mut CommandBuffer)
Writes the contents of the source buffer to this buffer using a command buffer.
This function is useful for when you want to write to the buffer in a command buffer context, such as during a render pass.
CommandBuffer::write_buffer is a more convenient way to write a buffer in a command buffer context.
Sourcepub fn write_raw<T: Pod + Zeroable>(&self, data: &[T])
pub fn write_raw<T: Pod + Zeroable>(&self, data: &[T])
Writes raw data to the buffer.
By default, this will create an intermediate buffer to copy the data into, and then write that buffer to the destination buffer. This function also will automatically pad the data to the required alignment if necessary.
Will panic if the buffer is not writable or if the data is larger than the buffer size.
Sourcepub fn write_raw_cmd<T: Pod + Zeroable>(
&self,
data: &[T],
encoder: &mut CommandBuffer,
)
pub fn write_raw_cmd<T: Pod + Zeroable>( &self, data: &[T], encoder: &mut CommandBuffer, )
Writes raw data to the buffer using a command buffer, useful for writing data during a render pass.
This function is useful for when you want to write to the buffer in a command buffer context, such as during a render pass. This function also will automatically pad the data to the required alignment if necessary.
CommandBuffer::write_buffer_raw is a more convenient way to write raw data to a buffer in a command buffer context.
Will panic if the buffer is not writable or if the data is larger than the buffer size.
Sourcepub fn read<T: Pod + Zeroable>(&self) -> Result<Vec<T>, BufferError>
pub fn read<T: Pod + Zeroable>(&self) -> Result<Vec<T>, BufferError>
Reads the buffer data into a vector of type T.
Unless if the buffer was created with [BufferUsages::COPY_SRC] or [BufferUsages::MAP_READ], this will create an intermediate buffer to copy the data into, and then read from that buffer.
pub fn map(&mut self, mode: BufferMapMode) -> Result<&mut Vec<u8>, BufferError>
pub fn unmap(&mut self)
Trait Implementations§
impl Eq for Buffer
impl StructuralPartialEq for Buffer
Auto Trait Implementations§
impl Freeze for Buffer
impl !RefUnwindSafe for Buffer
impl !Send for Buffer
impl !Sync for Buffer
impl Unpin for Buffer
impl !UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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