%% how one DispatchGraph runs on Metal (no GPU work graphs there), with the scheduler ported from vkd3d-proton. flowchart TD A["CreateStateObject
(EXECUTABLE, WORK_GRAPH)"] --> B["Program build on the CPU:
sort nodes by ID and array index,
place each on every level it can run at,
unroll recursion"] B --> C["Each node translated once
DXIL → SPIR-V → MSL;
up to 4 Metal pipelines via
function constants"] D["DispatchGraph
(CPU or GPU records)"] --> E["Level 0: dispatch the entry
node on the uploaded records"] C --> E E --> F["Nodes write records to a payload
ring and count them per node
(atomics in the backing memory)"] F --> G["wg_distribute: counts →
threadgroups per node"] G --> H["wg_offsets: each record's
payload offset, grouped by node"] H --> I["Level n: one indirect
dispatch per node,
reading the other ring"] I --> J{"more levels?"} J -- "yes: swap the rings" --> F J -- no --> K["Done: 3 dispatches
and barriers per level"]