
RPU is a GLSL compatible programming language for rendering procedural graphics on the CPU.
For more information visit rpu-lang.org.
Usage
To execute a function:
let fib = r#"
int fib(int n) {
if (n <= 1) return n;
return fib(n - 2) + fib(n - 1);
}
export int main(int x) {
return fib(x);
}"#;
let rpu = RPUnew;
let use_64_bit = true;
if let Ok = rpu.compile_and_run
If you only want to compile to WAT you can call:
let rc = compile_to_wat;
It returns a String containing the WAT source code.
To run the WAT source as a shader use
let mut buffer = new;
let rc = rpu.compile_wat_and_run_as_shader;
The color buffer will contain the shader output. This runs the shader in a single thread. To run the shader in parallel use:
let mut buffer = new;
let rc = rpu.compile_wat_and_run_as_tiled_shader;
Where (80, 80) is the tile size. The buffer is wrapped in an Arc<Mutex<>> to allow multiple threads to write to it. The '1' is the number of iterations to compute (in case the shader is a path tracer).