Last updated: 2026-06-12
Decode Planning
Graph
Shape-static ZINC_RT IR graph builder.
Graphs contain logical buffers and opcode nodes before any tier lowers them into packets, shaders, or pure Zig calls.
6 exports shown
constant
BufferId
pub const BufferId = u32 Dense index identifying a logical buffer inside a Graph.
Buffer ids are assigned sequentially by `Graph.addBuffer` starting at 0.
constant
NodeId
pub const NodeId = u32 Dense index identifying a node (opcode invocation) inside a Graph.
Node ids are assigned in insertion order by `Graph.addNode`.
constant
max_bindings
pub const max_bindings = 8 Maximum number of input or output buffers a single node may bind.
Picked to keep `BindingList` inline-storable without heap allocation.
struct
BindingList
pub const BindingList = struct Fixed-capacity list of buffer ids bound to one side of a node.
Stores up to `max_bindings` entries inline so a `Node` stays POD and trivially copyable through the planner.
struct
Node
pub const Node = struct Single opcode invocation in the graph.
Each node references its inputs and outputs by `BufferId`; the opcode itself decides the semantics of those bindings (see `op.Info`).
struct
Graph
pub const Graph = struct Shape-static ZINC_RT IR graph.
A graph is a flat list of opcode nodes plus a buffer count; lowering passes turn this representation into T-CPU packets, PM4 indirect buffers, or Metal/Vulkan dispatches without mutating the graph itself.
Methods
5method
Graph.init
pub fn init(allocator: std.mem.Allocator) Graph Create an empty graph backed by `allocator`.
tracked as a plain counter and require no per-buffer heap allocation.
method
Graph.deinit
pub fn deinit(self: *Graph) void Release the node array and poison the graph value.
method
Graph.addBuffer
pub fn addBuffer(self: *Graph) BufferId Reserve a new logical buffer and return its id.
method
Graph.addNode
pub fn addNode( self: *Graph, opcode: op.Opcode, inputs: []const BufferId, outputs: []const BufferId, ) !NodeId Append an opcode node with the given input and output bindings.
method
Graph.verify
pub fn verify(self: *const Graph) !void Structural sanity check: graph is non-empty, all bindings resolve, and every non-barrier/stream_out node produces at least one output.
`error.UnknownOutputBuffer`, or `error.NodeWithoutOutput` on failure.