2026-11-13 · devlog

The renderer moved to Rust

In v2026.11.13, Rust recorded every GPU pass in the same WebAssembly module as the physics. How that renderer worked and how it performed at 1080p and 4K.

Update, November 24, 2026. Pinionfall now submits frames directly to WebGPU from TypeScript. See the v2026.11.24 release notes and gameplay measurements.

Until this release, Pinionfall’s renderer was TypeScript: a large frame orchestrator and a few hundred passes, each encoding its own WebGPU commands. In v2026.11.13 every one of those passes is recorded in Rust instead, through wgpu compiled to WebAssembly, in the same module that already held the Rapier and parry physics. TypeScript still runs the game. This post is about why, how it works, and what it changed, measured.

Why Rust

The honest reason is control and cost on the CPU side. A frame of this engine is a lot of small bookkeeping before any GPU work happens: draw lists for every shadow cascade, bind groups keyed by the resources they name, upload ranges, the streams of terrain, trees, rocks, structures and characters. In TypeScript each of those is an object, and each crossing into the browser’s WebGPU implementation is a call with its own validation. In Rust the same records are plain data in WASM memory, checked once, and they cross into JavaScript once a frame instead of once a record.

What Rust does not change is the GPU work itself. wgpu’s web backend issues the browser’s own WebGPU calls, so a pass that waits on the graphics card costs exactly what it cost before. Where the frame is the GPU’s (4K, the sea filling the screen), Rust can only reach parity on that pass; the gains there came from the passes themselves, many of them reworked in the same campaign.

How a frame is recorded now

TypeScript decides, Rust records. Each frame the game still culls, sorts, picks levels of detail and fills the uniform blocks in TypeScript. Then, pass by pass, it hands Rust words instead of objects:

The shaders moved too. The engine’s WGSL lives in one tree in the core, read by Rust with include_str! and by the game through a generated module, spliced by the same rules on both sides, so a file is the one text of its shader.

Pipelines that never hold a frame

The first version of the port froze the loading screen for up to twenty seconds. wgpu 30 created every pipeline synchronously, and Chrome compiles shaders on the GPU process thread that also presents every frame, so nothing reached the screen until the compile was done. We vendored wgpu with its asynchronous pipeline creation backported: every Rust pipeline is now created asynchronously and polled, a pass whose pipeline is still compiling answers “pending” and is simply not drawn that frame, and the reveal after the loading screen waits until nothing is compiling. A small gate keeps only a few compiles and shader modules in flight at once, so the compiles never starve the browser’s own drawing.

What it means for a licensee

If you extend the engine, most of your work is still TypeScript: game logic, culls, a new material’s choices. A new GPU pass is described rather than encoded: a compute pass hands its WGSL text, entry point and layouts to the engine’s program registry once, then a plan of groups and dispatches each frame, and needs no new Rust export. The engine counts any TypeScript GPU command that reaches a frame and names it under ?diag, because one would split the frame’s command buffer. Changing the Rust side itself (a pass’s recording, the physics, a shader) means the physics workspace and one build command that installs the module back into your checkout; ARCHITECTURE.md describes the layout and the gates.

The numbers

Measured against v2026.11.04, the TypeScript renderer, on the same machine: headless Chrome, uncapped, the same fixed places on both builds, two runs of each alternated, warm caches, saves reset. Frame times in milliseconds (lower is better), the mean and the 95th percentile.

1920x1080 HighRustTypeScript
a town market22.4 (24.6)23.3 (30.6)
a cliff19.9 (35.8)28.5 (63.0)
a ridge21.8 (40.1)33.2 (67.7)
a grove15.4 (30.8)23.8 (36.8)
out to sea26.3 (46.5)37.0 (72.4)
1,500 m up10.5 (17.3)13.8 (24.2)
on the moon5.8 (8.6)11.7 (21.1)

At 3840x2160 the Rust build’s mean is lower at every place we measured (the market 35.8 against 46.3, out to sea 66.1 against 86.8), and it reaches the playable world sooner (38 against 55 seconds in these runs).

Not every row improved. At 1080p a town market at night has more frames over 33 ms on the Rust build, because it is fast enough there to be limited by the graphics card and Chrome then alternates short and long frames; its mean is still a quarter lower. A fast low flight is about 1.5 ms slower at 1080p, which a first comparison puts on the new lighting and vegetation rather than on the renderer. The Low preset is slower at most places: it is limited by the CPU on most machines, and it is next on the list.

Most of the frame time above came off in the passes themselves (shadows, clouds, water, the material resolve), work the move to Rust made easier to see and change. The language alone does not make a GPU faster; owning every command of the frame made it possible to stop paying for the ones that were not needed.

← all posts