build: RX_VK_PGO, a profile-guided build of the Vulkan back end #965

Closed
HenriqueSBueno wants to merge 1 commit from vk-pgo into main
HenriqueSBueno commented 2026-11-09 03:27:46 +00:00 (Migrated from github.com)

Problem

The replay thread is the frame's limit on CPU-bound PCs (n_nvnQueueSubmitCommands, ~10 us a draw), and the back end is large, branchy C++ built at plain -O2. The lifted game already has a profile-guided build (RX_PGO), the back end has none.

Change

RX_VK_PGO, the same two steps for hookshot_vk.dll (off unless set, nothing changes otherwise):

  • RX_VK_PGO=gen: the back end's objects are built with -fprofile-instr-generate, the DLL linked with it. While the game runs, a thread in vk_main.cpp writes the counters every 15 s to RX_VK_PGO_FILE (so a run that is stopped, not closed, still leaves its profile).
  • llvm-profdata merge -o vk.profdata *.profraw (the toolchain's).
  • RX_VK_PGO=<vk.profdata>: built with -fprofile-instr-use; the profile's hash goes into the flags, so a new profile rebuilds the objects, as RX_PGO does.

The bundled llvm-mingw (clang 23) links libclang_rt.profile-x86_64.a for this without anything extra.

Measured

i5-10400F + RTX 3080, Windows 11, v2.0.5 plus a few renderer PRs, Kokiri Forest from the same save, frame generation off, fullscreen 3840x2160 (Output resolution 3840x2160 at 67%, #849), 12 x 5 s windows a run, runs interleaved. Profile: one 60 s idle run at the same spot and one 2 min walk around Kokiri Forest (two .profraw, 44 MB).

run build draws native fps (median) replay submit a frame
1 -O2 2451 32.5 24.09 ms
2 PGO 2455 34.0 22.52 ms
3 -O2 2440 32.2 24.00 ms
4 PGO 2454 33.3 22.75 ms
5 -O2 2457 32.8 23.59 ms
6 PGO 1794 35.6 18.65 ms (another view, not comparable)

At the same view: replay 23.9 → 22.6 ms a frame (-5.5%), native 32.5 → 33.7 fps. The flash detector run on the instrumented build: 0 flash events.

Not done

  • No profile is shipped: one could be kept beside the game's PGO profile and used by the builder by default, if this is wanted.
  • Only OoT's opening area was profiled.
## Problem The replay thread is the frame's limit on CPU-bound PCs (`n_nvnQueueSubmitCommands`, ~10 us a draw), and the back end is large, branchy C++ built at plain `-O2`. The lifted game already has a profile-guided build (`RX_PGO`), the back end has none. ## Change `RX_VK_PGO`, the same two steps for `hookshot_vk.dll` (off unless set, nothing changes otherwise): - `RX_VK_PGO=gen`: the back end's objects are built with `-fprofile-instr-generate`, the DLL linked with it. While the game runs, a thread in `vk_main.cpp` writes the counters every 15 s to `RX_VK_PGO_FILE` (so a run that is stopped, not closed, still leaves its profile). - `llvm-profdata merge -o vk.profdata *.profraw` (the toolchain's). - `RX_VK_PGO=<vk.profdata>`: built with `-fprofile-instr-use`; the profile's hash goes into the flags, so a new profile rebuilds the objects, as `RX_PGO` does. The bundled llvm-mingw (clang 23) links `libclang_rt.profile-x86_64.a` for this without anything extra. ## Measured i5-10400F + RTX 3080, Windows 11, v2.0.5 plus a few renderer PRs, Kokiri Forest from the same save, frame generation off, fullscreen 3840x2160 (Output resolution 3840x2160 at 67%, #849), 12 x 5 s windows a run, runs interleaved. Profile: one 60 s idle run at the same spot and one 2 min walk around Kokiri Forest (two `.profraw`, 44 MB). | run | build | draws | native fps (median) | replay submit a frame | |---|---|---|---|---| | 1 | -O2 | 2451 | 32.5 | 24.09 ms | | 2 | PGO | 2455 | 34.0 | 22.52 ms | | 3 | -O2 | 2440 | 32.2 | 24.00 ms | | 4 | PGO | 2454 | 33.3 | 22.75 ms | | 5 | -O2 | 2457 | 32.8 | 23.59 ms | | 6 | PGO | 1794 | 35.6 | 18.65 ms (another view, not comparable) | At the same view: replay 23.9 → 22.6 ms a frame (-5.5%), native 32.5 → 33.7 fps. The flash detector run on the instrumented build: 0 flash events. ## Not done - No profile is shipped: one could be kept beside the game's PGO profile and used by the builder by default, if this is wanted. - Only OoT's opening area was profiled.
NotRexed commented 2026-11-09 05:37:12 +00:00 (Migrated from github.com)

Thank you! On current main this breaks tests/test_shader_stamp_cache.py (6 failures, "expected one Vulkan job-construction branch": the new RX_VK_PGO branch in nx2/build.py adds a second vflags assignment the test looks for). Closing to keep the queue clear — please rebase on current main, keep that test passing, and reopen; thanks!

Thank you! On current main this breaks tests/test_shader_stamp_cache.py (6 failures, "expected one Vulkan job-construction branch": the new RX_VK_PGO branch in nx2/build.py adds a second vflags assignment the test looks for). Closing to keep the queue clear — please rebase on current main, keep that test passing, and reopen; thanks!
Commenting is not possible because the repository is archived.
No description provided.