Show HN: PNGine, Declarative WebGPU in S-expressions that match the spec 1:1

hugodan1 pts0 comments

PNGine | PNGineSkip to contentSearchCtrlKCancel

PNGine<br>Declarative WebGPU in S-expressions that match the spec 1:1.<br>Compile them to a few hundred bytes of bytecode, and play anywhere WebGPU runs.

Get startedSee Samples

A complete animated program, in SJON, the S-expression format PNGine reads:

(pass-graph

(pass :name main :code """

@fragment fn fs(@builtin(position) pos: vec4f) -> @location(0) vec4f {

let uv = pos.xy / vec2f(pngine.width, pngine.height);

return vec4f(uv, sin(pngine.time) * .5 + .5, 1);

"""))

@location(0) vec4f { let uv = pos.xy / vec2f(pngine.width, pngine.height); return vec4f(uv, sin(pngine.time) * .5 + .5, 1); } """))">

Terminal windowpngine art.sjon # → art.png: image, bytecode and runtime in one file

Write<br>Every WebGPU resource is a form, checked against a WebGPU schema: buffers,<br>textures, pipelines, passes, compute. Or skip all of that with the<br>seven-line sugar above.<br>SJON reference

Compile<br>One CLI: validate, compile, render, inspect, diff. A triangle is<br>631 bytes of bytecode; tucked into a PNG with its runtime, 4.6 KB.<br>CLI reference

Run<br>A functional browser API from 3 KB to 17 KB gzipped, or a standalone HTML<br>file of around 1 KB with no dependency at all.<br>JavaScript API

Inspect<br>Replay any compiled program against a mock GPU that records calls instead<br>of drawing: call traces, per-frame analysis, black-canvas diagnosis, no<br>browser needed.<br>Inspect a payload

pngine webgpu vec4f compile bytecode sjon

Related Articles