Declarative WebGPU with S-expressions
This story details pngine, a declarative format and runtime for WebGPU, developed by the author over the past 2.5 years. The code provided is a simple red triangle created using S-expressions that match 1:1 with the WebGPU spec. The S-expressions are compiled into a binary representation and interpreted by a tiny runtime, which can be included in a PNG chunk alongside the preview image.
The author has released the code under CC0 license on GitHub, allowing for issues and discussions as well as releases from a self-hosted repo. The primary goal of pngine is to create a single file that describes all aspects of WebGPU pipelines, buffers, and passes, as well as shader modules and WGSL code, in a higher abstraction with no distractions.
The author emphasizes the usefulness of structured data representation for validation, replay, inspection, minification, serialization, and machine generation. The author also discusses the bundling of multiple WebGPU wirings in different contexts, where the WebGPU spec provides consistency and elegance while aiming to reduce the surface area for sharing WebGPU wirings.
The author compares the declarative space offered by pngine with the procedural environment of traditional WebGPU coding, highlighting the ease of describing concepts that can be moved around as needed. The author also mentions other tools like shadertoy and compute.toys, but stresses that pngine is a versatile substrate that helps users build on top of it, rather than offering a playground for experimentation.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.