pub struct Buffer { /* private fields */ }Implementations§
Source§impl Buffer
impl Buffer
pub fn check_is_valid(&self) -> Result<(), InvalidResourceError>
pub fn invalid(device: Arc<Device>, desc: &BufferDescriptor<'_>) -> Arc<Self> ⓘ
Sourcepub fn resolve_vertex_or_index_binding_range(
&self,
offset: BufferAddress,
size: Option<BufferAddress>,
) -> Result<Range<BufferAddress>, BindingError>
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.
Sourcepub fn binding<'a>(
&'a self,
offset: BufferAddress,
binding_size: Option<BufferSize>,
snatch_guard: &'a SnatchGuard<'_>,
) -> Result<BufferBinding<'a, dyn DynBuffer, BufferSize>, BindingError>
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.
Sourcepub fn map_async<M>(
self: &Arc<Self>,
mode: M,
offset: BufferAddress,
size: Option<BufferAddress>,
callback: Option<BufferMapCallback>,
) -> Option<SubmissionIndex>
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.
Sourcepub fn get_mapped_range(
self: &Arc<Self>,
offset: BufferAddress,
size: Option<BufferAddress>,
) -> Result<BufferMapping, BufferAccessError>
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.