pub struct Buffer {
pub size: u64,
/* private fields */
}
Expand description
- Probably best used as
RefCell<Buffer>
Fields§
§size: u64
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn bind_uniform(&self) -> Binding<'_>
pub fn bind_uniform(&self) -> Binding<'_>
Create a uniform buffer binding.
Example GLSL syntax:
layout(std140, binding = 0)
uniform Globals {
vec2 aUniform;
vec2 anotherUniform;
};
Sourcepub fn bind_storage(&self) -> Binding<'_>
pub fn bind_storage(&self) -> Binding<'_>
Create a storage buffer binding.
Example GLSL syntax:
layout (set=0, binding=0) buffer myStorageBuffer {
vec4 myElement[];
};
Sourcepub fn bind_storage_readonly(&self) -> Binding<'_>
pub fn bind_storage_readonly(&self) -> Binding<'_>
Create a storage buffer binding. The buffer is read-only in shader,
and it must be annotated with readonly
.
Example GLSL syntax:
layout (set=0, binding=0) readonly buffer myStorageBuffer {
vec4 myElement[];
};
Source§impl Buffer
impl Buffer
Sourcepub fn download_immediately(&self) -> Result<DownloadBuffer, BufferAsyncError>
pub fn download_immediately(&self) -> Result<DownloadBuffer, BufferAsyncError>
§Errors
Errors according to wgpu::BufferAsyncError
pub fn size(&self) -> usize
pub fn write<T>(&mut self, data: &[T])where
T: Pod,
Sourcepub fn write_at<T>(&mut self, offset: u64, data: &[T])where
T: Pod,
pub fn write_at<T>(&mut self, offset: u64, data: &[T])where
T: Pod,
Writes to the buffer at the given byte offset
Sourcepub fn write_index<T>(&mut self, index: u64, data: &[T])where
T: Pod,
pub fn write_index<T>(&mut self, index: u64, data: &[T])where
T: Pod,
Convenince function for writing at an index of the buffer (multiple of the data size)
pub fn write_unchecked<T>(&self, data: &[T])where
T: Pod,
Sourcepub fn write_at_unchecked<T>(&mut self, offset: u64, data: &[T])where
T: Pod,
pub fn write_at_unchecked<T>(&mut self, offset: u64, data: &[T])where
T: Pod,
Writes to the buffer at the given byte offset
Sourcepub fn write_index_unchecked<T>(&mut self, index: u64, data: &[T])where
T: Pod,
pub fn write_index_unchecked<T>(&mut self, index: u64, data: &[T])where
T: Pod,
Convenince function for writing at an index of the buffer (multiple of the data size)
pub fn resize(&mut self, size: u64)
pub fn copy_to(&self, encoder: &mut CommandEncoder, target: &Buffer)
Methods from Deref<Target = Buffer>§
Sourcepub fn as_entire_binding(&self) -> BindingResource<'_>
pub fn as_entire_binding(&self) -> BindingResource<'_>
Return the binding view of the entire buffer.
Sourcepub fn as_entire_buffer_binding(&self) -> BufferBinding<'_>
pub fn as_entire_buffer_binding(&self) -> BufferBinding<'_>
Return the binding view of the entire buffer.
Sourcepub fn slice<S>(&self, bounds: S) -> BufferSlice<'_>where
S: RangeBounds<u64>,
pub fn slice<S>(&self, bounds: S) -> BufferSlice<'_>where
S: RangeBounds<u64>,
Use only a portion of this Buffer for a given operation. Choosing a range with no end will use the rest of the buffer. Using a totally unbounded range will use the entire buffer.