Struct DynamicBuffer

Source
pub struct DynamicBuffer { /* private fields */ }
Expand description

A wgpu::Buffer which dynamically grows based on the contents.

Implementations§

Source§

impl DynamicBuffer

Source

pub fn new(device: &Device, descriptor: &BufferDescriptor<'_>) -> Self

Create a new empty buffer.

Source

pub fn new_init(device: &Device, descriptor: &BufferInitDescriptor<'_>) -> Self

Create a new buffer with contents.

Source

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.

Source

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.

Source

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.

Source

pub fn raw(&self) -> &Buffer

Get a reference to the raw buffer.

Source

pub fn into_raw(self) -> Buffer

Convert into raw buffer.

Trait Implementations§

Source§

impl Debug for DynamicBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>