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.
impl GpuPrimitiveInstance
Packing, conversion, and compile-time ABI stride verification helpers for GpuPrimitiveInstance.
Sourcepub fn pack_rgba8_f32(rgba: [f32; 4]) -> u32
pub fn pack_rgba8_f32(rgba: [f32; 4]) -> u32
Sourcepub fn pack_color_rgba8(color: Color) -> u32
pub fn pack_color_rgba8(color: Color) -> u32
Sourcepub fn pack_u16_q4(value: f32) -> u16
pub fn pack_u16_q4(value: f32) -> u16
Sourcepub fn corner_radius_cap(rect: [f32; 4], kind: u32, shadow_pad: f32) -> f32
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.
Sourcepub fn f32_to_f16_bits(value: f32) -> u16
pub fn f32_to_f16_bits(value: f32) -> u16
Sourcepub fn pack_f16x2(lo: f32, hi: f32) -> u32
pub fn pack_f16x2(lo: f32, hi: f32) -> u32
Sourcepub const fn pack_kind_flags(
kind: PrimKind,
clip_mask_or_sub: u16,
tex_slot: u8,
layer_id: u8,
) -> u32
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 orVectorSubKind(bits[4..16]).u8- Bound texture slot index (bits[16..24]).u8- Owning retained layer identifier (bits[24..32]).
§Returns
u32- Packedkind_flagsbitfield.
Sourcepub fn prim_kind(&self) -> PrimKind
pub fn prim_kind(&self) -> PrimKind
Decodes the PrimKind variant stored in kind_flags bits [0..4].
§Returns
PrimKind- Decoded primitive variant.
Sourcepub fn clip_or_sub_kind(&self) -> u16
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.
Sourcepub fn texture_slot(&self) -> u8
pub fn texture_slot(&self) -> u8
Returns the texture slot index stored in kind_flags bits [16..24].
§Returns
u8- Bound texture slot.
Sourcepub fn layer_id(&self) -> u8
pub fn layer_id(&self) -> u8
Returns the retained layer identifier stored in kind_flags bits [24..32].
§Returns
u8- Owning layer identifier.
Sourcepub fn from_quad_instance(
quad: &GpuQuadInstance,
tex_slot: u8,
layer_id: u8,
) -> Self
pub fn from_quad_instance( quad: &GpuQuadInstance, tex_slot: u8, layer_id: u8, ) -> Self
Sourcepub fn external_surface(
bounds: Rect,
clip: Rect,
radii: [f32; 4],
uv_rect: [u16; 4],
tex_slot: u8,
layer_id: u8,
) -> Self
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.