junkpile

31 — wgpu I/O Profile Router

A native wgpu + Tauri 2 teaching example for describing render and file-output routes as validated, hot-reloadable JSON profiles.

This example is built from two confirmed working Junkpile foundations:

It does not reuse the paused network-streaming implementation from Example 29.

What this example demonstrates

Architecture

config/io-profiles.json
        ↓ parse + validate
last-known-good profile registry
        ↓ arm one profile
native authoritative wgpu texture
        ├── GPU window preview
        └── optional mapped readback
                ↓ bounded queue
             FFmpeg file worker
                ↓
             MP4 or MOV

The control panel never sends arbitrary dimensions or codec settings to the renderer. It selects a profile ID. Rust resolves that ID against the validated profile registry and uses the stored settings.

Profile schema

{
  "id": "delivery-4k",
  "label": "Delivery · 4K H.264",
  "description": "Native 4K render and H.264 recording.",
  "frame": {
    "width": 3840,
    "height": 2160
  },
  "recording": {
    "enabled": true,
    "codec": "h264",
    "fps": 30,
    "workerDelayMs": 0
  }
}

Supported codecs:

h264
prores

Supported recording frame rates:

24
30
60

The renderer itself continues running at 60 Hz. The recording route captures at the profile’s configured output frame rate.

Built-in profiles

Prerequisites

Verify the tools before starting:

ffmpeg -version
ffprobe -version

Optional executable overrides:

export FFMPEG_PATH=/absolute/path/to/ffmpeg
export FFPROBE_PATH=/absolute/path/to/ffprobe

Run

cd 31-wgpu-io-profile-router
npm install
npm run dev

Two windows should open:

  1. HTML/CSS profile and telemetry controls
  2. Native wgpu renderer preview

Test sequence

1. Preview-only route

The default profile is Preview only · 1080p.

Confirm:

2. Arm and record 1080p

  1. Select Delivery · 1080p H.264
  2. Click Arm selected profile
  3. Confirm the armed badge and route graph update
  4. Click Start file route
  5. Record for about five seconds
  6. Click Stop and finalize
  7. Wait for Complete
  8. Play the verified MP4

3. Change profiles

Arm Delivery · 4K H.264 or Archive · 4K ProRes while idle.

The native authoritative texture and recording stage should reconfigure immediately. Profile changes are rejected while a recording is active or finalizing.

4. Verify hot reload

Open the config folder from the controls and edit:

config/io-profiles.json

Change a label or add a valid profile. Save the file. The generation and profile list should update without restarting.

Then deliberately make the JSON invalid. The UI should show the validation error while the previously valid profile registry remains usable.

Use Restore built-ins to recover the original file.

Output location

Recordings are written to:

./recordings/

Example filenames:

junkpile-31-h264-1920x1080-30fps-<timestamp>.mp4
junkpile-31-prores-3840x2160-30fps-<timestamp>.mov

Validation rules

Why this matters

A reusable I/O system should not require every application to hardcode its delivery settings. A small processor, recorder, feedback instrument, or routing utility should be able to load a known profile and expose the same predictable route contract.

This example proves a focused version of that model:

Configuration chooses the route, Rust validates it, the renderer prepares it, and each sink remains responsible for its own lifecycle and backpressure.

Future examples can extend the same profile format with NDI and platform-native shared-texture outputs after those individual sinks are independently verified.