pub struct Buffer { /* private fields */ }
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn resolve_binding_size(
&self,
offset: BufferAddress,
binding_size: Option<BufferSize>,
) -> Result<u64, BindingError>
pub fn resolve_binding_size( &self, offset: BufferAddress, binding_size: Option<BufferSize>, ) -> Result<u64, 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<BufferSize>,
snatch_guard: &'a SnatchGuard<'_>,
) -> Result<(BufferBinding<'a, dyn DynBuffer>, u64), BindingError>
pub fn binding<'a>( &'a self, offset: BufferAddress, binding_size: Option<BufferSize>, snatch_guard: &'a SnatchGuard<'_>, ) -> Result<(BufferBinding<'a, dyn DynBuffer>, u64), 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.
If the binding would overflow the buffer, then an error is returned.
A zero-size binding at the end of the buffer is permitted here for historical reasons. Although zero-size bindings are permitted by WebGPU, they are not permitted by some backends. The zero-size binding 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.
Although it seems like it would be simpler and safer to use the resolved
size in the returned hal::BufferBinding
, doing this (and removing
redundant logic in backends to resolve the implicit size) was observed
to cause problems in certain CTS tests, so an implicit size
specification is preserved in the output.