Skip to main content

GpuPrimitiveInstance

Struct GpuPrimitiveInstance 

Source
pub struct GpuPrimitiveInstance { /* private fields */ }
Expand description

Unified 64-byte #[repr(C)] instanced GPU draw primitive consumed identically across WGSL, MSL, GLSL ES 3.0, and HLSL uber-shaders.

Implementations§

Source§

impl GpuPrimitiveInstance

Packing, conversion, and compile-time ABI stride verification helpers for GpuPrimitiveInstance.

Source

pub fn pack_rgba8_f32(rgba: [f32; 4]) -> u32

Packs normalized [r, g, b, a] floating-point channels into little-endian RGBA8 u32.

§Arguments
  • [f32; 4] - Normalized RGBA channels in [0.0..=1.0].
§Returns
  • u32 - Packed RGBA8 color word (R in low byte, A in high byte).
Source

pub fn pack_color_rgba8(color: Color) -> u32

Packs a Color into little-endian RGBA8 u32.

§Arguments
  • Color - Source sRGB color with alpha.
§Returns
  • u32 - Packed RGBA8 color word.
Source

pub fn pack_u16_q4(value: f32) -> u16

Packs a non-negative physical pixel radius into Q12.4 unsigned fixed-point (1/16 px).

§Arguments
  • f32 - Physical pixel measurement (>= 0.0).
§Returns
  • u16 - Q12.4 quantized fixed-point value.
Source

pub fn corner_radius_cap(rect: [f32; 4], kind: u32, shadow_pad: f32) -> f32

Returns the geometric corner-radius ceiling (half the shortest side) for a quad so oversized full-pill radii (e.g. 999.0 logical px at high DPR) encode losslessly within Q12.4 range.

§Arguments
  • [f32; 4] - Physical quad rectangle [x, y, w, h] (shadow quads include blur padding).
  • u32 - Primitive kind discriminant (2 = shadow).
  • f32 - Shadow blur padding stored in the angle slot for shadow quads.
§Returns
  • f32 - Maximum meaningful corner radius in physical pixels.
Source

pub fn f32_to_f16_bits(value: f32) -> u16

Converts a finite f32 into IEEE-754 binary16 (f16) raw bit representation.

§Arguments
  • f32 - Single-precision floating-point value.
§Returns
  • u16 - IEEE-754 binary16 encoded bits.
Source

pub fn pack_f16x2(lo: f32, hi: f32) -> u32

Packs two f32 values into an IEEE-754 f16x2 u32 matching GPU unpack2x16float / half2.

§Arguments
  • f32 - Low-lane parameter (stroke_or_blur).
  • f32 - High-lane parameter (angle_or_pad).
§Returns
  • u32 - Packed f16x2 parameter word.
Source

pub const fn pack_kind_flags( kind: PrimKind, clip_mask_or_sub: u16, tex_slot: u8, layer_id: u8, ) -> u32

Encodes PrimKind, clip_mask_or_sub, tex_slot, and layer_id into kind_flags.

§Arguments
  • PrimKind - Unified 8-variant primitive discriminant (bits[0..4]).
  • u16 - Clip-mask identifier or VectorSubKind (bits[4..16]).
  • u8 - Bound texture slot index (bits[16..24]).
  • u8 - Owning retained layer identifier (bits[24..32]).
§Returns
  • u32 - Packed kind_flags bitfield.
Source

pub fn prim_kind(&self) -> PrimKind

Decodes the PrimKind variant stored in kind_flags bits [0..4].

§Returns
  • PrimKind - Decoded primitive variant.
Source

pub fn clip_or_sub_kind(&self) -> u16

Returns the clip_mask_id / VectorSubKind stored in kind_flags bits [4..16].

§Returns
  • u16 - Encoded clip-mask ID or vector sub-kind.
Source

pub fn texture_slot(&self) -> u8

Returns the texture slot index stored in kind_flags bits [16..24].

§Returns
  • u8 - Bound texture slot.
Source

pub fn layer_id(&self) -> u8

Returns the retained layer identifier stored in kind_flags bits [24..32].

§Returns
  • u8 - Owning layer identifier.
Source

pub fn from_quad_instance( quad: &GpuQuadInstance, tex_slot: u8, layer_id: u8, ) -> Self

Compiles a 64-byte GpuPrimitiveInstance from a legacy 96-byte GpuQuadInstance.

§Arguments
  • &GpuQuadInstance - Source quad descriptor.
  • u8 - Active texture slot index.
  • u8 - Active retained layer identifier.
§Returns
  • Self - Tightly packed 64-byte GPU primitive instance.
Source

pub fn external_surface( bounds: Rect, clip: Rect, radii: [f32; 4], uv_rect: [u16; 4], tex_slot: u8, layer_id: u8, ) -> Self

Constructs a 64-byte PrimKind::ExternalGpuSurface instance for shared-device 3D game or video textures.

§Arguments
  • Rect - Destination physical bounds.
  • Rect - Active physical scissor clip rectangle.
  • [f32; 4] - Per-corner physical clip radii [tl, tr, br, bl].
  • [u16; 4] - Normalized texture UV rectangle [u0, v0, u1, v1].
  • u8 - External GPU texture slot.
  • u8 - Retained layer identifier.
§Returns
  • Self - Packed 64-byte external GPU surface primitive instance.
Source§

impl GpuPrimitiveInstance

Source

pub fn get_rect(&self) -> [f32; 4]

Source

pub fn get_mut_rect(&mut self) -> &mut [f32; 4]

Source

pub fn set_rect(&mut self, val: [f32; 4]) -> &mut Self

Source

pub fn get_clip_rect(&self) -> [f32; 4]

Source

pub fn get_mut_clip_rect(&mut self) -> &mut [f32; 4]

Source

pub fn set_clip_rect(&mut self, val: [f32; 4]) -> &mut Self

Source

pub fn get_color_rgba(&self) -> u32

Source

pub fn get_mut_color_rgba(&mut self) -> &mut u32

Source

pub fn set_color_rgba(&mut self, val: u32) -> &mut Self

Source

pub fn get_aux_color_rgba(&self) -> u32

Source

pub fn get_mut_aux_color_rgba(&mut self) -> &mut u32

Source

pub fn set_aux_color_rgba(&mut self, val: u32) -> &mut Self

Source

pub fn get_uv_rect(&self) -> [u16; 4]

Source

pub fn get_mut_uv_rect(&mut self) -> &mut [u16; 4]

Source

pub fn set_uv_rect(&mut self, val: [u16; 4]) -> &mut Self

Source

pub fn get_radii_border(&self) -> [u16; 4]

Source

pub fn get_mut_radii_border(&mut self) -> &mut [u16; 4]

Source

pub fn set_radii_border(&mut self, val: [u16; 4]) -> &mut Self

Source

pub fn get_kind_flags(&self) -> u32

Source

pub fn get_mut_kind_flags(&mut self) -> &mut u32

Source

pub fn set_kind_flags(&mut self, val: u32) -> &mut Self

Source

pub fn get_extra_param(&self) -> u32

Source

pub fn get_mut_extra_param(&mut self) -> &mut u32

Source

pub fn set_extra_param(&mut self, val: u32) -> &mut Self

Trait Implementations§

Source§

impl Clone for GpuPrimitiveInstance

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for GpuPrimitiveInstance

Source§

impl Debug for GpuPrimitiveInstance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GpuPrimitiveInstance

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for GpuPrimitiveInstance

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GpuPrimitiveInstance

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.