SSX 3 Vulkan renderer

Replaces the software rasteriser (nv2a_pb_exec.c) on Linux. Code: src/vk/. Target: Honeykrisp (Asahi M2), Vulkan 1.3 dynamic rendering. Branch vulkan, worktree .claude/worktrees/vulkan.

cmake -S src/vk -B build-vk -G Ninja && ninja -C build-vk && build-vk/vkr_selftest out.bmp

Approach

The executor keeps parsing the pushbuffer, tracking state and running vertex programs on the CPU (nv2a_vsh_run). Its post-program vertices (Nv2aVshOutput: pixel-space pos, w, d0/d1, fog, 4×tex) go to vkr_draw instead of the per-pixel rasteriser. The vertex shader re-expands pos to clip space (xy/size*2-1, z/zmax, w) so the GPU clips and interpolates perspective-correctly. Raster was ~65–70% of executor time, VSH ~15%.

Milestones

Notes

Log

2026-10-14Worktree vulkan from linux. Core + selftest on Honeykrisp: depth-tested triangles OK (5ee232b).
2026-10-14Backend hook + glue; game builds in the worktree (private toolkit clone tk/, generated sources and game symlinked from the main tree). RECOMP_GPU=vk reaches the frontend, Honeykrisp, 640x480 target. Next: textures.
2026-10-14Vulkan 1.4 required (push descriptors core). Stage-0 textures + blend + alpha test: intro movie frame correct under RECOMP_GPU=vk.
2026-10-14Frontend menus on Vulkan look right (Select Mode screen). Menu frame rate: Vulkan 43–50 FPS (p50 18–23 ms) vs software 5–8 FPS. Race not tried yet (needs combiners, shadow-map RTs, fog).
2026-10-14Black menu backgrounds: stage 0 disabled (stage_program&0x1F == 0) but a stale texture was still sampled. Fixed; backgrounds and panels now draw. Still to compare with software: ~10 px black strip at the left/right screen edge. RECOMP_VKR_TRACE=<flagfile> logs large draws while the file exists.
2026-10-14Select Character: rider was transparent because the placeholder shader used d0.a; the vertex-program lighting puts junk there and the combiners produce the real alpha. Combiner GLSL port fixed it.
2026-10-14Character screen 12 FPS: RECOMP_VKR_STATS=1 showed 700 of 1000 ms/s in texture lookup, i.e. hashing every bound texture's bytes on every draw (984 draws × up to 4 stages). Hash now memoised per texture per flipped frame: 47 FPS (p50 21 ms). Remaining per frame: flip readback ~3 ms (GPU sync + copy to guest memory), vkr_draw ~1 ms; the rest is guest code + CPU vertex programs. A texture rewritten mid-frame is only seen at the next flip.
2026-10-14perf (6 s, character screen): note() (pushbuffer survey, linear scan per word) 33%, read_src 16% + nv2a_vsh_run 11% (CPU vertex programs), sched_yield 11%, Vulkan driver ~3%. note() made O(1). Frame stays ~19–20 ms: menus of any size cap at ~50 FPS, so that screen is probably at the game's own frame pacing (PAL?) — unconfirmed. Next speed target is races; CPU vertex programs (→ SPIR-V) are the biggest known cost.
2026-10-14Worktree now has its own generated sources (lifted with this branch's overrides via the private tk/); the symlink to the main tree's gen/ broke when the other session regenerated.
2026-10-14Found the shared toolkit clone diverges from the patch; plan a private clone for the backend hook.
2026-10-14Race (Snow Jam) 23.6 → 52–54 FPS (p50 18 ms), from perf profiles: per-batch post-transform vertex cache (RECOMP_VSH_CACHE=0 off; 24 → 30); vertex programs pre-decoded once per upload and big batches run on the raster pool; raster pool enabled on POSIX (was _WIN32 only), batch flush threshold 1024 px, texture decode on the pool; LensFX visibility poll no longer blocks; software-method hand-off signalled by an event instead of a 1 ms poll (200 → 20 ms/s executor stall; 30 → 42); flip readback asynchronous, two frames in flight (5 ms/flip executor stall gone; 42 → 53). Near the game's ~50 Hz pacing now.
2026-10-14Magenta HUD in races: vkr_set_target (the race intro changes the clip height 468–480) dropped the recorded command buffer, texture uploads included; those textures stayed cached empty until the 768 MB cache drop. Now submitted first. Palette address and contents are part of the texture key (P8 textures). W-buffering (CONTROL0 bit 16) emulated in the fragment shader, for trails seen through distant hills.