Skip to main content

Module codegen

Module codegen 

Source
Expand description

Slang code generation for fused kernels.

A kernel is generated from a small expression tree (SpecNodes). Each node calls its op function from shaders/lib.slang; warps change the context their input is evaluated in, so a shape under a transform is evaluated analytically at the transformed position instead of being rasterized and resampled.

Param offsets are baked into the code and depend only on structure, so a param edit never changes the code and never triggers a compile.

Modules§

feedback_params
Param layout of a feedback step kernel (after the 4-float header, whose [1] is the state texel size in frame px).

Structs§

Generated
RunLayer
RunLayout
A run of layers as the packer writes it each frame: the blocks of the layers showing then ([kind][composite params][guard rect][layer], stride floats each), after everything else in the params.
SpecNode

Enums§

Child
LayerRef
Slot
What fills a kernel’s params after the 4-float header, in order.

Constants§

ENTRY
Name every generated kernel entry point is emitted with. The compiler renames it to a unique symbol per kernel key.
LIBRARY
Op library prepended to every generated module.

Functions§

entry_name
Renames the generated entry point to a unique symbol.
feedback
Kernel for one step of a feedback node: update(pos, px) from the agent’s code, with the previous state (T0) and up to four placed inputs (T1..T4), and the code’s constant tables after the params when it has them. Returns (key, body).
generate
Generates the kernel for spec, rooted at node root.
module
Assembles a compile unit: the op library plus each kernel body with its entry point and module-level names made unique.
single_op
Generates the standalone single-op kernel for def (tier 0): all inputs are textures. Returns None for ops without one (blur, custom shaders).