pub struct TypedBuffer<T: Pod> { /* private fields */ }Expand description
A typed wrapper around wgpu::Buffer that tracks the element count so
callers never have to compute byte sizes manually.
T must implement bytemuck::Pod — the same bound used by
storage_buffer_init and read_back.
§Example
use oxiui_compute_wgpu::buffer::TypedBuffer;
// Construction, upload, and download are all in element counts.Implementations§
Source§impl<T: Pod> TypedBuffer<T>
impl<T: Pod> TypedBuffer<T>
Sourcepub fn new(
device: &Device,
label: &str,
usage: BufferUsages,
len: usize,
) -> Self
pub fn new( device: &Device, label: &str, usage: BufferUsages, len: usize, ) -> Self
Allocate an uninitialised GPU buffer for len elements with the given
usage flags.
Sourcepub fn from_data(device: &Device, label: &str, data: &[T]) -> Self
pub fn from_data(device: &Device, label: &str, data: &[T]) -> Self
Create a STORAGE | COPY_DST | COPY_SRC buffer pre-filled with data.
Sourcepub fn as_entire_binding(&self) -> BindingResource<'_>
pub fn as_entire_binding(&self) -> BindingResource<'_>
Return a wgpu::BindingResource covering the entire buffer, suitable
for passing to BindGroupEntry::resource.
Sourcepub fn inner(&self) -> &Buffer
pub fn inner(&self) -> &Buffer
Access the underlying wgpu::Buffer.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for TypedBuffer<T>
impl<T> !UnwindSafe for TypedBuffer<T>
impl<T> Freeze for TypedBuffer<T>
impl<T> Send for TypedBuffer<T>where
T: Send,
impl<T> Sync for TypedBuffer<T>where
T: Sync,
impl<T> Unpin for TypedBuffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for TypedBuffer<T>
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
Mutably borrows from an owned value. Read more