Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit90c9d5108d

README.md

fx

The fixed, data-driven device program set an effect play runs on. A graph reaches the device as data: a field expression is compiled to an op list (fx.ops.compileText), words that a fixed element interpreter (kernels/fx_eval) reads, so no program is built for a graph and a play never waits on a build.

The op compiler

fx.ops.compileText(text, retType) reads the let name: T = expr; lines and the return of a field function (or the whole function) and answers { ops, words, ret, lanes, slots, family, ... }, or { refusal } naming what the op set does not hold. fx.refusals() counts every refusal by its reason.

An op list is SSA over a scalar bank of registers (values of one lane, up to 32) and a vector bank (values of two to four lanes, up to 15), with the element's position in vector register 0. Pure ops that repeat are shared, ops no returned value reads are dropped, and the field operator templates (division, remainder, square root, gather index, unit hash) are one op each, except a remainder, which is a quotient, a product and a difference. fx.ops.table is the opcode table: each op's code, its family (core, rand, noise) and whether it is a scalar form. slot_get(k) reads word k of the dispatch.

The interpreter

fx.warm() registers the three families of kernels/fx_eval once; fx.ready() says when they are built and fx.awaitReady() waits. fx.dispatchEval(job) writes the job's row, column descriptors and op list into the owner's chunk of rows and queues the family's program over the pages the columns stand in; the dispatch names the runs it reaches and writes. fx.dispatchCount() counts the dispatches queued.

The backend

proc.substrate.withBackend("fx", fn), setOwnerBackend(owner, "fx") and backend() choose where work runs. Under "fx":

  • fieldc.evaluate and fieldc.runMap run a field chain on the interpreter (fx.map);
  • the element programs of proc.device that have a twin (fx.twins: fills, the index run, the word copy, an integer run read as numbers, the bounded gather) are never built, and queue their op list;
  • anything the fixed set does not hold runs the compiled program and is counted by fx.refusals().

proc.eval(graph, target, { backend = "fx" }) cooks under it.