Skip to main content

Buffer

Struct Buffer 

Source
pub struct Buffer { /* private fields */ }

Implementations§

Source§

impl Buffer

Source

pub unsafe fn as_hal<A: Api>( self: Arc<Self>, ) -> Option<impl Deref<Target = A::Buffer>>

§Safety
  • The raw buffer handle must not be manually destroyed
Source§

impl Buffer

Source

pub fn check_is_valid(&self) -> Result<(), InvalidResourceError>

Source

pub fn invalid(device: Arc<Device>, desc: &BufferDescriptor<'_>) -> Arc<Self> ⓘ

Source

pub fn resolve_vertex_or_index_binding_range( &self, offset: BufferAddress, size: Option<BufferAddress>, ) -> Result<Range<BufferAddress>, BindingError>

Resolve the binding range for a vertex or index buffer.

This function is for vertex and index buffer bindings, which WebGPU allows to have zero size. For storage and uniform buffer bindings, which must have non-zero size, use Buffer::binding.

Returns an error if the binding would overflow the buffer.

Source

pub fn binding<'a>( &'a self, offset: BufferAddress, binding_size: Option<BufferSize>, snatch_guard: &'a SnatchGuard<'_>, ) -> Result<BufferBinding<'a, dyn DynBuffer, BufferSize>, BindingError>

Create a new hal::BufferBinding for the buffer with offset and binding_size.

If binding_size is None, then the remainder of the buffer starting from offset is used.

Returns an error if the binding would overflow the buffer.

This function is for storage and uniform buffer bindings, which must have non-zero size. For vertex and index buffer bindings, which may have zero size, use Buffer::resolve_vertex_or_index_binding_range.

Source

pub fn map_async<M>( self: &Arc<Self>, mode: M, offset: BufferAddress, size: Option<BufferAddress>, callback: Option<BufferMapCallback>, ) -> Option<SubmissionIndex>

Schedule buffer mapping.

op.callback is guaranteed to be called, regardless of the outcome.

Source

pub fn get_mapped_range( self: &Arc<Self>, offset: BufferAddress, size: Option<BufferAddress>, ) -> Result<BufferMapping, BufferAccessError>

Get a guarded pointer to the mapped range of the buffer.

While returned BufferMapping is alive, Buffer::destroy and Buffer::unmap calls will block until BufferMapping is dropped.

Source

pub fn unmap(self: &Arc<Self>)

Source

pub fn destroy(self: &Arc<Self>)

Source

pub fn size(&self) -> BufferAddress

Source

pub fn usage(&self) -> BufferUsages

Trait Implementations§

Source§

impl Debug for Buffer

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Buffer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Labeled for Buffer

Source§

fn label(&self) -> &str

Returns a string identifying this resource for logging and errors. Read more
Source§

fn error_ident(&self) -> ResourceErrorIdent

Source§

impl ParentDevice for Buffer

Source§

fn device(&self) -> &Arc<Device> ⓘ

Source§

fn is_equal(self: &Arc<Self>, other: &Arc<Self>) -> bool

Source§

fn same_device_as<O: ParentDevice>(&self, other: &O) -> Result<(), DeviceError>

Source§

fn same_device(&self, device: &Device) -> Result<(), DeviceError>

Source§

impl RawResourceAccess for Buffer

Source§

type DynResource = dyn DynBuffer

Source§

fn raw<'a>( &'a self, guard: &'a SnatchGuard<'_>, ) -> Option<&'a Self::DynResource>

Get access to the raw resource if it is not destroyed. Read more
Source§

fn try_raw<'a>( &'a self, guard: &'a SnatchGuard<'_>, ) -> Result<&'a Self::DynResource, DestroyedResourceError>

Get access to the raw resource if it is not destroyed. Read more
Source§

impl ResourceType for Buffer

Source§

const TYPE: &'static str = "Buffer"

Auto Trait Implementations§

§

impl !Freeze for Buffer

§

impl !RefUnwindSafe for Buffer

§

impl !UnwindSafe for Buffer

§

impl Forget for Buffer

§

impl Move for Buffer

§

impl Send for Buffer
where BoxRaw<dyn DynBuffer>: Send, Arc<Device>: Send, InternalBitFlags: Send, InternalBitFlags: Send, RwLock<RawRwLock, InitTracker<u64>>: Send, InternalBitFlags: Send, RawVecInner: Send, Arc<SharedTrackerIndexAllocator>: Send, Arc<RwLock<BufferMapState>>: Send, Mutex<RawMutex, WeakVec<BindGroup>>: Send, BoxRaw<dyn DynBindGroup>: Send,

§

impl Sync for Buffer
where SnatchableInner<Option<Box<dyn DynBuffer>>>: Sync, Arc<Device>: Sync, InternalBitFlags: Sync, InternalBitFlags: Sync, RwLock<RawRwLock, InitTracker<u64>>: Sync, InternalBitFlags: Sync, RawVecInner: Sync, Arc<SharedTrackerIndexAllocator>: Sync, Arc<RwLock<BufferMapState>>: Sync, Mutex<RawMutex, WeakVec<BindGroup>>: Sync, SnatchableInner<Option<TimestampNormalizationBindGroup>>: Sync, SnatchableInner<Option<BindGroups>>: Sync,

§

impl Unpin for Buffer
where Box<dyn DynBuffer>: Unpin, Arc<Device>: Unpin, InternalBitFlags: Unpin, InternalBitFlags: Unpin, Align8<usize>: Unpin, *const Range<u64> is !null: Unpin, Range<u64>: Unpin, InternalBitFlags: Unpin, *const u8 is !null: Unpin, Arc<SharedTrackerIndexAllocator>: Unpin, Arc<RwLock<BufferMapState>>: Unpin, Align1<u8>: Unpin, *const ArcInner<BindGroup> is !null: Unpin, Box<dyn DynBindGroup>: Unpin,

§

impl UnsafeUnpin for Buffer
where *const dyn DynBuffer is !null: UnsafeUnpin, PhantomData<dyn DynBuffer>: UnsafeUnpin, *const ArcInner<Device> is !null: UnsafeUnpin, PhantomData<ArcInner<Device>>: UnsafeUnpin, InternalBitFlags: UnsafeUnpin, InternalBitFlags: UnsafeUnpin, Align8<usize>: UnsafeUnpin, *const Range<u64> is !null: UnsafeUnpin, PhantomData<Range<u64>>: UnsafeUnpin, InternalBitFlags: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<SharedTrackerIndexAllocator> is !null: UnsafeUnpin, PhantomData<ArcInner<SharedTrackerIndexAllocator>>: UnsafeUnpin, *const ArcInner<RwLock<BufferMapState>> is !null: UnsafeUnpin, PhantomData<ArcInner<RwLock<BufferMapState>>>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, PhantomData<Weak<BindGroup>>: UnsafeUnpin, *const dyn DynBindGroup is !null: UnsafeUnpin, PhantomData<dyn DynBindGroup>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,