simvx.graphics.draw2d_ops

Ordered op record for Draw2D.

Every Draw2D submission (fill, line, text, textured quad) appends a single Op to Draw2D._ops. Draw2DPass walks that list in order and coalesces adjacent same-(kind, clip, tex_id) ops into one GPU draw, so submission order is the GPU order. This is the canonical 2D ordering contract; there is no other mechanism.

Verts are stored as raw 8-float tuples (x, y, u, v, r, g, b, a) and indices as raw int lists; the pass concatenates per-run and builds the structured numpy buffer once at upload time. Carrying numpy arrays on every op was hot in the bullet-hell HUD workload (1000+ rects/frame).

Each op carries a blend mode ("alpha" default, "add", or "multiply"); the pass splits coalesced runs on a blend change exactly as it splits on a pipeline-kind change, so FILL/TEX runs pick the matching blend-state pipeline. LINE and TEXT are always alpha-blended.

The reserved material_id field is not used today: it marks where per-call ShaderMaterial extensions land without re-shaping callers.

post_layer_id tags an op with the band of a per-post CanvasLayer (CanvasLayer.environment set) it was emitted under, mirroring the desktop item pipeline’s layer column for the WEB backend (which renders via Op, not the item pipeline). It defaults to -1 (no post layer): the desktop path ignores the field entirely (it bands via the item layer column), and the web serializer only peels tagged ops when at least one carries a >= 0 value, so the field is purely additive and the unused wire stays byte-identical.

item_id carries the retained item pipeline’s stable cross-frame identity (id(node) ^ (seq << 1), the :class:ItemList item_id column) for the WEB per-sub-batch delta wire (P4b): the serializer folds the item_ids of the ops a sub-batch co-batches into a stable wire id and ships only the geometry of sub-batches whose items changed this frame. It defaults to -1 (no retained identity): the immediate producer and the desktop path leave it unset, so the serializer falls back to a per-frame ordinal id (a full keyframe) and the unused wire is delta-free.

Module Contents

Classes

Data

API

simvx.graphics.draw2d_ops.__all__

[‘OpKind’, ‘Op’]

class simvx.graphics.draw2d_ops.OpKind[source]

Bases: enum.IntEnum

FILL

0

LINE

1

TEXT

2

TEX

3

__abs__()
__add__()
__and__()
__bool__()
__ceil__()
__delattr__()
__dir__()
__divmod__()
__eq__()
__float__()
__floor__()
__floordiv__()
__format__()
__ge__()
__getattribute__()
__getnewargs__()
__getstate__()
__gt__()
__hash__()
__index__()
__int__()
__invert__()
__le__()
__lshift__()
__lt__()
__mod__()
__mul__()
__ne__()
__neg__()
__new__()
__or__()
__pos__()
__pow__()
__radd__()
__rand__()
__rdivmod__()
__reduce__()
__reduce_ex__()
__repr__()
__rfloordiv__()
__rlshift__()
__rmod__()
__rmul__()
__ror__()
__round__()
__rpow__()
__rrshift__()
__rshift__()
__rsub__()
__rtruediv__()
__rxor__()
__setattr__()
__sizeof__()
__str__()
__sub__()
__subclasshook__()
__truediv__()
__trunc__()
__xor__()
as_integer_ratio()
bit_count()
bit_length()
conjugate()
class denominator
class imag
is_integer()
class numerator
class real
to_bytes()
__deepcopy__(memo)
__copy__()
name()
value()
simvx.graphics.draw2d_ops.BLEND_MODES

(‘alpha’, ‘add’, ‘multiply’)

class simvx.graphics.draw2d_ops.Op[source]

Bases: typing.NamedTuple

kind: simvx.graphics.draw2d_ops.OpKind

None

clip: tuple[int, int, int, int] | None

None

verts: list[tuple]

None

indices: list[int] | None

None

tex_id: int

None

blend: str

‘alpha’

screen_space: bool

False

post_layer_id: int

None

item_id: int

None