AtlatestRepositorysigil-graphics
sigil-graphics / tree / test / test-shader-limitsREADME.md
1
# test-shader-limits3
The measured proof for the v0.11.3 shader additions, on native and on the4
`web` config: a Game of Life stepped entirely on the GPU (a step shader bound5
with `with-shader` inside `with-render-target`, ping-pong between two render6
targets), colours drawn from `vec4 palette[8]` and `float levels[4]` uniform7
arrays, and a 4x4 texture made from pixels and refilled with `update-texture`.8
`verify.mjs` reads the presented frame on each target and compares every cell9
against a CPU Life run of the same seed, every strip against the array entries,10
and every texel against the post-update pattern.12
## Native arm14
Builds against the sigil-graphics checkout two directories up (`dev-redirects.sgl`).15
The app needs an X display; use a worker-owned Xvfb, never a real session.17
```sh18
guix shell xorg-server -- Xvfb :91 -screen 0 1400x900x24 +extension GLX -nolisten tcp &19
guix shell -m ../../manifest.scm -- sh -c 'CPATH=$GUIX_ENVIRONMENT/include LIBRARY_PATH=$GUIX_ENVIRONMENT/lib sigil deps install --redirects dev-redirects.sgl && sigil build --redirects dev-redirects.sgl'20
DISPLAY=:91 guix shell -m ../../manifest.scm imagemagick xdotool -- sh -c 'LD_LIBRARY_PATH=$GUIX_ENVIRONMENT/lib node verify.mjs --native'21
```23
The verifier runs `build/dev/bin/test-shader-limits`, waits for its24
`shader-limits: ready` line, captures the window with `import -window`, and25
prints one `PASS`/`FAIL` line per sub-arm, then `GREEN`/`RED`; exit 1 on any26
FAIL, 2 when a wait ran out or the setup was wrong (`TIMED-OUT`, `SETUP-FAILED`).27
The capture lands at `/tmp/test-shader-limits-native.png`.29
## Web arm31
Needs `binaryen` (wasm-opt) for the build and `google-chrome` plus Node 22 for32
the verifier (headless Chrome with SwiftShader, driven over the DevTools33
Protocol, no puppeteer).35
```sh36
guix shell binaryen -- sigil build --redirects dev-redirects.sgl --config web37
node verify.mjs --web38
```40
Adds two sub-arms: `imports` (the wasm imports only `gl`, `sigil_wasm_gles3` and41
wasi) and `console` (no error entries). The page screenshot lands at42
`/tmp/test-shader-limits-web.png`.44
## Options46
- `--grid N`, `--steps N`: the field size (64) and the generations to run (8).47
- `--expect-steps N`: what the verifier models; different from `--steps` it must48
go RED (the assertion-layer control).49
- `--rule reaction --steps 4000 --substeps 8 [--grid 128]`: the Gray-Scott bonus:50
u and v packed into 16 bits each across the RGBA8 target (8 bits per quantity51
freezes the field), the step shader loaded with `'none` blending. The field52
sub-arm then checks that a pattern grew from the three seed squares rather than53
comparing cells (there is no closed form), and the screenshot shows it.54
- `--bench [--grid 512]`: run the app in bench mode and print its55
`frame-ms MEAN MAX tick-ms MEAN MAX` lines (wall time between frames, and the56
tick's own step+present CPU time), no verdict.57
- `--verbose` (web): dump the page console, including sokol's log lines.59
Running the app by hand: `test-shader-limits [--grid N] [--steps N] [--rule life|reaction]60
[--substeps N] [--bench]61
[--hold SECONDS]` natively; `index.html?grid=N&steps=N&rule=NAME&substeps=N&bench` on the web.63
## What it proves, and what it does not65
Every cell of the field is compared, so a wrong neighbour offset, a wrong wrap66
(the glider crosses both torus edges), a wrong `u_resolution` inside the pass,67
a filtered read, or a pass that silently draws nothing all read as a FAIL; the68
sabotage legs that showed each of those going red are in the task note69
`tasks/sigil-graphics-shader-limits`. Frame timing under Xvfb (llvmpipe) and70
SwiftShader is software rendering on both arms: it bounds the CPU-side cost of a71
step, not what a phone's GPU will do.73
## Wayland arm75
`verify-wl.mjs` is the native arm for a Wayland compositor the caller owns76
(a headless sway); it captures the window through `swaymsg` and `grim`77
instead of `xdotool` and `import`, and pins the window to the child's pid.79
```sh80
WAYLAND_DISPLAY=/run/user/$UID/<private>/wayland-1 SWAYSOCK=<its ipc socket> \81
guix shell -m ../../manifest.scm imagemagick grim jq -- \82
sh -c 'LD_LIBRARY_PATH=$GUIX_ENVIRONMENT/lib node verify-wl.mjs --native'83
```85
With sigil-desktop 0.10 the binary's NEEDED list is libm and libc only, so86
`guix shell --pure -m <sigil-desktop>/guix/run-wayland.scm -- build/dev/bin/test-shader-limits`87
runs it with no LD_LIBRARY_PATH at all (the runtime libraries resolve88
through sigil-desktop's dlopen fallback).