Skip to content

Staged Computation

Status: stub

Full staging documentation is planned for Phase 2. Spec source: 06_STAGING.csl.

Staged computation allows you to write a single program that partially evaluates at compile time and completes at runtime. The key use case in Sigil: generating optimized shaders or kernels where some parameters are known at compile time.

// stage<T>: this value is known at compile time (stage 0)
// The compiler specializes the function for this specific value
fn make_blur_kernel(stage<radius: u32>) -> fn(Image) -> Image !gpu {
// radius is a compile-time constant — the loop is unrolled
|img| {
for dx in -radius..=radius {
for dy in -radius..=radius {
// ...
}
}
}
}
// Generates two distinct, fully-unrolled GPU kernels:
let blur3 = make_blur_kernel(3);
let blur7 = make_blur_kernel(7);

Full documentation in Phase 2.