pub struct Attribute {
pub buffer: BufferRef,
pub data: Option<Arc<Vec<u8>>>,
pub format: VertexFormat,
pub offset: u64,
pub count: u32,
pub stride: u64,
pub step_mode: VertexStepMode,
}Expand description
Attribute holds CPU-side data (Option<Arc<Vec<u8>>>) and metadata.
Fields§
§buffer: BufferRef§data: Option<Arc<Vec<u8>>>CPU-side data shared via Arc (supports interleaved buffers)
format: VertexFormat§offset: u64§count: u32§stride: u64§step_mode: VertexStepModeImplementations§
Source§impl Attribute
impl Attribute
Sourcepub fn new_planar<T>(data: &[T], format: VertexFormat) -> Attributewhere
T: Pod,
pub fn new_planar<T>(data: &[T], format: VertexFormat) -> Attributewhere
T: Pod,
Creates a Planar (non-interleaved) attribute
Sourcepub fn new_from_owned_bytes(
data: Vec<u8>,
format: VertexFormat,
stride: usize,
count: u32,
) -> Attribute
pub fn new_from_owned_bytes( data: Vec<u8>, format: VertexFormat, stride: usize, count: u32, ) -> Attribute
Creates a Planar attribute from pre-built raw bytes and a known stride.
Used by the quantised geometry pipeline where vertex data is already in its
final GPU-ready byte layout (e.g. Snorm16x4) and no further CPU-side
conversion is needed.
Sourcepub fn new_instanced<T>(data: &[T], format: VertexFormat) -> Attributewhere
T: Pod,
pub fn new_instanced<T>(data: &[T], format: VertexFormat) -> Attributewhere
T: Pod,
Creates an Instance attribute
Sourcepub fn new_interleaved(
buffer: BufferRef,
data: Option<Arc<Vec<u8>>>,
format: VertexFormat,
offset: u64,
count: u32,
stride: u64,
step_mode: VertexStepMode,
) -> Attribute
pub fn new_interleaved( buffer: BufferRef, data: Option<Arc<Vec<u8>>>, format: VertexFormat, offset: u64, count: u32, stride: u64, step_mode: VertexStepMode, ) -> Attribute
Creates an Interleaved attribute
Multiple Attributes can share the same BufferRef and data (Arc)
Sourcepub fn update_data<T>(&mut self, new_data: &[T])where
T: Pod,
pub fn update_data<T>(&mut self, new_data: &[T])where
T: Pod,
Updates data in-place (preserves ID, reuses GPU memory)
Uses Arc::make_mut to implement Copy-On-Write
Sourcepub fn update_region<T>(&mut self, offset_bytes: u64, new_data: &[T])where
T: Pod,
pub fn update_region<T>(&mut self, offset_bytes: u64, new_data: &[T])where
T: Pod,
Partially updates attribute data
pub fn read_vec3(&self, i: u32) -> Option<Vec3>
pub fn read_vec4(&self, i: u32) -> Option<Vec4>
pub fn read<T>(&self, i: u32) -> Option<T>where
T: Pod,
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Attribute
impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnsafeUnpin for Attribute
impl UnwindSafe for Attribute
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.