pub struct Buffer {
pub(crate) raw: Snatchable<Box<dyn DynBuffer>>,
pub(crate) device: Arc<Device>,
pub(crate) usage: BufferUsages,
pub(crate) size: BufferAddress,
pub(crate) initialization_status: RwLock<InitTracker<BufferAddress>>,
pub(crate) label: String,
pub(crate) tracking_data: TrackingData,
pub(crate) map_state: Mutex<BufferMapState>,
pub(crate) bind_groups: Mutex<WeakVec<BindGroup>>,
pub(crate) timestamp_normalization_bind_group: Snatchable<TimestampNormalizationBindGroup>,
pub(crate) indirect_validation_bind_groups: Snatchable<BindGroups>,
}
Fields§
§raw: Snatchable<Box<dyn DynBuffer>>
§device: Arc<Device>
§usage: BufferUsages
§size: BufferAddress
§initialization_status: RwLock<InitTracker<BufferAddress>>
§label: String
The label
from the descriptor used to create the resource.
tracking_data: TrackingData
§map_state: Mutex<BufferMapState>
§bind_groups: Mutex<WeakVec<BindGroup>>
§timestamp_normalization_bind_group: Snatchable<TimestampNormalizationBindGroup>
§indirect_validation_bind_groups: Snatchable<BindGroups>
Implementations§
Source§impl Buffer
impl Buffer
pub(crate) fn raw<'a>( &'a self, guard: &'a SnatchGuard<'_>, ) -> Option<&'a dyn DynBuffer>
pub(crate) fn try_raw<'a>( &'a self, guard: &'a SnatchGuard<'_>, ) -> Result<&'a dyn DynBuffer, DestroyedResourceError>
pub(crate) fn check_destroyed( &self, guard: &SnatchGuard<'_>, ) -> Result<(), DestroyedResourceError>
Sourcepub(crate) fn check_usage(
&self,
expected: BufferUsages,
) -> Result<(), MissingBufferUsageError>
pub(crate) fn check_usage( &self, expected: BufferUsages, ) -> Result<(), MissingBufferUsageError>
Checks that the given buffer usage contains the required buffer usage, returns an error otherwise.
Sourcepub fn resolve_binding_size(
&self,
offset: BufferAddress,
binding_size: Option<BufferSizeOrZero>,
) -> Result<BufferSizeOrZero, BindingError>
pub fn resolve_binding_size( &self, offset: BufferAddress, binding_size: Option<BufferSizeOrZero>, ) -> Result<BufferSizeOrZero, BindingError>
Resolve the size of a binding for buffer with offset
and size
.
If size
is None
, then the remainder of the buffer starting from
offset
is used.
If the binding would overflow the buffer, then an error is returned.
Zero-size bindings are permitted here for historical reasons. Although
zero-size bindings are permitted by WebGPU, they are not permitted by
some backends. See Buffer::binding
and
#3170.
Sourcepub fn binding<'a>(
&'a self,
offset: BufferAddress,
binding_size: Option<BufferSizeOrZero>,
snatch_guard: &'a SnatchGuard<'_>,
) -> Result<BufferBinding<'a, dyn DynBuffer>, BindingError>
pub fn binding<'a>( &'a self, offset: BufferAddress, binding_size: Option<BufferSizeOrZero>, snatch_guard: &'a SnatchGuard<'_>, ) -> Result<BufferBinding<'a, dyn DynBuffer>, BindingError>
Create a new hal::BufferBinding
for the buffer with offset
and
size
.
If size
is None
, then the remainder of the buffer starting from
offset
is used.
If the binding would overflow the buffer, then an error is returned.
Zero-size bindings are permitted here for historical reasons. Although
zero-size bindings are permitted by WebGPU, they are not permitted by
some backends. Previous documentation for hal::BufferBinding
disallowed zero-size bindings, but this restriction was not honored
elsewhere in the code. Zero-size bindings need to be quashed or remapped
to a non-zero size, either universally in wgpu-core, or in specific
backends that do not support them. See
#3170.
Sourcepub(crate) fn map_async(
self: &Arc<Self>,
offset: BufferAddress,
size: Option<BufferAddress>,
op: BufferMapOperation,
) -> Result<SubmissionIndex, (BufferMapOperation, BufferAccessError)>
pub(crate) fn map_async( self: &Arc<Self>, offset: BufferAddress, size: Option<BufferAddress>, op: BufferMapOperation, ) -> Result<SubmissionIndex, (BufferMapOperation, BufferAccessError)>
Returns the mapping callback in case of error so that the callback can be fired outside of the locks that are held in this function.
Sourcepub(crate) fn map(
&self,
snatch_guard: &SnatchGuard<'_>,
) -> Option<BufferMapPendingClosure>
pub(crate) fn map( &self, snatch_guard: &SnatchGuard<'_>, ) -> Option<BufferMapPendingClosure>
This function returns None
only if Self::map_state
is not BufferMapState::Waiting
.