WIP: perf(vk): a scene draw learns the frame's camera is taken without the chain's lock (RX_VK_CHAIN_LOCKLESS) #2005

Draft
siantm wants to merge 7 commits from siantm/Longshot:perf/vk-chain-lockless into main
Contributor

Summary

Every draw into a target of the scene's size asks the Upscaler's mode through a chain of calls and takes the temporal chain's mutex in temporal_note_scene_draw (gpu/vk/vk_temporal.cpp), to learn that this frame's camera, of a target at least as large, was taken already. With the switch on, that answer is read first from two atomics, State::cam_frame and cam_area, which cam_tell writes under the lock where the camera is taken (the draw that takes it) or let go (cam_drop, the one place that lets it go, called by stretch, fg_inputs and temporal_upscale): the area, then the frame. That a draw's two loads are of one camera rests on replay_mu (vk_replay.cpp): every draw and every upscale that takes or lets go of the camera runs on the replay with it held, so no cam_tell runs between them (the release/acquire pair alone would not rule out a later camera's area with this frame). Where they say "this frame's camera, at least this large" the draw returns, as it returned before at the mode's test or under the lock; else it goes on as before. The expected result is a little less replay CPU time a frame with a temporal upscaler (no Upscaler mode chain and no uncontended mutex for the draws after the one that took the camera); it is not measured. With RX_VK_PROF_FINE=1 (the draw path's fine profile) the scene draws at this test are counted, a frame, by the way they went: the frame log's vk: a frame (fine): scene draws at the camera's test: <n> returned without the chain's lock (RX_VK_CHAIN_LOCKLESS), <n> went on to the lock line, every 120 frames, for the A/B below.

Switch: RX_VK_CHAIN_LOCKLESS (kind kill, on by default as the change proposes, docs/dev/standards.md, Switches; its row in gpu/vk/switches.def). Unset, 1 or any value but those below: the atomics first. 0 (or an empty value, false, off or no, in any case, spaces around it not counted): the draw's decision as before (a target the Upscaler's format or mode rejects returns before the lock, the others ask under the lock), the frame read under the lock alone and the atomics neither read nor written; the switch is still tested at each scene draw. It is read once, at its first use (so HOS_AB cannot alternate it); its first read logs what it chose.

From bd3ea307 and 4eed88f7 on exp/x86-asm-sync.

Read first: cam_tell, cam_drop, chain_lockless, the start of temporal_note_scene_draw and temporal_scene_draw_report in gpu/vk/vk_temporal.cpp.

Testing

Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head 84157f83 on main @ 9dd41326 (the branch's earlier commits unchanged by the rebase, git range-diff; then test ae8ab7a4, default ae476851, test 9003fc39, counts 84157f83), in jobs dyl-2005 (light, two checks at once) and dyh-2005 (build) of the PC's job queue, each check in a hidden console of its own, RX_CPM set:

  • Its own, through tests/run_all.py --strict --exact: tests/test_chain_lockless.py (kNoCamera, chain_lockless, cam_tell, cam_drop, the counters, the part of temporal_note_scene_draw before its lock and its test under the lock, cut from vk_temporal.cpp, over 20,000 random frames, cameras taken and let go by the real cam_drop and draws, with RX_VK_CHAIN_LOCKLESS unset, 0 and 1 and RX_VK_PROF_FINE unset, 0 and 1: on (unset or 1), a draw returns before the mode and the lock exactly when the cut test under the lock would; 0, every draw goes on to the lock, the frame is not read before it and the atomics are never written; with RX_VK_PROF_FINE=1 each draw counted once by the way it went and temporal_scene_draw_report giving both counts a frame, then nothing new; otherwise nothing counted or logged; the source has no write to the camera but in cam_drop and the draw that takes it, and fine_report calls the report; the switch's reader in fresh processes: unset, 1, on and another value on, 0, off, false, no, empty and spaces off, twice each, set to the other answer after its first read with the setter's result checked), tests/test_psychov35_off.py (Off's real stretch, with a camera told to the atomics, lets it go and tells them), tests/test_switch_table.py: pass.
  • At the test commits: at ae8ab7a4 test_chain_lockless.py fails (unset still off); at 9003fc39 it fails (no counts in the source); at the head it passes.
  • gpu/vk/vk_temporal.cpp and gpu/vk/vk_draw.cpp compiled (no object) with the game build's own commands for them, from a local build's compile_commands.json: no error.
  • The 196 checks that read a file this change touches (tests/run_all.py --changed origin/main, RX_CPM set; job dyh-2005): 171 passed, 19 failed, 6 skipped (Linux only). 18 of the failures fail on main @ 9dd41326 too, the same way, run in the same job: tests/test_crash_dialog.py, tests/test_dev_ab.py, tests/test_dev_packs.py, tests/test_device_lost_exit.py, tests/test_draw_binds.py, tests/test_draw_stream_visibility.py, tests/test_frame_overlap.py, tests/test_fsr_uniform_ownership.py, tests/test_linux_pressure.py, tests/test_mesh_conv.py, tests/test_pipeline_play_cache.py, tests/test_prepare_cache_save.py, tests/test_present_queue_default.py, tests/test_recorder_own_idle.py, tests/test_sampler_admission.py, tests/test_target_reuse_memory.py, tests/test_upscaler_rows.py, tests/test_vk_occlusion_queries.py. The 19th, tests/test_recording_admission.py, failed at the head and passed on main in that job: its parallel worker-slot case fails now and then on main as well (3 of 5 runs on f1f2dc5b in #2003's earlier job fb-2003-3); repeated runs at the head against main are still to do. None stopped for want of the Vulkan headers. tests/test_vbytes.py is not among them and was not run.

It has NOT run in the game on this PC yet.

Still to test:

  • Windows 11, i7-9700, RTX 4060 (this PC): start in Kokiri Forest from the scene's save, play a minute (walking, turning the camera) with DLSS as the Upscaler, then FSR 3.1, then the Upscaler Off, then Game after a temporal upscaler (the kept output size lets draws reach the new test with no camera this frame): main @ 9dd41326, this PR with RX_VK_CHAIN_LOCKLESS=0 and this PR unset (as it ships), all with RX_VK_PROF_FINE=1, each warmed a minute in the scene first, then interleaved (main, =0, unset, unset, =0, main), two runs each. Report the replay's CPU time a frame (vk: a frame's replay time (ms), its draw part) per run and as medians with the spread, and from the unset runs the scene draws a frame that took the shortcut against those that reached the lock (vk: a frame (fine): scene draws at the camera's test: ...); FPS, 1% lows and p99 only beside them (they are bound by the GPU and the present and cannot show a saving this size). Expecting the same picture all three ways (no smearing, no ghosting, no jitter), =0 as main, and unset's replay CPU time lower than =0's beyond the spread; if it is not, the change is dropped (no measured gain, no merge) and this description says so (by hand)
  • Windows 11, i7-9700, RTX 4060 (this PC): the same in a heavy scene (Hyrule Field) at the PC's usual preset and resolution, also with Off's stretch, with frame generation on without a temporal upscaler and with DLAA before the bloom, and a camera taken again across presents (pausing and unpausing) (by hand)
  • Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: start in Kokiri Forest from the scene's save, play a minute (walking, turning the camera) with a temporal upscaler, main against this PR unset (as it ships) and with RX_VK_CHAIN_LOCKLESS=0, warmed, in ABBA order, expecting the same picture every way and no crash or validation error (by hand or on the farm, not run yet); the change has no vendor, driver or OS path, so this is a picture and stability check, the gain is measured above
  • Linux (any GPU): build the renderer and run tests/test_chain_lockless.py, tests/test_psychov35_off.py with --cxx g++ and --cxx clang++, expecting PASS (by hand)

Measurements

Verdict: not measured in play yet: no micro-benchmark and no run in the game on this PC yet; the in-game A/B (replay CPU time a frame and the shortcut's counts, Still to test) comes first. RX_VK_CHAIN_LOCKLESS ships on (kind kill, 0 gives the draw's decision as before), the value this change proposes (docs/dev/standards.md, Switches); if the A/B shows no gain beyond the spread, the change is dropped.

Risks

Unset (the default) a scene draw first reads the two atomics; RX_VK_CHAIN_LOCKLESS=0 decides as on main, the cost then the switch's test at each scene draw. A draw that returns early though the camera was let go since would leave the upscaler without this frame's camera (smearing or ghosting for a frame): the camera is let go in cam_drop alone, which tells the atomics, and the test fails on any other write to it; the shortcut's two loads rely on replay_mu serialising the draws and the upscales, as they do today. With RX_VK_PROF_FINE=1 each scene draw at the test adds one relaxed atomic increment (off, one read-once bool). The renderer is compiled again after updating.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. Not yet: it has not run in the game.
  • mise run test passes (any failure that also fails on main is named). Not yet: only the checks in Testing ran.
  • Measured against main, or Measurements says why there is nothing to measure. Not yet (Measurements).
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def. Its row is in; it ships on, as the change proposes (docs/dev/standards.md, Switches), not measured yet; RX_VK_PROF_FINE's row names the new count line.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Not yet: vk_temporal.cpp and vk_draw.cpp compiled with the game build's commands (Testing); no full build.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary Every draw into a target of the scene's size asks the Upscaler's mode through a chain of calls and takes the temporal chain's mutex in `temporal_note_scene_draw` (`gpu/vk/vk_temporal.cpp`), to learn that this frame's camera, of a target at least as large, was taken already. With the switch on, that answer is read first from two atomics, `State::cam_frame` and `cam_area`, which `cam_tell` writes under the lock where the camera is taken (the draw that takes it) or let go (`cam_drop`, the one place that lets it go, called by `stretch`, `fg_inputs` and `temporal_upscale`): the area, then the frame. That a draw's two loads are of one camera rests on `replay_mu` (`vk_replay.cpp`): every draw and every upscale that takes or lets go of the camera runs on the replay with it held, so no `cam_tell` runs between them (the release/acquire pair alone would not rule out a later camera's area with this frame). Where they say "this frame's camera, at least this large" the draw returns, as it returned before at the mode's test or under the lock; else it goes on as before. The expected result is a little less replay CPU time a frame with a temporal upscaler (no Upscaler mode chain and no uncontended mutex for the draws after the one that took the camera); it is not measured. With `RX_VK_PROF_FINE=1` (the draw path's fine profile) the scene draws at this test are counted, a frame, by the way they went: the frame log's `vk: a frame (fine): scene draws at the camera's test: <n> returned without the chain's lock (RX_VK_CHAIN_LOCKLESS), <n> went on to the lock` line, every 120 frames, for the A/B below. Switch: `RX_VK_CHAIN_LOCKLESS` (kind kill, on by default as the change proposes, docs/dev/standards.md, Switches; its row in `gpu/vk/switches.def`). Unset, `1` or any value but those below: the atomics first. `0` (or an empty value, `false`, `off` or `no`, in any case, spaces around it not counted): the draw's decision as before (a target the Upscaler's format or mode rejects returns before the lock, the others ask under the lock), the frame read under the lock alone and the atomics neither read nor written; the switch is still tested at each scene draw. It is read once, at its first use (so `HOS_AB` cannot alternate it); its first read logs what it chose. From bd3ea307 and 4eed88f7 on `exp/x86-asm-sync`. Read first: `cam_tell`, `cam_drop`, `chain_lockless`, the start of `temporal_note_scene_draw` and `temporal_scene_draw_report` in `gpu/vk/vk_temporal.cpp`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head 84157f83 on main @ 9dd41326 (the branch's earlier commits unchanged by the rebase, `git range-diff`; then test ae8ab7a4, default ae476851, test 9003fc39, counts 84157f83), in jobs `dyl-2005` (light, two checks at once) and `dyh-2005` (build) of the PC's job queue, each check in a hidden console of its own, `RX_CPM` set: - Its own, through `tests/run_all.py --strict --exact`: `tests/test_chain_lockless.py` (`kNoCamera`, `chain_lockless`, `cam_tell`, `cam_drop`, the counters, the part of `temporal_note_scene_draw` before its lock and its test under the lock, cut from `vk_temporal.cpp`, over 20,000 random frames, cameras taken and let go by the real `cam_drop` and draws, with `RX_VK_CHAIN_LOCKLESS` unset, `0` and `1` and `RX_VK_PROF_FINE` unset, `0` and `1`: on (unset or `1`), a draw returns before the mode and the lock exactly when the cut test under the lock would; `0`, every draw goes on to the lock, the frame is not read before it and the atomics are never written; with `RX_VK_PROF_FINE=1` each draw counted once by the way it went and `temporal_scene_draw_report` giving both counts a frame, then nothing new; otherwise nothing counted or logged; the source has no write to the camera but in `cam_drop` and the draw that takes it, and `fine_report` calls the report; the switch's reader in fresh processes: unset, `1`, `on` and another value on, `0`, `off`, `false`, `no`, empty and spaces off, twice each, set to the other answer after its first read with the setter's result checked), `tests/test_psychov35_off.py` (Off's real `stretch`, with a camera told to the atomics, lets it go and tells them), `tests/test_switch_table.py`: pass. - At the test commits: at ae8ab7a4 `test_chain_lockless.py` fails (unset still off); at 9003fc39 it fails (no counts in the source); at the head it passes. - `gpu/vk/vk_temporal.cpp` and `gpu/vk/vk_draw.cpp` compiled (no object) with the game build's own commands for them, from a local build's compile_commands.json: no error. - The 196 checks that read a file this change touches (`tests/run_all.py --changed origin/main`, `RX_CPM` set; job `dyh-2005`): 171 passed, 19 failed, 6 skipped (Linux only). 18 of the failures fail on main @ 9dd41326 too, the same way, run in the same job: `tests/test_crash_dialog.py`, `tests/test_dev_ab.py`, `tests/test_dev_packs.py`, `tests/test_device_lost_exit.py`, `tests/test_draw_binds.py`, `tests/test_draw_stream_visibility.py`, `tests/test_frame_overlap.py`, `tests/test_fsr_uniform_ownership.py`, `tests/test_linux_pressure.py`, `tests/test_mesh_conv.py`, `tests/test_pipeline_play_cache.py`, `tests/test_prepare_cache_save.py`, `tests/test_present_queue_default.py`, `tests/test_recorder_own_idle.py`, `tests/test_sampler_admission.py`, `tests/test_target_reuse_memory.py`, `tests/test_upscaler_rows.py`, `tests/test_vk_occlusion_queries.py`. The 19th, `tests/test_recording_admission.py`, failed at the head and passed on main in that job: its parallel worker-slot case fails now and then on main as well (3 of 5 runs on f1f2dc5b in #2003's earlier job fb-2003-3); repeated runs at the head against main are still to do. None stopped for want of the Vulkan headers. `tests/test_vbytes.py` is not among them and was not run. It has NOT run in the game on this PC yet. **Still to test:** - Windows 11, i7-9700, RTX 4060 (this PC): start in Kokiri Forest from the scene's save, play a minute (walking, turning the camera) with DLSS as the Upscaler, then FSR 3.1, then the Upscaler Off, then Game after a temporal upscaler (the kept output size lets draws reach the new test with no camera this frame): main @ 9dd41326, this PR with `RX_VK_CHAIN_LOCKLESS=0` and this PR unset (as it ships), all with `RX_VK_PROF_FINE=1`, each warmed a minute in the scene first, then interleaved (main, =0, unset, unset, =0, main), two runs each. Report the replay's CPU time a frame (`vk: a frame's replay time (ms)`, its draw part) per run and as medians with the spread, and from the unset runs the scene draws a frame that took the shortcut against those that reached the lock (`vk: a frame (fine): scene draws at the camera's test: ...`); FPS, 1% lows and p99 only beside them (they are bound by the GPU and the present and cannot show a saving this size). Expecting the same picture all three ways (no smearing, no ghosting, no jitter), =0 as main, and unset's replay CPU time lower than =0's beyond the spread; if it is not, the change is dropped (no measured gain, no merge) and this description says so (by hand) - Windows 11, i7-9700, RTX 4060 (this PC): the same in a heavy scene (Hyrule Field) at the PC's usual preset and resolution, also with Off's stretch, with frame generation on without a temporal upscaler and with DLAA before the bloom, and a camera taken again across presents (pausing and unpausing) (by hand) - Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: start in Kokiri Forest from the scene's save, play a minute (walking, turning the camera) with a temporal upscaler, main against this PR unset (as it ships) and with `RX_VK_CHAIN_LOCKLESS=0`, warmed, in ABBA order, expecting the same picture every way and no crash or validation error (by hand or on the farm, not run yet); the change has no vendor, driver or OS path, so this is a picture and stability check, the gain is measured above - Linux (any GPU): build the renderer and run `tests/test_chain_lockless.py`, `tests/test_psychov35_off.py` with `--cxx g++` and `--cxx clang++`, expecting PASS (by hand) ## Measurements **Verdict:** not measured in play yet: no micro-benchmark and no run in the game on this PC yet; the in-game A/B (replay CPU time a frame and the shortcut's counts, Still to test) comes first. `RX_VK_CHAIN_LOCKLESS` ships on (kind kill, `0` gives the draw's decision as before), the value this change proposes (docs/dev/standards.md, Switches); if the A/B shows no gain beyond the spread, the change is dropped. ## Risks Unset (the default) a scene draw first reads the two atomics; `RX_VK_CHAIN_LOCKLESS=0` decides as on main, the cost then the switch's test at each scene draw. A draw that returns early though the camera was let go since would leave the upscaler without this frame's camera (smearing or ghosting for a frame): the camera is let go in `cam_drop` alone, which tells the atomics, and the test fails on any other write to it; the shortcut's two loads rely on `replay_mu` serialising the draws and the upscales, as they do today. With `RX_VK_PROF_FINE=1` each scene draw at the test adds one relaxed atomic increment (off, one read-once bool). The renderer is compiled again after updating. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. Not yet: it has not run in the game. - [ ] `mise run test` passes (any failure that also fails on `main` is named). Not yet: only the checks in Testing ran. - [ ] Measured against `main`, or Measurements says why there is nothing to measure. Not yet (Measurements). - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. Its row is in; it ships on, as the change proposes (docs/dev/standards.md, Switches), not measured yet; `RX_VK_PROF_FINE`'s row names the new count line. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Not yet: `vk_temporal.cpp` and `vk_draw.cpp` compiled with the game build's commands (Testing); no full build. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
perf(vk): a scene draw learns the frame's camera is taken without the chain's lock (RX_VK_CHAIN_LOCKLESS)
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
ec735e077e
Every draw into a target of the scene's size asked the Upscaler's mode through a chain of calls and took the temporal
chain's mutex in temporal_note_scene_draw (gpu/vk/vk_temporal.cpp), to learn that this frame's camera, of a target at
least as large, was taken already (the largest target of the frame wins, and its first draw took it). Now that answer is
read first from two atomics, State::cam_frame and cam_area, which cam_tell writes under the lock wherever the camera is
taken or let go (the draw that takes it, stretch, fg_inputs, temporal_upscale): the area before the frame, so a reader
that sees the frame has the pixels that go with it. Where they say "this frame's camera, at least this large" the draw
returns, as it returned before at the mode's test or under the lock; else it goes on as before, and reads the frame
again under the lock (4eed88f7's review fix: a wait for the lock across a present must not stamp the frame before).

Branch: bd3ea307 / 4eed88f7; the saving is not measured, on the branch or in play.

Switch: RX_VK_CHAIN_LOCKLESS (kill, on; =0, or false, off, no: the mode and the lock at every scene draw, as before),
read once, at its first use; its row in switches.def.
Test: tests/test_chain_lockless.py compiles kNoCamera, chain_lockless, cam_tell and the part of temporal_note_scene_draw
before its lock, cut from vk_temporal.cpp, and runs 20,000 random frames, cameras taken and let go and draws: a draw
returns before the mode and the lock exactly when the test under the lock would return (with =0, never); and it checks
every camera let go in vk_temporal.cpp is told to the atomics; and the switch's reader runs in fresh processes (unset,
0, off, false, 1, on and another value, twice each, set again after its first read).

Assisted-by: Claude Code
BeanBot left a comment

Recommendation: Request changes. The new check can fail before it starts on a documented Windows setup because the test runner bypasses its llvm-mingw fallback. The draw shortcut can save CPU work, but there are no in-game measurements to justify enabling it by default.

Repeated draws can skip the temporal chain mutex and upscaler mode lookup once the frame has a camera from a target at least as large. The existing replay mutex serializes the camera and frame changes. The patch adds two copies of camera metadata and four places that must keep them in sync.

@fix will do (7)

  1. L1 tests/test_chain_lockless.py:27: The suite resolves {cxx} before this test's compiler fallback runs. (more on the line)
  2. L2 (minor) gpu/vk/vk_temporal.cpp:345: The comment attributes snapshot consistency to the release/acquire pair. (more on the line)
  3. L3 (minor) tests/test_chain_lockless.py:182: The fixture simulates invalidation and checks production with a regex. (more on the line)
  4. L4 (minor) tests/test_chain_lockless.py:121: The switch fixture ignores the result of _putenv_s and setenv. (more on the line)
  5. L5 (minor) gpu/vk/switches.def:296: The switch row says every scene draw takes the lock when disabled and that any other value enables it. (more on the line)
  6. L6 (its part an edit can do) gpu/vk/vk_temporal.cpp:976: Read the frame only when the shortcut is enabled and skip metadata publication when disabled. Consider using replay-owned camera fields to remove the extra stores on both paths.
  7. L8 (minor): The PR omits the template's Ready to merge checklist. Restore it with the boxes open so the hardware runs, review and final head checks can be recorded. Add the named-commit Measurements table once the runs are available.

For the author (2) (a run, a measurement or a decision)

  • L6 (minor) gpu/vk/vk_temporal.cpp:976: Measure warmed, interleaved runs of main and the PR with the switch on and off. (more on the line)
  • L7 (minor): The PR opened without the required author gameplay run. Before merge, record the actual renderer builds and in-game results on Windows and Linux, including affected Tier 1 NVIDIA and AMD configurations and Steam Deck. Exercise camera reacquisition across presents, Off's stretch, frame-generation-only inputs, and DLAA before bloom where available. Run the full source suite and record the driver versions and results.

Checks: Still running: PR description / Description follows the template (pull_request_target), CI / Conventional Commit title (pull_request), CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request), CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request), CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request), CI / Workflow lint (actionlint) (pull_request), CI / Website build and checks (pull_request), Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request).

More: does it help, other systems, switches, what was read

Does it help: Unproven. The PR reports 39 of 47 selected Windows source checks passed and eight failed on both ec735e07 and base 75317e1f. Those checks provide no replay timing, FPS, 1% lows, or frame-time measurements. There are no in-game runs.

Other systems: The changed hook is shared by DLSS, DLAA before bloom, FSR 3.1 on the temporal chain, FSR 4, XeSS, Off's stretch, and camera inputs for frame generation without a temporal upscaler. Game mode and FSR 3.1's separate path can still pay for a failed shortcut. The recorder and presenter do not update the camera. The diff changes no shader, GPU allocation, public renderer interface, save format, audio, or input code.

Switches: RX_VK_CHAIN_LOCKLESS is a developer kill switch, on when unset. Empty or whitespace-only values and 0, false, off, or no disable it, ignoring case and surrounding whitespace. It is cached and logged at first use, so HOS_AB cannot alternate it. The sorted table row is present. The on default still needs measurements across supported configurations.

Reviewed: ec735e077e against 75317e1f31: Read vk_temporal.cpp, both changed Python tests, the changed switch row and nearby entries, the full diff and commit, AGENTS.md, CONTRIBUTING.md, the Forgejo template, and the developer standards. Traced draw and upscale callers, replay and present locking, the frame counter, the environment parser, and test-runner compiler selection. Skimmed other source checks that read the changed files and the rest of the switch table. No local review-checklist or cited run logs were present. There were no comments, prior reviews, translations, or generated-file changes.; nothing run (a code review).

Checked and fine:

  • All current camera capture and invalidation sites publish the mirror. Camera struct copies stay under the chain mutex, and replay_mu serializes the shortcut with those writes and the frame increment.
  • The area calculation widens before multiplying. The shortcut reads no camera pointers or guest data and adds no per-thread allocation.
  • The existing Off fixture keeps its dispatch and failure-retry assertions. The new fixture exercises both switch states and removes any inherited switch value for its unset case.
  • The commit carries the AI assistance trailer. The diff contains no game-derived outputs, vendor SDKs, third-party edits, public API changes, or generated shader changes.

Testing: Read-only review. No builds or tests run here. The author reports both edited checks passed with Windows llvm-mingw and that eight selected failures also occur on the base. The full suite, Linux compiler runs, gameplay comparisons, and CI results are pending.

Overlaps and merge order: No overlapping pull request found in the supplied context or local history. Local main has advanced past the tested base. Its switch-table edit is on a different row. Confirm results against current main before merge.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The new check can fail before it starts on a documented Windows setup because the test runner bypasses its llvm-mingw fallback. The draw shortcut can save CPU work, but there are no in-game measurements to justify enabling it by default. Repeated draws can skip the temporal chain mutex and upscaler mode lookup once the frame has a camera from a target at least as large. The existing replay mutex serializes the camera and frame changes. The patch adds two copies of camera metadata and four places that must keep them in sync. **`@fix` will do (7)** 1. **L1** `tests/test_chain_lockless.py:27`: The suite resolves {cxx} before this test's compiler fallback runs. (more on the line) 2. **L2** (minor) `gpu/vk/vk_temporal.cpp:345`: The comment attributes snapshot consistency to the release/acquire pair. (more on the line) 3. **L3** (minor) `tests/test_chain_lockless.py:182`: The fixture simulates invalidation and checks production with a regex. (more on the line) 4. **L4** (minor) `tests/test_chain_lockless.py:121`: The switch fixture ignores the result of _putenv_s and setenv. (more on the line) 5. **L5** (minor) `gpu/vk/switches.def:296`: The switch row says every scene draw takes the lock when disabled and that any other value enables it. (more on the line) 6. **L6** (its part an edit can do) `gpu/vk/vk_temporal.cpp:976`: Read the frame only when the shortcut is enabled and skip metadata publication when disabled. Consider using replay-owned camera fields to remove the extra stores on both paths. 7. **L8** (minor): The PR omits the template's Ready to merge checklist. Restore it with the boxes open so the hardware runs, review and final head checks can be recorded. Add the named-commit Measurements table once the runs are available. **For the author (2)** (a run, a measurement or a decision) - **L6** (minor) `gpu/vk/vk_temporal.cpp:976`: Measure warmed, interleaved runs of main and the PR with the switch on and off. (more on the line) - **L7** (minor): The PR opened without the required author gameplay run. Before merge, record the actual renderer builds and in-game results on Windows and Linux, including affected Tier 1 NVIDIA and AMD configurations and Steam Deck. Exercise camera reacquisition across presents, Off's stretch, frame-generation-only inputs, and DLAA before bloom where available. Run the full source suite and record the driver versions and results. **Checks:** Still running: `PR description / Description follows the template (pull_request_target)`, `CI / Conventional Commit title (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request)`, `CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request)`, `CI / Workflow lint (actionlint) (pull_request)`, `CI / Website build and checks (pull_request)`, `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The PR reports 39 of 47 selected Windows source checks passed and eight failed on both ec735e07 and base 75317e1f. Those checks provide no replay timing, FPS, 1% lows, or frame-time measurements. There are no in-game runs. **Other systems:** The changed hook is shared by DLSS, DLAA before bloom, FSR 3.1 on the temporal chain, FSR 4, XeSS, Off's stretch, and camera inputs for frame generation without a temporal upscaler. Game mode and FSR 3.1's separate path can still pay for a failed shortcut. The recorder and presenter do not update the camera. The diff changes no shader, GPU allocation, public renderer interface, save format, audio, or input code. **Switches:** RX_VK_CHAIN_LOCKLESS is a developer kill switch, on when unset. Empty or whitespace-only values and 0, false, off, or no disable it, ignoring case and surrounding whitespace. It is cached and logged at first use, so HOS_AB cannot alternate it. The sorted table row is present. The on default still needs measurements across supported configurations. **Reviewed:** ec735e077e36 against 75317e1f31ff: Read vk_temporal.cpp, both changed Python tests, the changed switch row and nearby entries, the full diff and commit, AGENTS.md, CONTRIBUTING.md, the Forgejo template, and the developer standards. Traced draw and upscale callers, replay and present locking, the frame counter, the environment parser, and test-runner compiler selection. Skimmed other source checks that read the changed files and the rest of the switch table. No local review-checklist or cited run logs were present. There were no comments, prior reviews, translations, or generated-file changes.; nothing run (a code review). **Checked and fine:** - All current camera capture and invalidation sites publish the mirror. Camera struct copies stay under the chain mutex, and replay_mu serializes the shortcut with those writes and the frame increment. - The area calculation widens before multiplying. The shortcut reads no camera pointers or guest data and adds no per-thread allocation. - The existing Off fixture keeps its dispatch and failure-retry assertions. The new fixture exercises both switch states and removes any inherited switch value for its unset case. - The commit carries the AI assistance trailer. The diff contains no game-derived outputs, vendor SDKs, third-party edits, public API changes, or generated shader changes. **Testing:** Read-only review. No builds or tests run here. The author reports both edited checks passed with Windows llvm-mingw and that eight selected failures also occur on the base. The full suite, Linux compiler runs, gameplay comparisons, and CI results are pending. **Overlaps and merge order:** No overlapping pull request found in the supplied context or local history. Local main has advanced past the tested base. Its switch-table edit is on a different row. Confirm results against current main before merge. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -293,6 +293,7 @@ SW(RX_VK_CAP_FREE_ASYNC, kill, bool, "on: a capture buffer past the spares is de
SW(RX_VK_CAP_MIN_MB, tune, int, "2 MB", "The smallest capture buffer size class in MB; 16 is the old behaviour.")
SW(RX_VK_CAP_SPARE_MB, hw, int, "32 MB of spare capture buffers on cards allowing 6.5 GB or less; no byte limit elsewhere", "Sets how many MB of spare capture buffers are kept for reuse; 0 means no limit, as before.")
SW(RX_VK_CASCADE_BIAS, tune, string, "0,0: nothing added", "Adds a depth bias <units>,<slope> to the sun's shadow cascades.")
SW(RX_VK_CHAIN_LOCKLESS, kill, bool, "on: a scene draw learns the frame's camera is taken without the chain's lock", "=0 (or false, off, no) asks the Upscaler's mode and takes the chain's lock at every scene draw, as before; any other value is on. Read once, at its first use (HOS_AB cannot alternate it).")
Member

L5 (minor): The switch row says every scene draw takes the lock when disabled and that any other value enables it. A format or mode rejection still returns before locking, and whitespace-only values disable the shortcut. Update the row and PR summary. Describe the disabled variant as restoring the original draw decision, since it still checks the switch and publishes camera metadata.

**L5** (minor): The switch row says every scene draw takes the lock when disabled and that any other value enables it. A format or mode rejection still returns before locking, and whitespace-only values disable the shortcut. Update the row and PR summary. Describe the disabled variant as restoring the original draw decision, since it still checks the switch and publishes camera metadata.
@ -325,0 +342,4 @@
}();
return on;
}
/// (s.mu held) cam changed: what the draws' test reads of it. A camera taken: its pixels before its frame, so a reader that
Member

L2 (minor): The comment attributes snapshot consistency to the release/acquire pair. That ordering guarantees visibility of the earlier area store, but it cannot rule out a later area's store. If a draw and camera capture could overlap across a present, a reader could pair the old frame with the next frame's larger area. Today replay_mu excludes that interleaving in both threaded and synchronous replay. Document that ownership at the fast read and publication, or use the existing replay-owned camera fields directly.

**L2** (minor): The comment attributes snapshot consistency to the release/acquire pair. That ordering guarantees visibility of the earlier area store, but it cannot rule out a later area's store. If a draw and camera capture could overlap across a present, a reader could pair the old frame with the next frame's larger area. Today replay_mu excludes that interleaving in both threaded and synchronous replay. Document that ownership at the fast read and publication, or use the existing replay-owned camera fields directly.
@ -945,2 +973,4 @@
// below: the format, the camera's own size and perspective, the largest in the frame, and the upscale's input)
if (!color0 || !depth || !camera || camera_size < 0x230 || !temporal_scene_size(width, height)) return;
State& s = st();
uint64_t now = texture_frame_no();
Member

L6 (minor): Measure warmed, interleaved runs of main and the PR with the switch on and off. Cover Kokiri Forest and a heavy scene using the hardware's normal preset and resolution. Report shortcut hits or lock takes, replay CPU time, average FPS, 1% lows, and median and p99 frame time. Include Game mode after switching away from a temporal upscaler, where the retained output size lets draws reach the new branch but there is no current camera to produce hits. Use the results to choose the default.

**L6** (minor): Measure warmed, interleaved runs of main and the PR with the switch on and off. Cover Kokiri Forest and a heavy scene using the hardware's normal preset and resolution. Report shortcut hits or lock takes, replay CPU time, average FPS, 1% lows, and median and p99 frame time. Include Game mode after switching away from a temporal upscaler, where the retained output size lets draws reach the new branch but there is no current camera to produce hits. Use the results to choose the default.
@ -0,0 +24,4 @@
sys.path.insert(0, str(Path(__file__).resolve().parent)) # (tests/srccut.py: python -I leaves this folder off the path)
from srccut import block, between # noqa: E402
RUN_ALL_ARGS = ["--cxx", "{cxx}"]
Member

L1: The suite resolves {cxx} before this test's compiler fallback runs. On Windows with llvm-mingw configured through LONGSHOT_MINGW or bundled in the clone, and no C++ compiler on PATH, run_all --strict fails before launching the fixture. Make the runner's compiler selection honor configured llvm-mingw after CXX, or let this check resolve its compiler before the runner rejects it.

**L1**: The suite resolves {cxx} before this test's compiler fallback runs. On Windows with llvm-mingw configured through LONGSHOT_MINGW or bundled in the clone, and no C++ compiler on PATH, run_all --strict fails before launching the fixture. Make the runner's compiler selection honor configured llvm-mingw after CXX, or let this check resolve its compiler before the runner rejects it.
@ -0,0 +118,4 @@
const bool first = t::@FN@();
#ifdef _WIN32
_putenv_s("@NAME@", argv[1]);
#else
Member

L4 (minor): The switch fixture ignores the result of _putenv_s and setenv. If the write fails, the cached-value assertion passes without an environment change. Check the setter result and verify the new value before checking the second read. Include no and a whitespace-only value among the off cases.

**L4** (minor): The switch fixture ignores the result of _putenv_s and setenv. If the write fails, the cached-value assertion passes without an environment change. Check the setter result and verify the new value before checking the second read. Include no and a whitespace-only value among the off cases.
@ -0,0 +179,4 @@
raise SystemExit("temporal_note_scene_draw: the frame is not read again under the lock")
if not note.rstrip().rstrip("}").rstrip().endswith("cam_tell(s);"):
raise SystemExit("temporal_note_scene_draw: a camera taken is not told to the atomics")
# (every camera let go tells the atomics, right after)
Member

L3 (minor): The fixture simulates invalidation and checks production with a regex. Replacing a real invalidation and its cam_tell call with s.cam = {} would bypass the regex and leave the test passing while a later same-frame draw could skip capture. Exercise real invalidation paths with a camera already published, then check that the next eligible draw goes through. The existing Off dispatch fixture can cover stretch.

**L3** (minor): The fixture simulates invalidation and checks production with a regex. Replacing a real invalidation and its cam_tell call with s.cam = {} would bypass the regex and leave the test passing while a later same-frame draw could skip capture. Exercise real invalidation paths with a camera already published, then check that the next eligible draw goes through. The existing Off dispatch fixture can cover stretch.
siantm force-pushed perf/vk-chain-lockless from ec735e077e
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to 1cdc21f877
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-21 07:14:21 +00:00
Compare
siantm changed title from WIP: perf(vk): a scene draw learns the frame's camera is taken without the chain's lock (RX_VK_CHAIN_LOCKLESS) to WIP: perf(vk): a scene draw learns the frame's camera is taken without the chain's lock (RX_VK_CHAIN_LOCKLESS, off by default) 2026-11-21 07:14:48 +00:00
Author
Contributor

Thank you for the review (#issuecomment-63412). Pushed 1cdc21f8, rebased on main @ fd7dc40d (the branch's own commit unchanged by the rebase, git range-diff; main's FPS-footer change added a route_drawn stand-in to tests/test_psychov35_off.py beside this test commit's env_on one: both kept); test commit 59b5ee5a (its checks fail on the branch's earlier code), fix 1cdc21f8; queue job fb-2003-6 (shared with #2003). All checks named below ran in that job on this PC; nothing has run in the game.

Default: there is no measurement in play, so RX_VK_CHAIN_LOCKLESS is now off by default (kind attempt). The in-game A/B that could turn it on is in Still to test.

  • L1 (#issuecomment-63406), the runner's {cxx} before the check's fallback: fixed in 59b5ee5a the second way you name: test_chain_lockless.py no longer declares {cxx}, and resolves --cxx, CXX, the configured llvm-mingw (LONGSHOT_MINGW), then PATH itself. run_all.py --strict --exact tests/test_chain_lockless.py passed in that job with no compiler on PATH. The runner's own lookup is unchanged (other checks share it).
  • L2 (#issuecomment-63407), what makes the two loads one camera: fixed in 1cdc21f8: the comments at cam_tell and at the fast read now say it is replay_mu (every draw and every upscale that takes or lets go of the camera runs on the replay with it held), and that the release/acquire pair alone would not rule out a later camera's area.
  • L3 (#issuecomment-63408), simulated invalidation and a regex: partly fixed. 1cdc21f8 lets the camera go in one place, cam_drop, which stretch, fg_inputs and temporal_upscale call; the fixture runs the real cam_drop, and test_psychov35_off.py runs Off's real stretch with a camera told to the atomics and checks it lets it go and tells them (59b5ee5a). The source check now fails on any write to the camera outside cam_drop and the draw that takes it (s.cam = {}, s.cam.valid = ..., a non-const reference), not only the one spelling. fg_inputs and temporal_upscale are not run: they need the upscalers' and Vulkan's stand-ins far beyond these fixtures.
  • L4 (#issuecomment-63409), the setter's result: fixed in 59b5ee5a: the fixture returns an error when _putenv_s/setenv fails or the value read back differs, and no, empty and spaces are among the off cases.
  • L5 (#issuecomment-63410), the row: fixed in 1cdc21f8 (row) and in the description: off is the draw's decision as before (the format or mode rejection returns before the lock), empty and spaces are off, and the switch is still tested at each scene draw.
  • L6 (#issuecomment-63411), the edit part: fixed in 1cdc21f8: the frame is read before the lock only with the switch on, and cam_tell writes nothing with it off (the fixture checks both). I kept the two atomics rather than reading the replay-owned s.cam without the chain's mutex: those are plain fields written under it, so the unlocked read would be race-free only through replay_mu; the atomics keep the unlocked part to two values. The measurement part is pending, for the owner: warmed, interleaved main / off / on in Kokiri Forest and a heavy scene, Game after a temporal upscaler included (Still to test).
  • L7 (in 63412), the author's runs: pending, for the owner: renderer builds and in-game runs on Windows and Linux, Tier 1 NVIDIA, AMD and Steam Deck, camera reacquisition across presents, Off's stretch, frame-generation-only inputs, DLAA before bloom, the full suite with driver versions. Still to test lists them.
  • L8 (in 63412), the Ready to merge checklist: restored in the description with its boxes open; the Measurements table will come with the runs.
Thank you for the review (#issuecomment-63412). Pushed 1cdc21f8, rebased on main @ fd7dc40d (the branch's own commit unchanged by the rebase, `git range-diff`; main's FPS-footer change added a `route_drawn` stand-in to `tests/test_psychov35_off.py` beside this test commit's `env_on` one: both kept); test commit 59b5ee5a (its checks fail on the branch's earlier code), fix 1cdc21f8; queue job fb-2003-6 (shared with #2003). All checks named below ran in that job on this PC; nothing has run in the game. **Default:** there is no measurement in play, so `RX_VK_CHAIN_LOCKLESS` is now off by default (kind attempt). The in-game A/B that could turn it on is in Still to test. - **L1** ([#issuecomment-63406](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-63406)), the runner's `{cxx}` before the check's fallback: fixed in 59b5ee5a the second way you name: `test_chain_lockless.py` no longer declares `{cxx}`, and resolves `--cxx`, `CXX`, the configured llvm-mingw (`LONGSHOT_MINGW`), then PATH itself. `run_all.py --strict --exact tests/test_chain_lockless.py` passed in that job with no compiler on PATH. The runner's own lookup is unchanged (other checks share it). - **L2** ([#issuecomment-63407](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-63407)), what makes the two loads one camera: fixed in 1cdc21f8: the comments at `cam_tell` and at the fast read now say it is `replay_mu` (every draw and every upscale that takes or lets go of the camera runs on the replay with it held), and that the release/acquire pair alone would not rule out a later camera's area. - **L3** ([#issuecomment-63408](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-63408)), simulated invalidation and a regex: partly fixed. 1cdc21f8 lets the camera go in one place, `cam_drop`, which `stretch`, `fg_inputs` and `temporal_upscale` call; the fixture runs the real `cam_drop`, and `test_psychov35_off.py` runs Off's real `stretch` with a camera told to the atomics and checks it lets it go and tells them (59b5ee5a). The source check now fails on any write to the camera outside `cam_drop` and the draw that takes it (`s.cam = {}`, `s.cam.valid = ...`, a non-const reference), not only the one spelling. `fg_inputs` and `temporal_upscale` are not run: they need the upscalers' and Vulkan's stand-ins far beyond these fixtures. - **L4** ([#issuecomment-63409](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-63409)), the setter's result: fixed in 59b5ee5a: the fixture returns an error when `_putenv_s`/`setenv` fails or the value read back differs, and `no`, empty and spaces are among the off cases. - **L5** ([#issuecomment-63410](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-63410)), the row: fixed in 1cdc21f8 (row) and in the description: off is the draw's decision as before (the format or mode rejection returns before the lock), empty and spaces are off, and the switch is still tested at each scene draw. - **L6** ([#issuecomment-63411](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-63411)), the edit part: fixed in 1cdc21f8: the frame is read before the lock only with the switch on, and `cam_tell` writes nothing with it off (the fixture checks both). I kept the two atomics rather than reading the replay-owned `s.cam` without the chain's mutex: those are plain fields written under it, so the unlocked read would be race-free only through `replay_mu`; the atomics keep the unlocked part to two values. The measurement part is pending, for the owner: warmed, interleaved main / off / on in Kokiri Forest and a heavy scene, Game after a temporal upscaler included (Still to test). - **L7** (in 63412), the author's runs: pending, for the owner: renderer builds and in-game runs on Windows and Linux, Tier 1 NVIDIA, AMD and Steam Deck, camera reacquisition across presents, Off's stretch, frame-generation-only inputs, DLAA before bloom, the full suite with driver versions. Still to test lists them. - **L8** (in 63412), the Ready to merge checklist: restored in the description with its boxes open; the Measurements table will come with the runs.
Author
Contributor

@Beanstalk This adds RX_VK_CHAIN_LOCKLESS, off by default: with RX_VK_CHAIN_LOCKLESS=1 a scene-sized draw learns this frame's camera for the temporal upscalers and frame generation from two atomics instead of the chain's lock (gpu/vk/vk_temporal.cpp); unset, main's way. It has not run in the game on these PCs yet. Please play Kokiri Forest for three minutes with a temporal upscaler on in the Insert menu (one this farm's builds have), the PR against main on the same PC, on the PR's side with RX_VK_CHAIN_LOCKLESS=1 and with it unset, with a picture compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with Intel and the Steam Deck. The same picture (no smearing, ghosting or jitter), no crash or validation error; set, frame time p99 equal to unset or better; unset, as main's.

@Beanstalk This adds RX_VK_CHAIN_LOCKLESS, off by default: with RX_VK_CHAIN_LOCKLESS=1 a scene-sized draw learns this frame's camera for the temporal upscalers and frame generation from two atomics instead of the chain's lock (gpu/vk/vk_temporal.cpp); unset, main's way. It has not run in the game on these PCs yet. Please play Kokiri Forest for three minutes with a temporal upscaler on in the Insert menu (one this farm's builds have), the PR against main on the same PC, on the PR's side with RX_VK_CHAIN_LOCKLESS=1 and with it unset, with a picture compared with main's, on Linux with NVIDIA, Linux with AMD (RADV), Windows with Intel and the Steam Deck. The same picture (no smearing, ghosting or jitter), no crash or validation error; set, frame time p99 equal to unset or better; unset, as main's.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 1cdc21f, and the PR has changed since (84157f8), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `1cdc21f`, and the PR has changed since (`84157f8`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
dyst left a comment

Verdict: Request changes. The code is sound: under replay_mu the shortcut returns only where the draw returned before, and BeanBot's code points are fixed. But the switch now ships off only because it is unmeasured, which docs/dev/standards.md rules out. A perf change also needs a measured gain to merge, and the run the PR plans can't show one this size.

For a player: with the switch on, the replay thread does a little less work per scene-sized draw (it skips the Upscaler mode chain and an uncontended mutex once the frame's camera is taken), and the picture stays the same. The gain is real in principle and probably small: a few hundred to a couple of thousand draws a frame, each saving tens to a few hundred ns. It is not measured. The cost is two mirrored atomics, cam_tell/cam_drop, and a 241-line source-cutting check.

Reviewed: 1cdc21f8 against fd7dc40d (merge base with main; it also merges cleanly with main at 9dd41326, and main has not touched vk_temporal.cpp, vk_draw.cpp or the Off test since): gpu/vk/vk_temporal.cpp (the diff, State, Camera, temporal_note_scene_draw in full, stretch, fg_inputs, temporal_upscale, every other s.mu taker), the switches.def row, tests/test_chain_lockless.py and tests/test_psychov35_off.py in full; the caller in vk_draw.cpp, texture_frame()/frame_no in vk_texture.cpp and the present's replay_mu hold in vk_replay.cpp, env_on in longshot_env.h, the runner's RUN_ALL_ARGS handling. Nothing run (a code review). Re-review after BeanBot's review of ec735e07, which is no longer on the branch; I judged its points from the reply and the current code.
Fixed in this review: nothing.
Checked and fine:

  • The shortcut returns in a subset of the cases where the old code returned. cam_frame == now && area <= cam_area holds only while s.cam is valid, of this frame and at least that large, and then the test under the lock returns too. Before that, a format or mode rejection returned anyway. No draw that used to take the camera skips it now.
  • The invariant the comments name holds today. Every writer of s.cam holds replay_mu: the capturing draw (draw() in vk_draw.cpp), and stretch, fg_inputs and temporal_upscale (called from the draw path), so the two loads are of one camera. The frame counter it compares against (frame_no++ in texture_frame) also advances under replay_mu, in do_present.
  • Memory ordering: area stored before frame (release), frame loaded before area (acquire, the && sequences them). Even without replay_mu, a reader that sees the frame sees that camera's area or a later one. A mix of two cameras in the same frame still gives the answer the lock would give at the second load. Release/acquire costs nothing on x86 (including the Deck).
  • s.cam is written only in cam_drop and the capturing draw (it ends with cam_tell; it has no early return between Camera& k = s.cam and that call). The source check now catches s.cam = {}, field writes and other references.
  • Off: nothing is read before the mode test and nothing is written (cam_tell returns first), so the only cost is a static-bool test per scene draw.
  • The test fails if the fast path is removed (on: on == !kept) or if cam_tell is dropped from cam_drop (a draw would return with no camera). test_psychov35_off.py runs Off's real stretch and checks it lets the camera go and tells the atomics.
  • BeanBot's L1 (the check resolves its own compiler, RUN_ALL_ARGS = []), L2 (the comments name replay_mu), L4 (setter result and read-back checked; no, empty and spaces are off cases), L5 (the row) and L8 (checklist restored) are fixed in the code and description. L3 is fixed far enough: there is one place that lets the camera go, it is run for stretch, and the regex covers the other ways to write the camera.
  • Assisted-by: trailers on all three commits.

Blocking (to change before merge)

  1. gpu/vk/switches.def:297 / gpu/vk/vk_temporal.cpp:339: the switch was turned off in 1cdc21f8 only because it is unmeasured. docs/dev/standards.md, Switches: "It ships at that value from the branch's first push, WIP or not ... Never off just because it is new or unmeasured." Testers and anyone else running the branch get main's path, so they test nothing. Ship it on (env_on_or("RX_VK_CHAIN_LOCKLESS", 1), kind kill, the row and title saying =0 restores the old decision), and turn it off or drop the change if the A/B goes against it. (BeanBot's "no measurements to justify enabling it by default" is answered by measuring, not by shipping it off.)
  2. Measurements: "No measured gain, no merge", and the planned A/B can't find this gain. It compares average FPS, 1% lows and p99 frame time, which are bound by the GPU and present. A saving of tens to hundreds of µs on the replay thread falls inside their spread. Measure what the change saves: the replay's CPU time per frame (main, =0, on; warmed and interleaved, per the measure skill), and how many scene draws a frame take the shortcut against those that reach the lock. If it is within the spread, the change doesn't earn its code.

Suggestions (the author may take or leave)

  • The mirror buys little over reading s.cam directly. The pair is consistent only because of replay_mu (the comment says so), and on that same ground a read of s.cam.valid/frame/width/height before the mode test, without s.mu, is race-free: every writer holds replay_mu. That drops the two atomics, cam_tell, the off-path write rule and most of the regex check. The atomics avoid formal UB only if a writer ever leaves replay_mu, and then the shortcut would be wrong anyway. Worth weighing once the gain is known.
  • tests/test_chain_lockless.py:63: under_lock is the fixture's own copy of the test under the lock. Cut the condition from the source (between std::lock_guard lk(s.mu); and return; // (the largest one of the frame wins)), so a change there can't leave the shortcut out of step without the check noticing.

Testing: source checks on the author's Windows PC (i7-9700, RTX 4060): the two edited checks and the switch table pass, and the 8 failures named also fail on main. CI is still blocked. Nothing has run in the game. The farm request (65036) asks for a picture check and p99 frame time, on and unset, on Linux NVIDIA/AMD, Windows Intel and the Deck. The change has no vendor, driver or OS path (pure CPU logic under the replay's lock), so it is unlikely to differ by hardware. The farm's frame-time criterion can't show a gain this size, and it leaves out Off's stretch, frame-generation-only inputs and Game after a temporal upscaler. The author's own measurement (point 2) should come first.
Overlaps and merge order: no open PR shares its code files apart from the usual switches.def row (no conflict with main today). #2053 changes what the present holds but lets go sync_order_mu and the replay pin, not replay_mu, so the invariant this PR rests on still holds with both merged. Either order.

**Verdict: Request changes.** The code is sound: under `replay_mu` the shortcut returns only where the draw returned before, and BeanBot's code points are fixed. But the switch now ships off only because it is unmeasured, which docs/dev/standards.md rules out. A perf change also needs a measured gain to merge, and the run the PR plans can't show one this size. For a player: with the switch on, the replay thread does a little less work per scene-sized draw (it skips the Upscaler mode chain and an uncontended mutex once the frame's camera is taken), and the picture stays the same. The gain is real in principle and probably small: a few hundred to a couple of thousand draws a frame, each saving tens to a few hundred ns. It is not measured. The cost is two mirrored atomics, `cam_tell`/`cam_drop`, and a 241-line source-cutting check. **Reviewed:** 1cdc21f8 against fd7dc40d (merge base with main; it also merges cleanly with main at 9dd41326, and main has not touched `vk_temporal.cpp`, `vk_draw.cpp` or the Off test since): `gpu/vk/vk_temporal.cpp` (the diff, `State`, `Camera`, `temporal_note_scene_draw` in full, `stretch`, `fg_inputs`, `temporal_upscale`, every other `s.mu` taker), the `switches.def` row, `tests/test_chain_lockless.py` and `tests/test_psychov35_off.py` in full; the caller in `vk_draw.cpp`, `texture_frame()`/`frame_no` in `vk_texture.cpp` and the present's `replay_mu` hold in `vk_replay.cpp`, `env_on` in `longshot_env.h`, the runner's `RUN_ALL_ARGS` handling. Nothing run (a code review). Re-review after BeanBot's review of ec735e07, which is no longer on the branch; I judged its points from the reply and the current code. **Fixed in this review:** nothing. **Checked and fine:** - The shortcut returns in a subset of the cases where the old code returned. `cam_frame == now && area <= cam_area` holds only while `s.cam` is valid, of this frame and at least that large, and then the test under the lock returns too. Before that, a format or mode rejection returned anyway. No draw that used to take the camera skips it now. - The invariant the comments name holds today. Every writer of `s.cam` holds `replay_mu`: the capturing draw (`draw()` in `vk_draw.cpp`), and `stretch`, `fg_inputs` and `temporal_upscale` (called from the draw path), so the two loads are of one camera. The frame counter it compares against (`frame_no++` in `texture_frame`) also advances under `replay_mu`, in `do_present`. - Memory ordering: area stored before frame (release), frame loaded before area (acquire, the `&&` sequences them). Even without `replay_mu`, a reader that sees the frame sees that camera's area or a later one. A mix of two cameras in the same frame still gives the answer the lock would give at the second load. Release/acquire costs nothing on x86 (including the Deck). - `s.cam` is written only in `cam_drop` and the capturing draw (it ends with `cam_tell`; it has no early return between `Camera& k = s.cam` and that call). The source check now catches `s.cam = {}`, field writes and other references. - Off: nothing is read before the mode test and nothing is written (`cam_tell` returns first), so the only cost is a static-bool test per scene draw. - The test fails if the fast path is removed (on: `on == !kept`) or if `cam_tell` is dropped from `cam_drop` (a draw would return with no camera). `test_psychov35_off.py` runs Off's real `stretch` and checks it lets the camera go and tells the atomics. - BeanBot's L1 (the check resolves its own compiler, `RUN_ALL_ARGS = []`), L2 (the comments name `replay_mu`), L4 (setter result and read-back checked; `no`, empty and spaces are off cases), L5 (the row) and L8 (checklist restored) are fixed in the code and description. L3 is fixed far enough: there is one place that lets the camera go, it is run for `stretch`, and the regex covers the other ways to write the camera. - `Assisted-by:` trailers on all three commits. **Blocking** (to change before merge) 1. `gpu/vk/switches.def:297` / `gpu/vk/vk_temporal.cpp:339`: the switch was turned off in 1cdc21f8 only because it is unmeasured. docs/dev/standards.md, Switches: "It ships at that value from the branch's first push, WIP or not ... Never off just because it is new or unmeasured." Testers and anyone else running the branch get main's path, so they test nothing. Ship it on (`env_on_or("RX_VK_CHAIN_LOCKLESS", 1)`, kind `kill`, the row and title saying `=0` restores the old decision), and turn it off or drop the change if the A/B goes against it. (BeanBot's "no measurements to justify enabling it by default" is answered by measuring, not by shipping it off.) 2. Measurements: "No measured gain, no merge", and the planned A/B can't find this gain. It compares average FPS, 1% lows and p99 frame time, which are bound by the GPU and present. A saving of tens to hundreds of µs on the replay thread falls inside their spread. Measure what the change saves: the replay's CPU time per frame (main, `=0`, on; warmed and interleaved, per the measure skill), and how many scene draws a frame take the shortcut against those that reach the lock. If it is within the spread, the change doesn't earn its code. **Suggestions** (the author may take or leave) - The mirror buys little over reading `s.cam` directly. The pair is consistent only because of `replay_mu` (the comment says so), and on that same ground a read of `s.cam.valid/frame/width/height` before the mode test, without `s.mu`, is race-free: every writer holds `replay_mu`. That drops the two atomics, `cam_tell`, the off-path write rule and most of the regex check. The atomics avoid formal UB only if a writer ever leaves `replay_mu`, and then the shortcut would be wrong anyway. Worth weighing once the gain is known. - `tests/test_chain_lockless.py:63`: `under_lock` is the fixture's own copy of the test under the lock. Cut the condition from the source (between `std::lock_guard lk(s.mu);` and `return; // (the largest one of the frame wins)`), so a change there can't leave the shortcut out of step without the check noticing. **Testing:** source checks on the author's Windows PC (i7-9700, RTX 4060): the two edited checks and the switch table pass, and the 8 failures named also fail on main. CI is still blocked. Nothing has run in the game. The farm request (65036) asks for a picture check and p99 frame time, on and unset, on Linux NVIDIA/AMD, Windows Intel and the Deck. The change has no vendor, driver or OS path (pure CPU logic under the replay's lock), so it is unlikely to differ by hardware. The farm's frame-time criterion can't show a gain this size, and it leaves out Off's stretch, frame-generation-only inputs and Game after a temporal upscaler. The author's own measurement (point 2) should come first. **Overlaps and merge order:** no open PR shares its code files apart from the usual `switches.def` row (no conflict with main today). https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2053 changes what the present holds but lets go `sync_order_mu` and the replay pin, not `replay_mu`, so the invariant this PR rests on still holds with both merged. Either order.
@ -294,6 +294,7 @@ SW(RX_VK_CAP_FREE_ASYNC, kill, bool, "on: a capture buffer past the spares is de
SW(RX_VK_CAP_MIN_MB, tune, int, "2 MB", "The smallest capture buffer size class in MB; 16 is the old behaviour.")
SW(RX_VK_CAP_SPARE_MB, hw, int, "32 MB of spare capture buffers on cards allowing 6.5 GB or less; no byte limit elsewhere", "Sets how many MB of spare capture buffers are kept for reuse; 0 means no limit, as before.")
SW(RX_VK_CASCADE_BIAS, tune, string, "0,0: nothing added", "Adds a depth bias <units>,<slope> to the sun's shadow cascades.")
SW(RX_VK_CHAIN_LOCKLESS, attempt, bool, "off: a scene draw decides as before (a target the Upscaler's format or mode rejects returns before the lock; the others ask under the temporal chain's lock whether the frame's camera is taken)", "1 (any value but an empty one, 0, false, off or no, in any case, spaces around it not counted): a scene draw first reads two atomics, which the places that take or let go of the camera write, and returns without the mode and the lock when this frame's camera, of a target at least as large, is taken. Off, the atomics are neither read nor written (the switch is still tested at each scene draw). Not measured in play. Read once, at its first use (HOS_AB cannot alternate it).")
Member

Blocking 1: turned off only because it is unmeasured. standards.md, Switches: it ships at its intended value from the first push, and is never off just because it is new or unmeasured. Ship it on (kind kill, =0 the old decision), then let the A/B decide.

Blocking 1: turned off only because it is unmeasured. standards.md, Switches: it ships at its intended value from the first push, and is never off just because it is new or unmeasured. Ship it on (kind kill, =0 the old decision), then let the A/B decide.
@ -326,0 +336,4 @@
constexpr uint64_t kNoCamera = ~0ull;
bool chain_lockless() {
static const bool on = [] {
const bool v = env_on("RX_VK_CHAIN_LOCKLESS");
Member

Blocking 1: env_on_or("RX_VK_CHAIN_LOCKLESS", 1) once it ships on, and the log line to match.

Blocking 1: env_on_or("RX_VK_CHAIN_LOCKLESS", 1) once it ships on, and the log line to match.
@ -948,0 +987,4 @@
// (longshot) RX_VK_CHAIN_LOCKLESS=1: this frame's camera, of a target at least this large, is taken: what the test under the
// lock below says, here without it (chain_lockless, above). The two loads are of one camera as replay_mu holds every
// writer off (cam_tell)
if (chain_lockless() && s.cam_frame.load(std::memory_order_acquire) == texture_frame_no() &&
Member

Sound under replay_mu (checked: every s.cam writer and frame_no++ hold it). Suggestion: on that same ground, a direct read of s.cam here (without s.mu) is race-free and drops the mirror. Blocking 2: measure replay CPU time per frame and the shortcut's hit count; FPS/p99 can't show a gain this size.

Sound under replay_mu (checked: every s.cam writer and frame_no++ hold it). Suggestion: on that same ground, a direct read of s.cam here (without s.mu) is race-free and drops the mirror. Blocking 2: measure replay CPU time per frame and the shortcut's hit count; FPS/p99 can't show a gain this size.
@ -0,0 +60,4 @@
MAIN = r'''
/// The test under the lock (vk_temporal.cpp, after it): this frame's camera, of a target at least this large
bool under_lock(uint32_t w, uint32_t h) {
Member

Suggestion: under_lock is the fixture's copy of the real test under the lock; cut the condition from vk_temporal.cpp so the two can't drift apart unnoticed.

Suggestion: under_lock is the fixture's copy of the real test under the lock; cut the condition from vk_temporal.cpp so the two can't drift apart unnoticed.
siantm force-pushed perf/vk-chain-lockless from 1cdc21f877
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 84157f837e
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
beanstalk/approval waiting for a BigBean's 👍 on the request
2026-11-21 10:38:53 +00:00
Compare
Author
Contributor

@Beanstalk This makes a scene-sized draw learn this frame's camera for the temporal upscalers and frame generation from two atomics instead of the chain's lock (gpu/vk/vk_temporal.cpp), on by default; RX_VK_CHAIN_LOCKLESS=0 turns it off. Its gain is measured on the author's PC; frame time cannot show it, so this run checks the picture. This head is on main 9dd41326: please compare with main at that merge base. Please play Kokiri Forest for one minute in each Insert-menu upscaling setting that reaches this code: a temporal upscaler this farm's builds have, Off (the stretch), frame generation alone, and Game after a temporal upscaler; the PR's build with the switch unset against RX_VK_CHAIN_LOCKLESS=0, with a picture in each compared, on Windows with NVIDIA and on Linux with AMD (RADV). The same picture in every setting (no smearing, ghosting or jitter), no crash or validation error.

@Beanstalk This makes a scene-sized draw learn this frame's camera for the temporal upscalers and frame generation from two atomics instead of the chain's lock (gpu/vk/vk_temporal.cpp), on by default; RX_VK_CHAIN_LOCKLESS=0 turns it off. Its gain is measured on the author's PC; frame time cannot show it, so this run checks the picture. This head is on main 9dd41326: please compare with main at that merge base. Please play Kokiri Forest for one minute in each Insert-menu upscaling setting that reaches this code: a temporal upscaler this farm's builds have, Off (the stretch), frame generation alone, and Game after a temporal upscaler; the PR's build with the switch unset against RX_VK_CHAIN_LOCKLESS=0, with a picture in each compared, on Windows with NVIDIA and on Linux with AMD (RADV). The same picture in every setting (no smearing, ghosting or jitter), no crash or validation error.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
siantm changed title from WIP: perf(vk): a scene draw learns the frame's camera is taken without the chain's lock (RX_VK_CHAIN_LOCKLESS, off by default) to WIP: perf(vk): a scene draw learns the frame's camera is taken without the chain's lock (RX_VK_CHAIN_LOCKLESS) 2026-11-21 10:49:40 +00:00
Author
Contributor

Thank you for the review (#issuecomment-65670). Pushed 84157f83, rebased on main @ 9dd41326 (the branch's earlier commits unchanged by the rebase, git range-diff): test ae8ab7a4, default ae476851, test 9003fc39, counts 84157f83. The checks named below ran in job dyl-2005 of this PC's queue (Windows 11, llvm-mingw clang 23): test_chain_lockless.py, test_psychov35_off.py and test_switch_table.py pass at the head, test_chain_lockless.py fails at each test commit, and vk_temporal.cpp and vk_draw.cpp compile with the game build's commands. The --changed checks and their failures on main are in job dyh-2005, queued, and the description will give them. Nothing has run in the game.

  • Blocking 1 (#issuecomment-65666, switches.def:297, and #issuecomment-65667, vk_temporal.cpp:339): you are right. RX_VK_CHAIN_LOCKLESS is on by default again, restored per docs/dev/standards.md (Switches), in ae476851: env_on_or(..., 1), kind kill, =0 (or empty, false, off, no) gives the draw's decision as before; the row, the title, the comments and the log line match. test_chain_lockless.py runs unset as on (ae8ab7a4).
  • Blocking 2 (measure what it saves; #issuecomment-65668): Still to test now measures the replay's CPU time a frame (vk: a frame's replay time (ms)), main, =0 and unset, warmed and interleaved, with FPS, 1% lows and p99 only beside it. For the shortcut's share, 84157f83 counts the scene draws at the camera's test with RX_VK_PROF_FINE=1 (the draw path's fine profile, off by default; one relaxed atomic increment a scene draw when on): the frame log gains vk: a frame (fine): scene draws at the camera's test: <n> returned without the chain's lock (RX_VK_CHAIN_LOCKLESS), <n> went on to the lock, both a frame. test_chain_lockless.py (9003fc39) checks each fixture draw is counted once by the way it went, the line gives both counts a frame and then nothing new, and nothing is counted or logged with it unset or 0; it fails at the test commit (no counts in the source) and passes at the head. If the A/B shows no gain beyond the spread, the change is dropped.
  • tests/test_chain_lockless.py:58 (#issuecomment-65669): taken in ae8ab7a4: under_lock is now cut from temporal_note_scene_draw, from std::lock_guard lk(s.mu); to the return it makes, and the check fails if that is no longer one if before the return.
  • Reading s.cam directly instead of the mirror: kept for now, as you suggest weighing it once the gain is known. If the A/B earns the change its place, I'll try the direct read under replay_mu and drop cam_tell, the off-path rule and most of the source check.
  • The farm request: made again for this head (#issuecomment-65989) as a picture check only, unset against =0, with a temporal upscaler, Off's stretch, frame generation alone and Game after a temporal upscaler; the gain is to be measured on this PC first.
Thank you for the review (#issuecomment-65670). Pushed 84157f83, rebased on main @ 9dd41326 (the branch's earlier commits unchanged by the rebase, `git range-diff`): test ae8ab7a4, default ae476851, test 9003fc39, counts 84157f83. The checks named below ran in job `dyl-2005` of this PC's queue (Windows 11, llvm-mingw clang 23): `test_chain_lockless.py`, `test_psychov35_off.py` and `test_switch_table.py` pass at the head, `test_chain_lockless.py` fails at each test commit, and `vk_temporal.cpp` and `vk_draw.cpp` compile with the game build's commands. The `--changed` checks and their failures on main are in job `dyh-2005`, queued, and the description will give them. Nothing has run in the game. - **Blocking 1** ([#issuecomment-65666](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-65666), `switches.def:297`, and [#issuecomment-65667](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-65667), `vk_temporal.cpp:339`): you are right. `RX_VK_CHAIN_LOCKLESS` is on by default again, restored per docs/dev/standards.md (Switches), in ae476851: `env_on_or(..., 1)`, kind `kill`, `=0` (or empty, `false`, `off`, `no`) gives the draw's decision as before; the row, the title, the comments and the log line match. `test_chain_lockless.py` runs unset as on (ae8ab7a4). - **Blocking 2** (measure what it saves; [#issuecomment-65668](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-65668)): Still to test now measures the replay's CPU time a frame (`vk: a frame's replay time (ms)`), main, `=0` and unset, warmed and interleaved, with FPS, 1% lows and p99 only beside it. For the shortcut's share, 84157f83 counts the scene draws at the camera's test with `RX_VK_PROF_FINE=1` (the draw path's fine profile, off by default; one relaxed atomic increment a scene draw when on): the frame log gains `vk: a frame (fine): scene draws at the camera's test: <n> returned without the chain's lock (RX_VK_CHAIN_LOCKLESS), <n> went on to the lock`, both a frame. `test_chain_lockless.py` (9003fc39) checks each fixture draw is counted once by the way it went, the line gives both counts a frame and then nothing new, and nothing is counted or logged with it unset or `0`; it fails at the test commit (no counts in the source) and passes at the head. If the A/B shows no gain beyond the spread, the change is dropped. - **`tests/test_chain_lockless.py:58`** ([#issuecomment-65669](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-65669)): taken in ae8ab7a4: `under_lock` is now cut from `temporal_note_scene_draw`, from `std::lock_guard lk(s.mu);` to the return it makes, and the check fails if that is no longer one `if` before the return. - **Reading `s.cam` directly instead of the mirror**: kept for now, as you suggest weighing it once the gain is known. If the A/B earns the change its place, I'll try the direct read under `replay_mu` and drop `cam_tell`, the off-path rule and most of the source check. - **The farm request**: made again for this head ([#issuecomment-65989](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2005#issuecomment-65989)) as a picture check only, unset against `=0`, with a temporal upscaler, Off's stretch, frame generation alone and Game after a temporal upscaler; the gain is to be measured on this PC first.
Author
Contributor

@Beanstalk One correction to my request 65989 above, for its picture point: please take each picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between, and take the main-against-itself picture from the same point. A picture taken during the load's fade-in from black is not comparable: run 70269 on #2156 caught the fade in 3 of 4 starts.

@Beanstalk One correction to my request 65989 above, for its picture point: please take each picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between, and take the main-against-itself picture from the same point. A picture taken during the load's fade-in from black is not comparable: run 70269 on #2156 caught the fade in 3 of 4 starts.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
beanstalk/approval waiting for a BigBean's 👍 on the request
This pull request has changes conflicting with the target branch.
  • gpu/vk/vk_temporal.cpp
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vk-chain-lockless:siantm-perf/vk-chain-lockless'
git switch 'siantm-perf/vk-chain-lockless'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2005
No description provided.