Builtin Library
- ..
- README.md1.1 KB
- bindings.yaml1.3 KB
- shader.wgsl1.2 KB
README.md
map
The per-element kernel: dst[id] = TEMPLATE over n elements. The template is
a WGSL expression over p (the element's position), id, the numbers u_get(k)
and the columns of the cols table; the preludes rand, noise and color
supply the functions a template calls. fieldc.mapSpec writes a chain of field
templates as one function, so a chain of any length is one dispatch.
Specialize T (f32, i32, vec2, vec3 or vec4 of f32), TEMPLATE, and optionally
PRELUDE and POSITION. Bind cols (a table from compute_abi.table) and u.
The output dst holds n elements of T, tightly packed.
local program = ref:program()
local variant = program:variant({ specialize = { T = "f32", TEMPLATE = "zero_rand(7u, id)",
PRELUDE = '#include "@builtin::systems.procgen.kernels.rand"' } })
local run = variant:run({ n = 64, inputs = { cols = emptyTable, u = numbers } })
fieldc.evaluate(field, domain) runs a Field through this kernel and answers the Column it wrote. Leaves of Int and UInt runs are read through cols_i32 and cols_u32, and a read past a run's end reads its last element.