pub struct Buffer { /* private fields */ }
Expand description
Handle to a GPU-accessible buffer.
Created with Device::create_buffer
or
DeviceExt::create_buffer_init
.
Corresponds to WebGPU GPUBuffer
.
Implementations§
source§impl Buffer
impl Buffer
sourcepub fn as_entire_binding(&self) -> BindingResource<'_>
pub fn as_entire_binding(&self) -> BindingResource<'_>
Return the binding view of the entire buffer.
sourcepub fn as_entire_buffer_binding(&self) -> BufferBinding<'_>
pub fn as_entire_buffer_binding(&self) -> BufferBinding<'_>
Return the binding view of the entire buffer.
sourcepub fn slice<S: RangeBounds<BufferAddress>>(&self, bounds: S) -> BufferSlice<'_>
pub fn slice<S: RangeBounds<BufferAddress>>(&self, bounds: S) -> BufferSlice<'_>
Use only a portion of this Buffer for a given operation. Choosing a range with no end will use the rest of the buffer. Using a totally unbounded range will use the entire buffer.
sourcepub fn unmap(&self)
pub fn unmap(&self)
Flushes any pending write operations and unmaps the buffer from host memory.
sourcepub fn size(&self) -> BufferAddress
pub fn size(&self) -> BufferAddress
Returns the length of the buffer allocation in bytes.
This is always equal to the size
that was specified when creating the buffer.
sourcepub fn usage(&self) -> BufferUsages
pub fn usage(&self) -> BufferUsages
Returns the allowed usages for this Buffer
.
This is always equal to the usage
that was specified when creating the buffer.
source§impl Buffer
impl Buffer
sourcepub fn global_id(&self) -> Id<Buffer>
Available on crate feature expose-ids
only.
pub fn global_id(&self) -> Id<Buffer>
expose-ids
only.Returns a globally-unique identifier for this Buffer
.
Calling this method multiple times on the same object will always return the same value.
The returned value is guaranteed to be unique among all Buffer
s created from the same
Instance
.