This fractal is computed on your GPU by a shader that the Kernelin compiler plugin generated from a plain Kotlin function. No hand-written GPU code.
You write the Kotlin. At build time, Kernelin translates it into the WGSL (switch tabs to compare), which this page runs with WebGPU. The same Kotlin function also runs on the JVM in unit tests.
loading...
The whole page logic that matters is Kotlin compiled to WebAssembly (100 KB):
mandelbrotView to WGSL and embeds it in place of kernelSource(::mandelbrotView). The Kotlin WebGPU host (kernelin-webgpu) compiles it, packs the parameters and runs it on your GPU.mandelbrotView function, compiled to Wasm, called once per pixel by KernelinCpu.dispatch.JavaScript only handles the buttons and paints the pixels. GPU timings include copying the result back from the GPU, but not drawing it. Source: Demo.kt.