diff options
| author | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 09:54:12 -0700 |
|---|---|---|
| committer | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 16:41:15 -0700 |
| commit | d2dbb0b69002e6e410119fd690da8d315ef51779 (patch) | |
| tree | 26bdffd9200bdaecbd36ffd3406bdaa9cd84c375 /docs | |
| parent | a8b6e471b2602f32a60565f015573342448593fc (diff) | |
tools: hello_pixels draws a synthetic quad through vk_harness
The package-free complement to first_light: hand-written SPIR-V
assembly (no GLSL compiler, spirv-as only), a generated VKH_DRAW_MESH
quad, RGBA32F readback to PPM and a zlib-only PNG, and a --check oracle
(coverage + 7 probe pixels against the pattern's closed form) exercised
by tests/test_hello_pixels.py without a GPU. Measured end to end on
Mesa llvmpipe 20.1.2 at 512x512.
Assisted-by: Devin
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/README.md | 1 | ||||
| -rw-r--r-- | docs/hello_pixels.md | 51 |
2 files changed, 52 insertions, 0 deletions
diff --git a/docs/README.md b/docs/README.md index 545f3ba37..a0c6ce3b2 100644 --- a/docs/README.md +++ b/docs/README.md | |||
| @@ -78,6 +78,7 @@ method, scope and caveats. No game data is included. | |||
| 78 | | [first_light.md](first_light.md) | The first draw of a real game model with its own translated VS/PS on a GPU: 4,213 vertices / 7,968 triangles, 78.1% coverage on an RTX 2060 SUPER; `tools/first_light.py`, the `vk_harness` mesh mode, and the same draw through the D3D12 layer (`d3d12_first_light`). | | 78 | | [first_light.md](first_light.md) | The first draw of a real game model with its own translated VS/PS on a GPU: 4,213 vertices / 7,968 triangles, 78.1% coverage on an RTX 2060 SUPER; `tools/first_light.py`, the `vk_harness` mesh mode, and the same draw through the D3D12 layer (`d3d12_first_light`). | |
| 79 | | [embedded_shaders.md](embedded_shaders.md) | DXBC containers embedded in the package's DLLs: 52 in `XboxBvhBuilder.dll` (console `FSSM` via the `XDAT`/`XBCH` record; 51/52 pass `spirv-val` today) and 29 `ACCC`/`FSPX` in the FidelityFX upscaler; the scan/extract tool and the one rule still missing. | | 79 | | [embedded_shaders.md](embedded_shaders.md) | DXBC containers embedded in the package's DLLs: 52 in `XboxBvhBuilder.dll` (console `FSSM` via the `XDAT`/`XBCH` record; 51/52 pass `spirv-val` today) and 29 `ACCC`/`FSPX` in the FidelityFX upscaler; the scan/extract tool and the one rule still missing. | |
| 80 | | [shader_inputs.md](shader_inputs.md) | Inputs that specific game shaders need to be right, as a first check for a black frame or a device-lost: the studio-shot lighting shader's 512-byte light records, eight-light loop, plane count at +0x4C (#1892 said +0x40), profile table and shadow-strength byte; the ACES LUT bakes' two tone-curve splines (reference order at +0x00, points-first at +0x70 behind the +0x118 switch), the +0x13C luminance mode and the quasi-log addressing (#1896); the sky LUT order and the +0xD0 dword that picks RGB9E5 or float outputs (#1897). | | 80 | | [shader_inputs.md](shader_inputs.md) | Inputs that specific game shaders need to be right, as a first check for a black frame or a device-lost: the studio-shot lighting shader's 512-byte light records, eight-light loop, plane count at +0x4C (#1892 said +0x40), profile table and shadow-strength byte; the ACES LUT bakes' two tone-curve splines (reference order at +0x00, points-first at +0x70 behind the +0x118 switch), the +0x13C luminance mode and the quasi-log addressing (#1896); the sky LUT order and the +0xD0 dword that picks RGB9E5 or float outputs (#1897). | |
| 81 | | [hello_pixels.md](hello_pixels.md) | The package-free sibling: a synthetic quad drawn through the same `vk_harness` mesh mode, shaders hand-written in SPIR-V assembly; `tools/hello_pixels.py` checks coverage and probe pixels against a closed form. | | ||
| 81 | | [coder.md](coder.md) | The compressed mass in `story000_script.rpf`: entry framing (`align16(entry+8)` payload), the 32-value tag alphabet, deflate-shaped but proprietary, variable-length 7/8-bit LSB-first codes with no stored table, and the `n7 = 116..127` search that finishes it. | | 82 | | [coder.md](coder.md) | The compressed mass in `story000_script.rpf`: entry framing (`align16(entry+8)` payload), the 32-value tag alphabet, deflate-shaped but proprietary, variable-length 7/8-bit LSB-first codes with no stored table, and the `n7 = 116..127` search that finishes it. | |
| 82 | | [mission_logic.md](mission_logic.md) | Mission state tables: 0x20 record layout (band counter, byte offsets), the 64-byte pool element with world transforms, case-folding joaat keys, 53.5 % of states named, 113 state-set clusters covering 82.4 % of files. | | 83 | | [mission_logic.md](mission_logic.md) | Mission state tables: 0x20 record layout (band counter, byte offsets), the 64-byte pool element with world transforms, case-folding joaat keys, 53.5 % of states named, 113 state-set clusters covering 82.4 % of files. | |
| 83 | | [gbuffer.md](gbuffer.md) | Deferred G-buffer targets (`PS_DeferredTextured` and all 2,989 `*Deferred*` pixel shaders, `PROC-146`): 5- and 6-target `OSG1`/`PSV0` signatures (`float32` + `exp ... compr` on all outputs), the 24-bit octahedral normal split across `mrt1.gba` (`2047.5` scale, `1/255` byte packing), sqrt-encoded `mrt2`, byte IDs in `mrt3.zw`, float motion in `mrt4`, and why binding `f16` targets mangles the normal bytes. | | 84 | | [gbuffer.md](gbuffer.md) | Deferred G-buffer targets (`PS_DeferredTextured` and all 2,989 `*Deferred*` pixel shaders, `PROC-146`): 5- and 6-target `OSG1`/`PSV0` signatures (`float32` + `exp ... compr` on all outputs), the 24-bit octahedral normal split across `mrt1.gba` (`2047.5` scale, `1/255` byte packing), sqrt-encoded `mrt2`, byte IDs in `mrt3.zw`, float motion in `mrt4`, and why binding `f16` targets mangles the normal bytes. | |
diff --git a/docs/hello_pixels.md b/docs/hello_pixels.md new file mode 100644 index 000000000..6c47a3e58 --- /dev/null +++ b/docs/hello_pixels.md | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | # Hello pixels: a package-free draw through vk_harness | ||
| 2 | |||
| 3 | **Status: measured** on Mesa llvmpipe (LLVM 20.1.2, Vulkan 1.3.275, Linux). This is a synthetic complement to | ||
| 4 | [first_light.md](first_light.md): where that page draws a real game model with real translated shaders, this one | ||
| 5 | draws a quad built entirely in the repository — hand-written SPIR-V assembly, a generated mesh — so anyone with | ||
| 6 | a Vulkan device can check the pipeline without the game package. | ||
| 7 | |||
| 8 | ## What it draws | ||
| 9 | |||
| 10 | `tools/hello_pixels.py --run --check` assembles two tiny shaders (no GLSL compiler needed, `spirv-as` only): | ||
| 11 | |||
| 12 | - **VS** (`vs.asm`): `Location 0` float3 position already in NDC, `Location 1` float2 uv; stores the position | ||
| 13 | into `gl_Position` and forwards uv to the interpolating varying. This is the same shape as the first_light VS. | ||
| 14 | - **PS** (`ps.asm`): `rgb = (u, v, (u+v)/2)` dimmed to 20% on every other cell of a 16×16 checker, computed with | ||
| 15 | core instructions only (`OpFMod` cell coordinate, `OpFOrdLessThan`/`OpSelect` parity). `OriginUpperLeft`. | ||
| 16 | |||
| 17 | The mesh is a generated fullscreen indexed quad (`u32` counts, `5f` vertices, `u32` indices — the | ||
| 18 | `VKH_DRAW_MESH` format with `VKH_VERTEX_LAYOUT=0:3f,1:2f`), drawn into the RGBA32F attachment, read back, and | ||
| 19 | written as `image.raw`, `image.ppm` and a zlib-only `image.png`. | ||
| 20 | |||
| 21 | ## What --check verifies | ||
| 22 | |||
| 23 | Same style as the first_light oracle, so the image has to be *right*, not just non-clear: | ||
| 24 | |||
| 25 | - the buffer is exactly `w*h*16` bytes of RGBA32F; | ||
| 26 | - coverage is 100% — a quad that misses the image fails, and so does an all-clear image; | ||
| 27 | - seven probe pixels match `expected_pixel`, the closed form of the same pattern (u, v, (u+v)/2 with cell | ||
| 28 | parity) computed at pixel centres, within 0.04. A flipped axis, a swapped u/v or a mirrored checker moves | ||
| 29 | probe values out of tolerance. | ||
| 30 | |||
| 31 | `tests/test_hello_pixels.py` runs the oracle on synthetic buffers without a GPU or vk_harness: the accepted | ||
| 32 | image, a truncated buffer, a wrong probe pixel and a coverage loss away from every probe. | ||
| 33 | |||
| 34 | ## Why it matters | ||
| 35 | |||
| 36 | first_light needs `shaders.rpf`, `data.rpf` and an OBJ export. This needs nothing but the built harness and | ||
| 37 | `spirv-as`, so it is the fastest way to tell a fresh machine "your Vulkan path prints pixels": vertex fetch → | ||
| 38 | interpolation → fragment → readback, exercised end to end. It also serves as the smallest reproducer for | ||
| 39 | VKH_DRAW_MESH bugs — the file format and layout string are spelled out in one generated mesh. | ||
| 40 | |||
| 41 | ## Reproduce it | ||
| 42 | |||
| 43 | ```sh | ||
| 44 | cmake -S runtime -B runtime/build -G Ninja | ||
| 45 | cmake --build runtime/build --target vk_harness | ||
| 46 | python -I tools/hello_pixels.py --work <dir> --size 512 --run --check | ||
| 47 | # <dir>/image.png: a u/v gradient dimmed on alternating 16x16 cells | ||
| 48 | ``` | ||
| 49 | |||
| 50 | On Windows the same command works against `runtime/build/windows/vk_harness.exe`; on a machine without | ||
| 51 | `spirv-as`, pass prebuilt `vs.spv`/`ps.spv` from `--emit-only` on a machine that has one. | ||