[−][src]Struct web_glitz::buffer::BufferView
A view on a segment or the whole of a Buffer.
Implementations
impl<'a, T> BufferView<'a, T> where
T: ?Sized,
[src]
T: ?Sized,
pub fn usage_hint(&self) -> UsageHint
[src]
Returns the UsageHint that was specified for the Buffer view by this BufferView when it was created.
See UsageHint for details.
impl<'a, T> BufferView<'a, T>
[src]
pub fn size_in_bytes(&self) -> usize
[src]
The size in bytes of the viewed buffer region.
impl<'a, T> BufferView<'a, 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 viewed by this BufferView
with the given data
.
This will modify the viewed Buffer, the buffer (and any other views on the same data) will be affected by this change.
pub fn download_command(&self) -> DownloadCommand<T>
[src]
Returns a command which, when executed will copy the data viewed by in this BufferView into a Box.
When the task is finished, the Box containing the copied data will be output.
impl<'a, T> BufferView<'a, MaybeUninit<T>>
[src]
pub unsafe fn assume_init(self) -> BufferView<'a, T>
[src]
Converts to BufferView<T>
.
Safety
Its up to the user to guarantee that any tasks that read buffer region viewed by this view, is only executed after the viewed region is 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<'a, T> BufferView<'a, [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: BufferViewSliceIndex<T>,
[src]
I: BufferViewSliceIndex<T>,
Returns a BufferView on an element or a sub-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 sub-slice of elements corresponding to that range,
or
None
if out of bounds.
Examples
use web_glitz::buffer::{Buffer, BufferView, UsageHint}; let buffer: Buffer<[f32]> = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw); let view = BufferView::from(&buffer); view.get(1); // Some BufferView<f32> containing `2.0` view.get(1..3); // Some BufferView<[f32]> containing `[2.0, 3.0]` view.get(..2); // Some BufferView<[f32]> containing `[1.0 2.0]` view.get(4); // None (index out of bounds)
pub unsafe fn get_unchecked<I>(&self, index: I) -> BufferView<'_, I::Output> where
I: BufferViewSliceIndex<T>,
[src]
I: BufferViewSliceIndex<T>,
Returns a BufferView on an element or a sub-slice of the elements this BufferView,
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::{Buffer, BufferView, UsageHint}; let buffer: Buffer<[f32]> = context.create_buffer([1.0, 2.0, 3.0, 4.0], UsageHint::StreamDraw); let view = BufferView::from(&buffer); unsafe { view.get_unchecked(1) }; // BufferView<f32> containing `2.0`
Unsafe
Only safe if index
is in bounds. See [get] for a safe alternative.
impl<'a, T> BufferView<'a, [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 viewed by this BufferView
with the elements in given data
.
If the data
contains fewer elements than the slice viewed by this BufferView, 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 the slice viewed by 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 slice viewed by the BufferView.
This will modify the viewed Buffer, the buffer (and any other views on the same data) will be affected by this change.
pub fn download_command(&self) -> DownloadCommand<[T]>
[src]
Returns a command which, when executed will copy the elements viewed by in this BufferView into a Box.
When the task is finished, the Box containing the copied elements will be output.
impl<'a, T> BufferView<'a, [MaybeUninit<T>]>
[src]
pub unsafe fn assume_init(self) -> BufferView<'a, [T]>
[src]
Converts to BufferView<[T]>
.
Safety
Its up to the user to guarantee that any tasks that read buffer region viewed by this view, is only executed after the viewed region is 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> Clone for BufferView<'a, T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T> Clone for BufferView<'a, [T]>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T> Copy for BufferView<'a, T>
[src]
impl<'a, T> Copy for BufferView<'a, [T]>
[src]
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> 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> Hash for BufferView<'a, T> where
T: Hash + ?Sized,
[src]
T: Hash + ?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<'a, T> PartialEq<BufferView<'a, T>> for BufferView<'a, T> where
T: PartialEq + ?Sized,
[src]
T: PartialEq + ?Sized,
fn eq(&self, other: &BufferView<'a, T>) -> bool
[src]
fn ne(&self, other: &BufferView<'a, T>) -> bool
[src]
impl<'a, T> Resource for BufferView<'a, T> where
T: InterfaceBlock,
[src]
T: InterfaceBlock,
type Encoding = Self
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> StructuralPartialEq for BufferView<'a, T> where
T: ?Sized,
[src]
T: ?Sized,
impl<'a, T> TypedVertexBuffer for BufferView<'a, [T]> where
T: Vertex,
[src]
T: Vertex,
type Vertex = T
impl<'a, 'b, T> TypedVertexBuffer for &'a BufferView<'b, [T]> where
T: Vertex,
[src]
T: Vertex,
type Vertex = T
impl<'a, 'b, T> TypedVertexBuffer for &'a mut BufferView<'b, [T]> where
T: Vertex,
[src]
T: Vertex,
type Vertex = T
impl<'a, T> VertexBuffer for BufferView<'a, [T]>
[src]
fn encode(self, encoding: &mut VertexBuffersEncoding<'_>)
[src]
impl<'a, 'b, T> VertexBuffer for &'a BufferView<'b, [T]>
[src]
fn encode(self, encoding: &mut VertexBuffersEncoding<'_>)
[src]
impl<'a, 'b, T> VertexBuffer for &'a mut BufferView<'b, [T]>
[src]
fn encode(self, encoding: &mut VertexBuffersEncoding<'_>)
[src]
Auto Trait Implementations
impl<'a, T> !RefUnwindSafe for BufferView<'a, T>
impl<'a, T> !Send for BufferView<'a, T>
impl<'a, T> !Sync for BufferView<'a, T>
impl<'a, T: ?Sized> Unpin for BufferView<'a, T>
impl<'a, T> !UnwindSafe for BufferView<'a, 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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,