[−][src]Struct web_glitz::buffer::Buffer
A GPU-accessible memory buffer that contains typed data.
Example
use web_glitz::buffer::{Buffer, UsageHint}; let buffer: Buffer<[f32]> = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw);
A buffer can be created with any data that implements IntoBuffer.
Implementations
impl<T> Buffer<T> where
T: ?Sized,
[src]
T: ?Sized,
pub fn usage_hint(&self) -> UsageHint
[src]
impl<T> Buffer<T> where
T: Copy,
[src]
T: Copy,
pub fn upload_command<D>(&self, data: D) -> UploadCommand<T, D> where
D: Borrow<T> + Send + Sync + 'static,
[src]
D: Borrow<T> + Send + Sync + 'static,
Returns a command which, when executed will replace the data contained in this Buffer with
the given data
.
pub fn download_command(&self) -> DownloadCommand<T>
[src]
impl<T> Buffer<MaybeUninit<T>>
[src]
pub unsafe fn assume_init(self) -> Buffer<T>
[src]
Converts to Buffer<T>
.
Safety
Any tasks that read from the buffer after assume_init
was called, must only be executed
after the buffer was initialized. Note that certain tasks may wait on GPU fences and allow
a runtime to progress other tasks while its waiting on the fence. As such, submitting your
initialization tasks as part of a task that includes fencing (these are typically tasks that
include "download" commands), may not guarantee that the buffer was initialized before any
tasks that are submitted later will begin executing.
impl<T> Buffer<[T]>
[src]
pub fn len(&self) -> usize
[src]
Returns the number of elements contained in this Buffer.
pub fn get<I>(&self, index: I) -> Option<BufferView<'_, I::Output>> where
I: BufferSliceIndex<T>,
[src]
I: BufferSliceIndex<T>,
Returns a BufferView on an element or a slice of the elements this Buffer, depending
on the type of index
.
- If given a position, returns a view on the element at that position or
None
if out of bounds. - If given a range, returns a view on the slice of elements corresponding to that range, or
None
if out of bounds.
Examples
use web_glitz::buffer::UsageHint; let buffer = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw); buffer.get(1); // Some BufferView<f32> containing `2.0` buffer.get(1..3); // Some BufferView<[f32]> containing `[2.0, 3.0]` buffer.get(..2); // Some BufferView<[f32]> containing `[1.0 2.0]` buffer.get(4); // None (index out of bounds)
pub unsafe fn get_unchecked<I>(&self, index: I) -> BufferView<'_, I::Output> where
I: BufferSliceIndex<T>,
[src]
I: BufferSliceIndex<T>,
Returns a BufferView on an element or a slice of the elements this Buffer, depending
on the type of index
, without doing bounds checking.
- If given a position, returns a view on the element at that position, without doing bounds checking.
- If given a range, returns a view on the slice of elements corresponding to that range, without doing bounds checking.
Examples
use web_glitz::buffer::UsageHint; let buffer = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw); unsafe { buffer.get_unchecked(1) }; // BufferView<f32> containing `2.0`
Unsafe
Only safe if index
is in bounds. See [get] for a safe alternative.
impl<T> Buffer<[T]> where
T: Copy,
[src]
T: Copy,
pub fn upload_command<D>(&self, data: D) -> UploadCommand<[T], D> where
D: Borrow<[T]> + Send + Sync + 'static,
[src]
D: Borrow<[T]> + Send + Sync + 'static,
Returns a command which, when executed will replace the elements contained in this Buffer
with the elements in given data
.
If the data
contains fewer elements than this Buffer, then only the first N
elements
will be replaced, where N
is the number of elements in the given data
.
If the data
contains more elements than this Buffer, then only the first M
elements
in the data
will be used to update this Buffer, where M
is the number of elements in
the Buffer.
pub fn download_command(&self) -> DownloadCommand<[T]>
[src]
impl<T> Buffer<[MaybeUninit<T>]>
[src]
pub unsafe fn assume_init(self) -> Buffer<[T]>
[src]
Converts to Buffer<[T]>
.
Safety
Any tasks that read from the buffer after assume_init
was called, must only be executed
after the buffer was initialized. Note that certain tasks may wait on GPU fences and allow
a runtime to progress other tasks while its waiting on the fence. As such, submitting your
initialization tasks as part of a task that includes fencing (these are typically tasks that
include "download" commands), may not guarantee that the buffer was initialized before any
tasks that are submitted later will begin executing.
Trait Implementations
impl<'a, T, const LEN: usize> From<&'a Buffer<[T; LEN]>> for BufferView<'a, [T]>
[src]
impl<'a, T> From<&'a Buffer<T>> for BufferView<'a, T> where
T: ?Sized,
[src]
T: ?Sized,
fn from(buffer: &'a Buffer<T>) -> BufferView<'a, T>
[src]
impl<'a, T, const LEN: usize> From<&'a mut Buffer<[T; LEN]>> for BufferView<'a, [T]>
[src]
impl<'a, T, const LEN: usize> From<&'a mut Buffer<[T; LEN]>> for BufferViewMut<'a, [T]>
[src]
impl<'a, T> From<&'a mut Buffer<T>> for BufferView<'a, T> where
T: ?Sized,
[src]
T: ?Sized,
fn from(buffer: &'a mut Buffer<T>) -> BufferView<'a, T>
[src]
impl<'a, T> From<&'a mut Buffer<T>> for BufferViewMut<'a, T> where
T: ?Sized,
[src]
T: ?Sized,
fn from(buffer: &'a mut Buffer<T>) -> BufferViewMut<'a, T>
[src]
impl<T> Hash for Buffer<T> where
T: ?Sized,
[src]
T: ?Sized,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> PartialEq<Buffer<T>> for Buffer<T> where
T: ?Sized,
[src]
T: ?Sized,
impl<'a, T> Resource for &'a Buffer<T> where
T: InterfaceBlock,
[src]
T: InterfaceBlock,
type Encoding = BufferView<'a, T>
const TYPE: ResourceSlotType
[src]
fn encode<E>(
self,
slot_index: u32,
encoder: BindGroupEncoder<'_, E>
) -> BindGroupEncoder<'_, (Self::Encoding, E)>
[src]
self,
slot_index: u32,
encoder: BindGroupEncoder<'_, E>
) -> BindGroupEncoder<'_, (Self::Encoding, E)>
impl<'a, T> TransformFeedbackBuffer for &'a mut Buffer<[T]>
[src]
fn encode(self, encoding: &mut TransformFeedbackBuffersEncoding<'_>)
[src]
impl<'a, T> TypedTransformFeedbackBuffer for &'a mut Buffer<[T]> where
T: TransformFeedback,
[src]
T: TransformFeedback,
type TransformFeedback = T
impl<T> TypedVertexBuffer for Buffer<[T]> where
T: Vertex,
[src]
T: Vertex,
type Vertex = T
impl<'a, T> TypedVertexBuffer for &'a Buffer<[T]> where
T: Vertex,
[src]
T: Vertex,
type Vertex = T
impl<'a, T> TypedVertexBuffer for &'a mut Buffer<[T]> where
T: Vertex,
[src]
T: Vertex,
type Vertex = T
impl<T> VertexBuffer for Buffer<[T]>
[src]
fn encode(self, encoding: &mut VertexBuffersEncoding<'_>)
[src]
impl<'a, T> VertexBuffer for &'a Buffer<[T]>
[src]
fn encode(self, encoding: &mut VertexBuffersEncoding<'_>)
[src]
impl<'a, T> VertexBuffer for &'a mut Buffer<[T]>
[src]
fn encode(self, encoding: &mut VertexBuffersEncoding<'_>)
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Buffer<T>
impl<T> !Send for Buffer<T>
impl<T> !Sync for Buffer<T>
impl<T: ?Sized> Unpin for Buffer<T>
impl<T> !UnwindSafe for Buffer<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static,
[src]
D: Borrow<T> + 'static,
T: Copy + 'static,
pub fn into_buffer<Rc>(Self, &Rc, BufferId, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static,
[src]
Rc: RenderingContext + Clone + 'static,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,