map.computeShader
- README.md1.5 KB
- bindings.yaml2.0 KB
- shader.wgsl1.7 KB
This package holds more than this page lists. See all of its files in its world.
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. Over a live count
n is the capacity and the first domain_count elements are the template's:
COUNT=device writes zero past them, and COUNT=live leaves the elements past
them as they stand.
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; given a live count
(live) it runs the COUNT=device variant over that count, and the COUNT=live variant when it is asked to keep the
elements past the count (rest = "keep"). 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.