WIP: perf(vk): the present lets the replay's order lock go once the frame's copy is on the queue (RX_VK_PRESENT_UNLOCKED=0 to disable) #2053

Draft
siantm wants to merge 1 commit from siantm/Longshot:perf/vk-present-unlocked into main
Contributor

Summary

With the replay on the submitting thread (Threaded rendering off), present() held the replay's order lock
(sync_order_mu) and the replay's core (ReplayPin) until it returned: over the hand-over to the presenter thread
(which waits there for the frame before's present) and over the frame's pacing wait after it (NVIDIA Reflex's sleep,
AMD Anti-Lag's input wait). Meanwhile no other game thread could submit, take or wait for a queue's fence, or let
stopped work go on.

What the lock protects is fixed once the frame's copy into the window is submitted: the copy is on the queue behind the
frame's work and ahead of anything replayed later. present_image now lets the lock and the pin go right after that
submit (present_order_release), before the hand-over; a present that ends earlier (no window, a deferred copy, frame
generation) keeps both until present() returns, as before. Reflex's sleep leaves the frame unmarked until it wakes, so
the other threads' submits during it go untagged instead of as the frame just shown (gpu/vk/vk_reflex.cpp). The render
thread's path holds no order lock at its present and is unchanged. The result expected: the game's other threads no
longer wait for the present's hand-over and pacing.

The switch: RX_VK_PRESENT_UNLOCKED (new, a kill switch, bool, its row in gpu/vk/switches.def), on by default as the
branch shipped it, read once; =0 holds both until the present returns, as main does.

From bd3ea307 on exp/x86-asm-sync (its replay-parts work, with 4eed88f7's Reflex line).

Read first: present_order_release, present_image and present in gpu/vk/vk_replay.cpp, reflex_sleep in
gpu/vk/vk_reflex.cpp, then tests/test_present_unlocked.py.

Testing

Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head 3edef0f6 on main 8aa74983 (rebased from 4c0c0b7a on 75317e1f). Build job rb-2053-2054 of this PC's job queue, the checks in a hidden console: tests/run_all.py --strict --exact on tests/test_present_unlocked.py, tests/test_present_acquire_ahead.py and tests/test_switch_table.py (log rb2053-own-head.log): 3 checks, 3 passed, 0 failed, 0 skipped; its own check passes, the switch's read included (fresh processes). The syntax compile of gpu/vk/vk_replay.cpp and gpu/vk/vk_reflex.cpp with the game build's own commands passes (log rb2053-syntax-head.log). The checks --changed picks were not run again at this head.

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

Still to test:

  • Windows 11, i7-9700, RTX 4060 (this PC): Kokiri Forest, Threaded rendering off, play three minutes with NVIDIA Reflex on and once off: main @ 8aa74983, this branch with RX_VK_PRESENT_UNLOCKED=0 and this branch with it unset (on), each warmed up a minute in the scene first, interleaved (ABBA), at least two runs each, expecting the same picture, no FATAL, no stutter or hang at the present, and a median frame time unset lower than with RX_VK_PRESENT_UNLOCKED=0 and than main, and RX_VK_PRESENT_UNLOCKED=0 the same as main (by hand)
  • Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: Kokiri Forest, Threaded rendering off, play three minutes: main @ 8aa74983, this branch with RX_VK_PRESENT_UNLOCKED=0 and this branch with it unset (on), warmed up, ABBA, expecting the same picture, no FATAL and no hang, and a median frame time unset lower than with RX_VK_PRESENT_UNLOCKED=0 and than main, and RX_VK_PRESENT_UNLOCKED=0 the same as main (@Beanstalk linux+nvidia, linux+amd, windows+amd, windows+intel, steamdeck: Kokiri Forest three minutes, Threaded rendering off: main @ 8aa74983, this branch with RX_VK_PRESENT_UNLOCKED=0 and this branch with it unset (on), warmed up, ABBA, the log, frame times and a screenshot)
  • Linux: build the renderer and run python3 -I -B tests/test_present_unlocked.py, expecting PASS (by hand)

Measurements

Verdict: not measured: no micro-benchmark of this port and no run in the game on this PC yet; the in-game A/B is
in Still to test. RX_VK_PRESENT_UNLOCKED ships on, as the branch shipped it; no measurement chose that default yet, the in-game A/B in Still to test does.

zeldaootr's run on a Steam Deck OLED (#issuecomment-71560), a third party's run, not ours, as posted. It ran the earlier head 4c0c0b7a, merged into main 9dd41326. Besides moving onto main 8aa74983, the rebase to 3edef0f6 changed tests only: outside tests/ its added and removed lines are 4c0c0b7a's, with only their context moved by main (present_image_with_trial, present_tagged, present_out's new arguments), so the run stands for this head's renderer change, measured over main 9dd41326 rather than 8aa74983, which this head sits on.

Before: main @ 9dd41326 After: this PR @ 4c0c0b7a (merged into main 9dd41326) Δ
fps (each run) 43.6 / 44.1 / 43.9 (median 43.9) 44.0 / 43.7 / 43.8 (median 43.8) -0.3%
1% low fps (1000 / p99) 32.8 32.9 +0.3%
median frame time 22.39 ms 22.35 ms -0.04 ms
p99 frame time 30.50 ms 30.41 ms -0.09 ms
frames of 50 ms or more (each run) 1 / 0 / 0 0 / 0 / 1

RX_VK_PRESENT_UNLOCKED=0 against unset on the PR's build, three pairs: 44.1 fps against 44.0 on the median (+0.3%), median frame time 22.57 against 22.53 ms. dev.py ab's verdict on both: no difference shown, within the runs' spread. The unset runs logged the switch's line ending on, the =0 runs the same line ending off; no FATAL, device-lost, VK_ERROR, validation or hang line in his 12 logs.

Hardware and settings: Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel, GPU clock set to 1600 MHz, headless; Minimum, render 50 % (640x400), output 1280x800, uncapped, V-Sync and frame generation off; Threaded rendering at Auto, off on the Deck. Method: dev.py ab (with a local change to compare two prebuilt runtimes), Kokiri Forest, three interleaved pairs of 180 s after the warm-up, the median. Its own stated limits: main 9dd41326 rather than 75317e1f as the base; Link standing where the scene puts him, not three minutes of play, in ABAB order rather than ABBA; no picture judged and no screenshot (headless); the Deck has no Reflex; in this scene the Deck's runs agree within about 1 %, so a change of 1-2 % would show only as a hint; the switch is not read through HOS_AB, so no in-run comparison.

Risks

What could break: another thread's submit replayed between the frame's work and its copy into the window (a frame
shown with the next one's work in it), or the lock released twice (an abort) or never (a hang). The lock is let go only
after the copy's submit, and the test runs present()'s hold through the real ReplayPin and
present_order_release (let go at the copy, held without one, a nested pin, =0). AMD Anti-Lag's wait is covered by
reading the order only. Turn it off with RX_VK_PRESENT_UNLOCKED=0. Renderer code: the runtime is rebuilt; nothing
changes for players' saves, options or caches.

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.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • 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.
  • 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.
  • 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 With the replay on the submitting thread (Threaded rendering off), `present()` held the replay's order lock (`sync_order_mu`) and the replay's core (`ReplayPin`) until it returned: over the hand-over to the presenter thread (which waits there for the frame before's present) and over the frame's pacing wait after it (NVIDIA Reflex's sleep, AMD Anti-Lag's input wait). Meanwhile no other game thread could submit, take or wait for a queue's fence, or let stopped work go on. What the lock protects is fixed once the frame's copy into the window is submitted: the copy is on the queue behind the frame's work and ahead of anything replayed later. `present_image` now lets the lock and the pin go right after that submit (`present_order_release`), before the hand-over; a present that ends earlier (no window, a deferred copy, frame generation) keeps both until `present()` returns, as before. Reflex's sleep leaves the frame unmarked until it wakes, so the other threads' submits during it go untagged instead of as the frame just shown (`gpu/vk/vk_reflex.cpp`). The render thread's path holds no order lock at its present and is unchanged. The result expected: the game's other threads no longer wait for the present's hand-over and pacing. The switch: `RX_VK_PRESENT_UNLOCKED` (new, a kill switch, bool, its row in `gpu/vk/switches.def`), on by default as the branch shipped it, read once; `=0` holds both until the present returns, as main does. From bd3ea307 on `exp/x86-asm-sync` (its replay-parts work, with 4eed88f7's Reflex line). Read first: `present_order_release`, `present_image` and `present` in `gpu/vk/vk_replay.cpp`, `reflex_sleep` in `gpu/vk/vk_reflex.cpp`, then `tests/test_present_unlocked.py`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head `3edef0f6` on main `8aa74983` (rebased from `4c0c0b7a` on `75317e1f`). Build job `rb-2053-2054` of this PC's job queue, the checks in a hidden console: `tests/run_all.py --strict --exact` on `tests/test_present_unlocked.py`, `tests/test_present_acquire_ahead.py` and `tests/test_switch_table.py` (log `rb2053-own-head.log`): 3 checks, 3 passed, 0 failed, 0 skipped; its own check passes, the switch's read included (fresh processes). The syntax compile of `gpu/vk/vk_replay.cpp` and `gpu/vk/vk_reflex.cpp` with the game build's own commands passes (log `rb2053-syntax-head.log`). The checks `--changed` picks were not run again at this head. **It has NOT run in the game on this PC yet.** **Still to test:** - Windows 11, i7-9700, RTX 4060 (this PC): Kokiri Forest, Threaded rendering off, play three minutes with NVIDIA Reflex on and once off: main @ 8aa74983, this branch with `RX_VK_PRESENT_UNLOCKED=0` and this branch with it unset (on), each warmed up a minute in the scene first, interleaved (ABBA), at least two runs each, expecting the same picture, no FATAL, no stutter or hang at the present, and a median frame time unset lower than with `RX_VK_PRESENT_UNLOCKED=0` and than main, and `RX_VK_PRESENT_UNLOCKED=0` the same as main (by hand) - Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: Kokiri Forest, Threaded rendering off, play three minutes: main @ 8aa74983, this branch with `RX_VK_PRESENT_UNLOCKED=0` and this branch with it unset (on), warmed up, ABBA, expecting the same picture, no FATAL and no hang, and a median frame time unset lower than with `RX_VK_PRESENT_UNLOCKED=0` and than main, and `RX_VK_PRESENT_UNLOCKED=0` the same as main (@Beanstalk linux+nvidia, linux+amd, windows+amd, windows+intel, steamdeck: Kokiri Forest three minutes, Threaded rendering off: main @ 8aa74983, this branch with RX_VK_PRESENT_UNLOCKED=0 and this branch with it unset (on), warmed up, ABBA, the log, frame times and a screenshot) - Linux: build the renderer and run `python3 -I -B tests/test_present_unlocked.py`, expecting PASS (by hand) ## Measurements **Verdict:** not measured: no micro-benchmark of this port and no run in the game on this PC yet; the in-game A/B is in Still to test. `RX_VK_PRESENT_UNLOCKED` ships on, as the branch shipped it; no measurement chose that default yet, the in-game A/B in Still to test does. zeldaootr's run on a Steam Deck OLED ([#issuecomment-71560](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2053#issuecomment-71560)), a third party's run, not ours, as posted. It ran the earlier head 4c0c0b7a, merged into main 9dd41326. Besides moving onto main 8aa74983, the rebase to 3edef0f6 changed tests only: outside `tests/` its added and removed lines are 4c0c0b7a's, with only their context moved by main (`present_image_with_trial`, `present_tagged`, `present_out`'s new arguments), so the run stands for this head's renderer change, measured over main 9dd41326 rather than 8aa74983, which this head sits on. | | Before: main @ 9dd41326 | After: this PR @ 4c0c0b7a (merged into main 9dd41326) | Δ | |---|---|---|---| | fps (each run) | 43.6 / 44.1 / 43.9 (median 43.9) | 44.0 / 43.7 / 43.8 (median 43.8) | -0.3% | | 1% low fps (1000 / p99) | 32.8 | 32.9 | +0.3% | | median frame time | 22.39 ms | 22.35 ms | -0.04 ms | | p99 frame time | 30.50 ms | 30.41 ms | -0.09 ms | | frames of 50 ms or more (each run) | 1 / 0 / 0 | 0 / 0 / 1 | | `RX_VK_PRESENT_UNLOCKED=0` against unset on the PR's build, three pairs: 44.1 fps against 44.0 on the median (+0.3%), median frame time 22.57 against 22.53 ms. `dev.py ab`'s verdict on both: no difference shown, within the runs' spread. The unset runs logged the switch's line ending `on`, the `=0` runs the same line ending `off`; no `FATAL`, device-lost, `VK_ERROR`, validation or hang line in his 12 logs. Hardware and settings: Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel, GPU clock set to 1600 MHz, headless; Minimum, render 50 % (640x400), output 1280x800, uncapped, V-Sync and frame generation off; Threaded rendering at Auto, off on the Deck. Method: `dev.py ab` (with a local change to compare two prebuilt runtimes), Kokiri Forest, three interleaved pairs of 180 s after the warm-up, the median. Its own stated limits: main 9dd41326 rather than 75317e1f as the base; Link standing where the scene puts him, not three minutes of play, in ABAB order rather than ABBA; no picture judged and no screenshot (headless); the Deck has no Reflex; in this scene the Deck's runs agree within about 1 %, so a change of 1-2 % would show only as a hint; the switch is not read through `HOS_AB`, so no in-run comparison. ## Risks What could break: another thread's submit replayed between the frame's work and its copy into the window (a frame shown with the next one's work in it), or the lock released twice (an abort) or never (a hang). The lock is let go only after the copy's submit, and the test runs `present()`'s hold through the real `ReplayPin` and `present_order_release` (let go at the copy, held without one, a nested pin, `=0`). AMD Anti-Lag's wait is covered by reading the order only. Turn it off with `RX_VK_PRESENT_UNLOCKED=0`. Renderer code: the runtime is rebuilt; nothing changes for players' saves, options or caches. ## 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. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [ ] Measured against `main`, or Measurements says why there is nothing to measure. - [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`. - [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. - [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): the present lets the replay's order lock go once the frame's copy is on the queue (RX_VK_PRESENT_UNLOCKED)
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 10s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
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
4c0c0b7a65
With the replay on the submitting thread (Threaded rendering off), present() held sync_order_mu and the replay's core
(ReplayPin) until it returned: over the present's hand-over to the presenter thread (present_out waits there for the frame
before's present, one out at most) and over the frame's pacing wait after it (NVIDIA Reflex's sleep, AMD Anti-Lag's input
wait, do_present's ReflexSleep). Meanwhile no other game thread could submit, take or wait for a queue's fence, or let
stopped work go on.

What the lock protects (the stopped queues and the burst, the fence values handed out, one replaying thread at a time) is
fixed once the frame's copy into the window is submitted: the copy is on the queue behind the frame's work and ahead of
anything replayed later. present_image now lets the lock and the pin go right after that submit
(present_order_release), before the hand-over; a present that ends earlier (no window, a deferred copy, frame generation)
keeps both until present() returns, as before. Reflex's sleep leaves the frame unmarked until it wakes, so the other
threads' submits during it go untagged instead of as the frame just shown (vk_reflex.cpp).

On main the present call itself is the presenter thread's (#1763), so what this frees is the hand-over's wait and the
pacing wait. The render thread's path (RX_VK_ASYNC) holds no order lock at its present and is unchanged.

From the branch's replay-parts work (bd3ea307, 4eed88f7's Reflex line). Not measured, neither on the branch nor in play.

Test: tests/test_present_unlocked.py compiles the real ReplayPin, present_unlocked_on and present_order_release with
stand-ins and runs present()'s hold (let go at the copy, held without one, a nested pin, =0), and reads present(),
present_image and reflex_sleep for their order.

Switch: RX_VK_PRESENT_UNLOCKED (kill), on; =0 holds both until the present returns, as before.

Switch reads: the test also runs RX_VK_PRESENT_UNLOCKED as the source reads it, in fresh processes (unset, 0, 1, 2, off, each twice, the variable flipped after the first read: read once).

Assisted-by: Claude Code
Member

Possibly related, for context:

  • PR #2005 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) — Concurrent Vulkan performance work by same author; nearby renderer replay synchronization code may overlap.
Possibly related, for context: - PR #2005 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) — Concurrent Vulkan performance work by same author; nearby renderer replay synchronization code may overlap.
Author
Contributor

@Beanstalk This adds RX_VK_PRESENT_UNLOCKED, a kill switch on by default: with Threaded rendering off, the present no longer holds the replay's order lock (gpu/vk); RX_VK_PRESENT_UNLOCKED=0 is main's way. It has not run in the game on these PCs yet. Please play Hyrule Field for three minutes with Threaded rendering off in the Insert menu, the PR against main on the same PC, on the PR's side with the switch unset and with RX_VK_PRESENT_UNLOCKED=0, with a picture compared with main's, on Windows with NVIDIA with Reflex on and with it off, on Linux with AMD (RADV), and on the Steam Deck. The same picture, no stutter, hang, crash or FATAL line at the present; unset, frame time p99 and hitches equal to main's or better and to the switch off.

@Beanstalk This adds RX_VK_PRESENT_UNLOCKED, a kill switch on by default: with Threaded rendering off, the present no longer holds the replay's order lock (gpu/vk); RX_VK_PRESENT_UNLOCKED=0 is main's way. It has not run in the game on these PCs yet. Please play Hyrule Field for three minutes with Threaded rendering off in the Insert menu, the PR against main on the same PC, on the PR's side with the switch unset and with RX_VK_PRESENT_UNLOCKED=0, with a picture compared with main's, on Windows with NVIDIA with Reflex on and with it off, on Linux with AMD (RADV), and on the Steam Deck. The same picture, no stutter, hang, crash or FATAL line at the present; unset, frame time p99 and hitches equal to main's or better and to the switch off.
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 4c0c0b7, and the PR has changed since (3edef0f), 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 `4c0c0b7`, and the PR has changed since (`3edef0f`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
siantm force-pushed perf/vk-present-unlocked from 4c0c0b7a65
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 10s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
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 3edef0f621
Some checks are pending
CI / Website build and checks (pull_request) Blocked by required conditions
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
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 5s
beanstalk/approval waiting for a BigBean's 👍 on the request
2026-11-22 01:51:04 +00:00
Compare
Author
Contributor

Rebased onto main @ 8aa74983 (unreviewed WIP): it conflicted with main's 7c23d2be (#1859, Output resolution preview) in tests/test_present_acquire_ahead.py, resolved by keeping both changes, and tests/test_present_unlocked.py now reads main's renamed present_tagged, present_image_with_trial, submit_or_retry and present_out signature; the range-diff is otherwise =. Job rb-2053-2054: tests/test_present_unlocked.py, tests/test_present_acquire_ahead.py, tests/test_switch_table.py and the syntax compile of gpu/vk/vk_replay.cpp and gpu/vk/vk_reflex.cpp pass, with no behaviour change; the earlier head 4c0c0b7a is gone.

Rebased onto main @ 8aa74983 (unreviewed WIP): it conflicted with main's 7c23d2be (#1859, Output resolution preview) in `tests/test_present_acquire_ahead.py`, resolved by keeping both changes, and `tests/test_present_unlocked.py` now reads main's renamed `present_tagged`, `present_image_with_trial`, `submit_or_retry` and `present_out` signature; the range-diff is otherwise `=`. Job `rb-2053-2054`: `tests/test_present_unlocked.py`, `tests/test_present_acquire_ahead.py`, `tests/test_switch_table.py` and the syntax compile of `gpu/vk/vk_replay.cpp` and `gpu/vk/vk_reflex.cpp` pass, with no behaviour change; the earlier head 4c0c0b7a is gone.
Author
Contributor

@Beanstalk This adds RX_VK_PRESENT_UNLOCKED, a kill switch on by default: with Threaded rendering off, the present lets the replay's order lock go once the frame's copy is on the queue (gpu/vk). This head is a rebase onto main 8aa74983 with no change in behaviour; it replaces my request 65623, made for the earlier head. Please start from the kokiri-start save and take the picture right after it loads and settles, before any input, with a main-against-itself picture on the same PC at that point; then, for frame times only, play Kokiri Forest for three minutes; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with RX_VK_PRESENT_UNLOCKED=0 (off), on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The farm cannot set Threaded rendering, so with the default settings this run checks that nothing changes; the Threaded-rendering-off path (with Reflex on and off on NVIDIA) is checked by hand, unless a tester has a CPU with fewer than 4 cores, where the game runs with Threaded rendering off; there the median frame time unset should be lower than with RX_VK_PRESENT_UNLOCKED=0 and than main's. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to RX_VK_PRESENT_UNLOCKED=0 or better. The log must have no FATAL, device lost or validation error line. No stutter or hang at the present.

@Beanstalk This adds RX_VK_PRESENT_UNLOCKED, a kill switch on by default: with Threaded rendering off, the present lets the replay's order lock go once the frame's copy is on the queue (gpu/vk). This head is a rebase onto main 8aa74983 with no change in behaviour; it replaces my request 65623, made for the earlier head. Please start from the kokiri-start save and take the picture right after it loads and settles, before any input, with a main-against-itself picture on the same PC at that point; then, for frame times only, play Kokiri Forest for three minutes; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with RX_VK_PRESENT_UNLOCKED=0 (off), on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The farm cannot set Threaded rendering, so with the default settings this run checks that nothing changes; the Threaded-rendering-off path (with Reflex on and off on NVIDIA) is checked by hand, unless a tester has a CPU with fewer than 4 cores, where the game runs with Threaded rendering off; there the median frame time unset should be lower than with RX_VK_PRESENT_UNLOCKED=0 and than main's. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to RX_VK_PRESENT_UNLOCKED=0 or better. The log must have no FATAL, device lost or validation error line. No stutter or hang at the present.
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.
Author
Contributor

@Beanstalk One correction to my request 71008 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 71008 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.
Contributor

Steam Deck result: I ran this PR against main, and its switch RX_VK_PRESENT_UNLOCKED=0 against unset, on a Steam Deck OLED standing in Kokiri Forest with Threaded rendering off, three pairs of three minutes each way. Neither showed a difference the Deck can resolve (-0.3 % and +0.3 % on the median, the runs overlapping), and there were no errors or hangs in any log.

Main against this PR:

Before: main @ 9dd41326 After: this PR @ 4c0c0b7a Δ
fps (each run) 43.6 / 44.1 / 43.9 (median 43.9) 44.0 / 43.7 / 43.8 (median 43.8) -0.3%
1% low fps (1000 / p99) 32.8 32.9 +0.3%
median frame time 22.39 ms 22.35 ms -0.04 ms
p99 frame time 30.50 ms 30.41 ms -0.09 ms
frames of 50 ms or more (each run) 1 / 0 / 0 0 / 0 / 1

dev.py ab's verdict: no difference shown: -0.3% fps (median 43.8 against 43.9), within the runs' spread (A 43.6 to 44.1, B 43.7 to 44.0).

RX_VK_PRESENT_UNLOCKED=0 against unset, on this PR's build:

Before, RX_VK_PRESENT_UNLOCKED unset After, RX_VK_PRESENT_UNLOCKED=0 Δ
fps (each run) 44.3 / 44.0 / 43.6 (median 44.0) 43.8 / 44.2 / 44.1 (median 44.1) +0.3%
1% low fps (1000 / p99) 36.7 37.0 +0.7%
median frame time 22.53 ms 22.57 ms +0.04 ms
p99 frame time 27.24 ms 27.06 ms -0.18 ms
frames of 50 ms or more (each run) 0 / 0 / 0 0 / 1 / 0

dev.py ab's verdict: no difference shown: +0.3% fps (median 44.1 against 44.0), within the runs' spread (A 43.6 to 44.3, B 43.8 to 44.2). (The tool's column header names main's commit because it takes the label from the scripts' folder; both sides ran this PR's build.) So the median frame time with the switch unset was not lower than with =0 or than main's here, and =0 was the same as main, within about 1 %.

From the logs: every one of the 12 reads vk: Threaded rendering: Auto: off (3 cores of 6 logical processors; the render thread from 4 cores). The PR's runs with the switch unset log vk: the present made with the replay's order lock let go, once the frame's copy is on the queue: on (RX_VK_PRESENT_UNLOCKED=0: held until the present returns), and with =0 the same line ends : off. No FATAL, device-lost, VK_ERROR, validation or hang line in any of the 12 logs; every run exited normally.

Note: this is the head I built, 4c0c0b7a, merged onto main 9dd41326. The PR has since been rebased (3edef0f6); that head was not run.

Hardware: Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel, GPU clock manual 1600 MHz, headless.
Settings: Minimum, Render 50 % (640x400), output 1280x800, uncapped, V-Sync and frame generation off; Threaded rendering at Auto (off on the Deck).
Game data: complete (the dump, with the three damaged textures replaced).
Built: main @ 9dd41326 and main 9dd41326 with this PR's head 4c0c0b7a merged in (its 1 commit on 75317e1f; tests/test_present_acquire_ahead.py conflicted and was taken from the PR, the code merged cleanly), x86-64-v3, shaders prepared on the Deck; only the renderer differs.
Measured: dev.py ab, Kokiri Forest, 3 interleaved pairs of 180 s after the warm-up (until no frame waits for a pipeline, at least 10 s), the median (the project's tool, with a local change to compare two prebuilt runtimes, since the Deck does not build).

Limits: main @ 9dd41326 rather than 75317e1f as the base; dev.py ab stands Link still where the scene puts him, so this is not three minutes of play, and the order is ABAB rather than ABBA; the picture can't be judged headless, and there's no screenshot. The Deck has no Reflex. In this standing scene the Deck's runs agree within about 1 %, so a change of 1-2 % would show only as a hint. The switch isn't read through HOS_AB, so an in-run comparison wasn't possible.

Steam Deck result: I ran this PR against main, and its switch `RX_VK_PRESENT_UNLOCKED=0` against unset, on a Steam Deck OLED standing in Kokiri Forest with Threaded rendering off, three pairs of three minutes each way. Neither showed a difference the Deck can resolve (-0.3 % and +0.3 % on the median, the runs overlapping), and there were no errors or hangs in any log. **Main against this PR:** | | Before: main @ 9dd41326 | After: this PR @ 4c0c0b7a | Δ | |---|---|---|---| | fps (each run) | 43.6 / 44.1 / 43.9 (median 43.9) | 44.0 / 43.7 / 43.8 (median 43.8) | -0.3% | | 1% low fps (1000 / p99) | 32.8 | 32.9 | +0.3% | | median frame time | 22.39 ms | 22.35 ms | -0.04 ms | | p99 frame time | 30.50 ms | 30.41 ms | -0.09 ms | | frames of 50 ms or more (each run) | 1 / 0 / 0 | 0 / 0 / 1 | | `dev.py ab`'s verdict: **no difference shown: -0.3% fps (median 43.8 against 43.9), within the runs' spread (A 43.6 to 44.1, B 43.7 to 44.0).** **`RX_VK_PRESENT_UNLOCKED=0` against unset, on this PR's build:** | | Before, RX_VK_PRESENT_UNLOCKED unset | After, RX_VK_PRESENT_UNLOCKED=0 | Δ | |---|---|---|---| | fps (each run) | 44.3 / 44.0 / 43.6 (median 44.0) | 43.8 / 44.2 / 44.1 (median 44.1) | +0.3% | | 1% low fps (1000 / p99) | 36.7 | 37.0 | +0.7% | | median frame time | 22.53 ms | 22.57 ms | +0.04 ms | | p99 frame time | 27.24 ms | 27.06 ms | -0.18 ms | | frames of 50 ms or more (each run) | 0 / 0 / 0 | 0 / 1 / 0 | | `dev.py ab`'s verdict: **no difference shown: +0.3% fps (median 44.1 against 44.0), within the runs' spread (A 43.6 to 44.3, B 43.8 to 44.2).** (The tool's column header names main's commit because it takes the label from the scripts' folder; both sides ran this PR's build.) So the median frame time with the switch unset was not lower than with `=0` or than main's here, and `=0` was the same as main, within about 1 %. From the logs: every one of the 12 reads `vk: Threaded rendering: Auto: off (3 cores of 6 logical processors; the render thread from 4 cores)`. The PR's runs with the switch unset log `vk: the present made with the replay's order lock let go, once the frame's copy is on the queue: on (RX_VK_PRESENT_UNLOCKED=0: held until the present returns)`, and with `=0` the same line ends `: off`. No `FATAL`, device-lost, `VK_ERROR`, validation or hang line in any of the 12 logs; every run exited normally. Note: this is the head I built, 4c0c0b7a, merged onto main 9dd41326. The PR has since been rebased (3edef0f6); that head was not run. Hardware: Steam Deck OLED, SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel, GPU clock manual 1600 MHz, headless. Settings: Minimum, Render 50 % (640x400), output 1280x800, uncapped, V-Sync and frame generation off; Threaded rendering at Auto (off on the Deck). Game data: complete (the dump, with the three damaged textures replaced). Built: main @ 9dd41326 and main 9dd41326 with this PR's head 4c0c0b7a merged in (its 1 commit on 75317e1f; `tests/test_present_acquire_ahead.py` conflicted and was taken from the PR, the code merged cleanly), x86-64-v3, shaders prepared on the Deck; only the renderer differs. Measured: `dev.py ab`, Kokiri Forest, 3 interleaved pairs of 180 s after the warm-up (until no frame waits for a pipeline, at least 10 s), the median (the project's tool, with a local change to compare two prebuilt runtimes, since the Deck does not build). Limits: main @ 9dd41326 rather than 75317e1f as the base; `dev.py ab` stands Link still where the scene puts him, so this is not three minutes of play, and the order is ABAB rather than ABBA; the picture can't be judged headless, and there's no screenshot. The Deck has no Reflex. In this standing scene the Deck's runs agree within about 1 %, so a change of 1-2 % would show only as a hint. The switch isn't read through `HOS_AB`, so an in-run comparison wasn't possible.
Author
Contributor

@zeldaootr thank you for the Deck runs, and for saying which head you built. Besides moving onto main 8aa74983, the rebase to 3edef0f6 changed tests only (tests/test_present_unlocked.py reads main's renamed present_tagged, present_image_with_trial, submit_or_retry and present_out's new arguments; tests/test_present_acquire_ahead.py keeps both sides): outside tests/ the added and removed lines are the same as 4c0c0b7a's, only their context moved with main. So your run stands for this head's renderer change, measured over main 9dd41326 rather than 8aa74983. It is now in Measurements as your run, with its limits (Link standing, no Reflex, runs agreeing within about 1 %): no difference and no error or hang on the Deck.

@zeldaootr thank you for the Deck runs, and for saying which head you built. Besides moving onto main 8aa74983, the rebase to 3edef0f6 changed tests only (`tests/test_present_unlocked.py` reads main's renamed `present_tagged`, `present_image_with_trial`, `submit_or_retry` and `present_out`'s new arguments; `tests/test_present_acquire_ahead.py` keeps both sides): outside `tests/` the added and removed lines are the same as 4c0c0b7a's, only their context moved with main. So your run stands for this head's renderer change, measured over main 9dd41326 rather than 8aa74983. It is now in Measurements as your run, with its limits (Link standing, no Reflex, runs agreeing within about 1 %): no difference and no error or hang on the Deck.
Author
Contributor

@Beanstalk One more correction to my request 71008 above: the farm can turn Threaded rendering off after all, through its switch RX_VK_ASYNC=0 (the setting the Threaded rendering row stands for, on main too). This change acts only with Threaded rendering off, so please set RX_VK_ASYNC=0 on both sides (main and the PR, the PR's side unset and with RX_VK_PRESENT_UNLOCKED=0); the earlier sentence saying the path is checked by hand no longer holds. There the median frame time unset should be lower than with RX_VK_PRESENT_UNLOCKED=0 and than main's.

@Beanstalk One more correction to my request 71008 above: the farm can turn Threaded rendering off after all, through its switch RX_VK_ASYNC=0 (the setting the Threaded rendering row stands for, on main too). This change acts only with Threaded rendering off, so please set RX_VK_ASYNC=0 on both sides (main and the PR, the PR's side unset and with RX_VK_PRESENT_UNLOCKED=0); the earlier sentence saying the path is checked by hand no longer holds. There the median frame time unset should be lower than with RX_VK_PRESENT_UNLOCKED=0 and than 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.

@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 / Website build and checks (pull_request) Blocked by required conditions
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
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 5s
beanstalk/approval waiting for a BigBean's 👍 on the request
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/vk-present-unlocked:siantm-perf/vk-present-unlocked'
git switch 'siantm-perf/vk-present-unlocked'
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!2053
No description provided.