pub struct DynamicBuffer { /* private fields */ }
Expand description
A wgpu::Buffer
which dynamically grows based on the contents.
Implementations§
Source§impl DynamicBuffer
impl DynamicBuffer
Sourcepub fn new(device: &Device, descriptor: &BufferDescriptor<'_>) -> Self
pub fn new(device: &Device, descriptor: &BufferDescriptor<'_>) -> Self
Create a new empty buffer.
Sourcepub fn new_init(device: &Device, descriptor: &BufferInitDescriptor<'_>) -> Self
pub fn new_init(device: &Device, descriptor: &BufferInitDescriptor<'_>) -> Self
Create a new buffer with contents.
Sourcepub fn upload(&mut self, device: &Device, queue: &Queue, contents: &[u8])
pub fn upload(&mut self, device: &Device, queue: &Queue, contents: &[u8])
Uploads contents
and resizes the buffer if needed.
If contents
fits, uploads using wgpu::Queue
, otherwise reallocates and uploads using
wgpu::Device
.
Sourcepub fn try_upload(
&mut self,
queue: &Queue,
contents: &[u8],
) -> Result<(), BufferAddress>
pub fn try_upload( &mut self, queue: &Queue, contents: &[u8], ) -> Result<(), BufferAddress>
Uploades data
using wgpu::Queue
without resizing.
Fails if data
doesn’t fit in buffers and returns the size difference.
Sourcepub fn upload_by_init(&mut self, device: &Device, contents: &[u8])
pub fn upload_by_init(&mut self, device: &Device, contents: &[u8])
Allocates a new buffer, replaces the old one and uploades the contents using
wgpu::Device
.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DynamicBuffer
impl !RefUnwindSafe for DynamicBuffer
impl Send for DynamicBuffer
impl Sync for DynamicBuffer
impl Unpin for DynamicBuffer
impl !UnwindSafe for DynamicBuffer
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