Source code for simvx.graphics.draw2d_vertex

"""Shared vertex format for the 2D drawing system.

Defines the structured numpy dtype matching the ui.vert shader layout.
"""

import numpy as np

# Vertex format matching ui.vert: pos(vec2) + uv(vec2) + colour(vec4) = 32 bytes
UI_VERTEX_DTYPE = np.dtype(
    [
        ("position", np.float32, 2),
        ("uv", np.float32, 2),
        ("colour", np.float32, 4),
    ]
)

# Extended vertex for the bindless co-batched item path (design §3 D, P3b):
# the legacy 32-byte UI vertex plus a per-vertex bindless texture slot and a
# flags bitfield (bit0 = is_msdf). Carrying texture_id + is_msdf PER VERTEX is
# the per-instance ABI change that lets ONE draw mix different-texture sprites
# AND MSDF glyph runs (the headline label-on-sprite co-batch). Matches
# ui2d.vert's attribute layout. 40 bytes.
UI2D_VERTEX_DTYPE = np.dtype(
    [
        ("position", np.float32, 2),
        ("uv", np.float32, 2),
        ("colour", np.float32, 4),
        ("tex_id", np.int32),
        ("flags", np.uint32),
    ]
)