Expand description
Vertex / uniform data layouts for the headless solid-fill + gradient pipelines.
All structs are #[repr(C)] and implement bytemuck::Pod /
bytemuck::Zeroable so they can be uploaded to the GPU as raw bytes with
a guaranteed, stable memory layout.
§Vertex layout (56 bytes = 14 × f32)
The struct was extended from the original 48-byte form to add an extra
field ([f32; 2]) that carries per-kind auxiliary parameters:
kind | local | shape_xy | shape_r | extra |
|---|---|---|---|---|
| 0 rect | pixel pos | – | – | – |
| 1 circle | pixel pos | centre (cx,cy) | radius | – |
| 2 rrect-uniform | pixel pos | centre (cx,cy) | radius | half-size (hw,hh) |
| 3 rrect-per-corner | pixel pos | centre (cx,cy) | pack16(tl,tr) | pack16(br,bl), pack16(hw,hh) |
| 4 ellipse | pixel pos | centre (cx,cy) | – | (rx, ry) |
| 5 line-seg | pixel pos | from (ax,ay) | half_width (+0.5=aa) | to (bx,by) |
For kind=3 the four corner radii and the half-extents are packed as u16
pairs into f32 bit patterns (see pack_u16_pair).
Structs§
- Globals
- Per-frame uniform block matching the WGSL
Globalsstruct. - Gradient
Uniforms - Per-gradient uniform block sent to
gradient.wgsl. - Gradient
Vertex - A single vertex fed to
gradient.wgsl. - Line
Quad Params - Parameters for a line-segment SDF quad.
- Vertex
- A single vertex fed to
solid.wgsl.
Constants§
- KIND_
CIRCLE - Primitive discriminator value for an SDF circle.
- KIND_
ELLIPSE - Primitive discriminator value for an SDF ellipse.
- KIND_
LINE_ SEG - Primitive discriminator value for a line-segment SDF.
- KIND_
RECT - Primitive discriminator value for a solid rectangle.
- KIND_
ROUNDED_ RECT - Primitive discriminator value for a uniformly-rounded rectangle (SDF).
- KIND_
ROUNDED_ RECT_ PC - Primitive discriminator value for a per-corner rounded rectangle (SDF).
- MAX_
GRADIENT_ STOPS - Maximum number of gradient colour stops supported in a single gradient draw.
Functions§
- pack_
u16_ pair - Pack two
u16values into the bit pattern of af32. - push_
circle_ quad - Append six vertices covering the bounding quad of the circle centred at
(cx, cy)withradius, tagged as an SDF circle. - push_
ellipse_ quad - Append six vertices for an SDF ellipse centred at
(cx, cy)with horizontal radiusrxand vertical radiusry. - push_
gradient_ quad - Append six gradient vertices covering
(x, y, w, h). - push_
line_ quad - Append six vertices for a line-segment SDF quad.
- push_
rect_ quad - Append six vertices (two triangles) covering the axis-aligned rectangle
(x, y, w, h)with a uniformcolor, tagged as a solid rectangle. - push_
rounded_ rect_ per_ corner_ quad - Append six vertices for a per-corner rounded rectangle (SDF).
- push_
rounded_ rect_ quad - Append six vertices for a uniformly-rounded rectangle (SDF).
- push_
triangle - Append three vertices (one triangle) for a path fill triangle.