perf(vk): RX_VK_ACQUIRE_AHEAD=1 asks for the window's next image right after a present, so the render thread no longer waits for it (off by default) #1574

Open
klimovich008 wants to merge 8 commits from klimovich008/Longshot:perf/acquire-ahead into main
Contributor

Type: perf · Risk: low · Tested on: Windows 11, RX 9070 XT (AMD 26.11.1); Test Farm: Windows RTX 3090, Linux RTX 4070; Steam Deck OLED (dukenheimer) · Needs: Intel on Windows; Linux RADV (X11 and Wayland); NVIDIA with the switch's log lines

TL;DR

Since #1458 the renderer waits on the CPU for the window's next image right before it draws into it. On an RX 9070 XT in a window that wait is about 3 ms of every frame on the thread the frame waits for. This PR adds an opt-in switch, RX_VK_ACQUIRE_AHEAD=1 (off by default), that asks for the next image right after each present, so it comes back while the next frame is made. In the standard test in a window it went from 64.6 to 70.0 fps (+8.4 %, 2 pairs), with the game clock at 1.000 and no new stutter. The code is the same on every GPU; the Test Farm is asked for the others.

Breakdown

  • Who it helps: anyone whose driver hands the window's image back late, measured so far on AMD's Windows driver with the game in a window (+8.4 % fps here); the same code runs on every GPU and system, so others may gain too, but no other one has been measured yet.
  • What was wrong: since #1458 each present asks for its image and then waits for it; in a window AMD's driver gives it back about 3 ms later, and the render thread spends that time waiting instead of working.
  • What changes: with the switch on, the next image is asked for right after each present without waiting (a timeout of 0), so its wait overlaps the next frame's work.
  • What does not change: the default (off on every PC: unset or 0 keeps #1458's order); #1458's fix for the window behind another one (no GPU-side wait anywhere); frame generation, the presenter thread and V-Sync On (FIFO) keep #1458's order even with the switch on; no shader cache or settings change.
  • How it was checked: the standard test (Hyrule Field, 2 alternating pairs, the third skipped by the harness), resize and full-screen toggles, a validation session, frame generation and V-Sync On runs, a game-free test with 11 broken variants, and the full test suite against clean main.
  • What is still open: every GPU and system except AMD on Windows; #1458's hidden-window case with the display on; a fence that can be left over per swapchain remake (listed under Risks).
  • Risk: low: off by default; with it on, at worst the image is waited for at its present as today.

Why

#1458 (HumanBean) moved the wait for the window's image from the GPU's queue to the CPU, so that a window behind another one no longer stops the GPU's work (#1376). Its text left one question open: "Frame pacing on AMD with the CPU-side wait is the open question for the Test Farm." On this PC (RX 9070 XT, AMD's Windows driver, a 1280x720 window on a 144 Hz desktop) that wait costs 2.8-3.2 ms of each frame on the render thread: its presents take 3.6-4.1 ms a frame since #1458 against 0.9-1.0 ms before it, the CPU sampler finds 19.8 % of the thread blocked in that fence wait, and the render thread is what the frame waits for. Full screen has no such wait (0.88-0.90 ms presents).

Why the gain should carry beyond this PC: the change is not AMD-specific. Every driver makes the program wait for the window's image somewhere, in the acquire's fence (AMD's on Windows, which hands the image back at once and leaves the wait to the fence) or inside the acquire call itself (NVIDIA's, Mesa's, as #1458 says). Asking for the image a present earlier, without waiting, gives it the next frame's work to come back in, whichever of the two holds the wait. Where the image is already back early (full screen here), nothing changes but where the acquire is called. This PC can only show AMD's Windows driver, hence the Test Farm request below and the switch off by default.

See #1458, #1376.

What changed

One switch, off by default. With RX_VK_ACQUIRE_AHEAD=1, right after each present of a game frame the renderer asks for the next present's image with a timeout of 0 and keeps it as an image already out, the state #1458 already has for an image it acquired and found busy. Its present then looks at it without a new acquire.

  • renderer: gpu/vk/vk_replay.cpp
    • acquire_ahead() (new), called at the end of present_image() after present_out() returned the present as made, with the queue's lock let go: nothing while an image is held, no swapchain or no unsignaled fence (acquire_fence_ready(), #1458's rule); vkAcquireNextImageKHR with a timeout of 0 into acquire_fence. VK_NOT_READY, VK_TIMEOUT, out of date or a lost surface: nothing is out and the next present acquires as without the switch. A lost device is reported as at every other acquire.
    • HeldImage gets ahead. At its present an image asked for ahead is looked at without waiting; not free yet, it is waited for up to kImageFreeNs (250 ms), as an image acquired at that present would be, and only then held as #1458 holds one. So a slow compositor drops no frame that is shown today.
    • held_image_drop() (a swapchain made again while an image is out) also lets go an image asked for ahead.
    • acquire_ahead_wanted(): the switch read once by value (0, off, no, false or unset: off), logged at the first present; not while frame generation runs, with the presenter thread (RX_VK_PRESENT_THREAD=1: the swapchain is one thread's at a time), or under FIFO (V-Sync On, where the acquire is what paces). Each change of that answer is logged once: vk: acquire ahead: not now, <why>.
    • A counter: every 600 presents vk: the window's image (600 presents): waited for X ms a present (its acquire and its fence), and what became of the images asked for ahead; with the switch only. Unset or 0, nothing is counted or logged beyond the one acquire ahead: off line at the first present: the switch costs nothing while off.
  • gpu/vk/switches.def: the row, attempt, off on every PC. docs/development.md: the row beside RX_VK_PRESENT_THREAD.
  • tests: tests/test_present_acquire_ahead.py (new, run by tests/run_all.py) cuts present_image's acquire, its copy's submit, its end and the new helpers out of vk_replay.cpp, compiles them against a model presentation engine (AMD-like: an image at once, its fence later, never while the window is hidden; NVIDIA-like: the wait in the acquire, nothing at a timeout of 0) and runs both _WIN32 sides with the switch unset, 0 and 1. tests/test_present_device_loss.py counts the new acquire among the WSI sites that must route a lost device; tests/test_present_thread.py's needle reads present_image's end with the present's result kept (its later check fails on main too); tests/test_present_image_free.py's fixture gets the switch reader env_on, answering off (#1458's order, which it checks).
  • docs/tested/: the four admitted standard-test runs, one file each.

Measurements

Verdict: helps on AMD's Windows driver in a window: +8.4 % fps (64.59 to 69.99, median of 2 pairs), CPU time a frame -6.7 %, the render thread's presents 3.9-4.2 to 0.73-0.76 ms a frame, every switch-on run faster than every control run; game clock 1.000-1.001 in both arms, p99 not worse, no frame over 100 ms in either. n = 2 pairs (the harness rejected the third pair's control run and skipped the pair, by its rules), so the harness labels it "diagnostic". Not measured on any other GPU or system.

Baseline: the runs were made before this branch was rebased onto main 430eef4f: "Before" is main as it was then, ef6038ab, and "After" is this PR's renderer at 0ceaa6ab over the same game build. The rebase changed none of this PR's commits (git range-diff: identical), and of main's 13 newer commits none touches present_image or the acquire (vk_replay.cpp changed in 5 lines elsewhere); later commits here change a comment, the docs row, the test and docs/tested/, and make the image-wait counter run with the switch only (a052b5eb: with the switch set, the same calls and counts as the measured renderer; unset, no counting).
Hardware: Windows 11 Home (26300), AMD Radeon RX 9070 XT (driver 26.11.1), Ryzen 7 5700X3D (8 cores, 16 threads), 64 GB; one 5120x1440 144 Hz display
Scene: Hyrule Field, the camera turning at full speed; a 1280x720 window (swapchain 1280x720, 4 images, immediate), 2048x1152 output (16:9), a fixed options profile (frame generation off, V-Sync off), no frame rate cap (HOS_FPS_MAX=240), threaded rendering on (RX_VK_ASYNC=1), a fixed background GPU load beside the game (500 blended quads a frame at 100 fps; it keeps the GPU's clock steady between runs)
Method: our standard test: a 20 s window from the area's load, alternating pairs control / switch on, no warm-up runs, a rejected run skips its pair; one game build (exe 0a53b387) in both arms, only longshot_vk.dll differs (control ed1771bb, this PR 59884440); fps, CPU time a frame, p99 and worst frame from the presents in the window, the game clock against real time from HOS_FPS_LOG=1, the render thread's time from its 600-present log line
How to reproduce: a window in Hyrule Field with V-Sync Off (immediate) and frame generation off; run once without and once with RX_VK_ACQUIRE_AHEAD=1 in longshot_env.txt, and compare the log's vk: the render thread (600 presents ...) lines (presents in them) and the FPS counter

Before: main @ ef6038ab After, RX_VK_ACQUIRE_AHEAD=1: this PR @ 0ceaa6ab
fps (median; the runs) 64.59 (64.89, 64.29) 69.99 (70.14, 69.84)
CPU ms a frame, all threads 73.57 (71.71, 75.44) 68.66 (69.32, 68.00)
p99 frame (ms) 21.42 (20.52, 22.32) 19.88 (19.97, 19.79)
worst frame (ms) 90.4, 47.7 95.7, 80.7
frames over 50 / 100 / 250 ms (sum) 1 / 0 / 0 2 / 0 / 0
game clock 1.000, 1.001 1.001, 1.000
the render thread's presents, ms a frame (in play) 3.94-4.16 0.74-0.76
the render thread idle, ms a frame (in play) 1.07-1.23 3.37-3.55
GPU ms a frame (the log) 7.6, 7.7 7.2, 7.1

The frame over 50 ms (90.4, 95.7 and 80.7 ms, 47.7 in the fourth run) is one and the same event in every run, about 1 s into the window: the turn's first stream-in. The third pair's control run was rejected for the game clock's coverage (a probe at 1.013 after a 26 s pause in the load); its pair was skipped, not replaced.

control (main ef6038ab), in play:
vk: the render thread (600 presents, ...): its jobs 14.06 ms a frame (submits 2.18, presents 4.16, others 7.71), idle 1.07
vk: the render thread (600 presents, ...): its jobs 14.12 ms a frame (submits 2.30, presents 4.08, others 7.74), idle 1.17

RX_VK_ACQUIRE_AHEAD=1 (this PR), in play:
vk: acquire ahead: on: the next image asked for right after each present (RX_VK_ACQUIRE_AHEAD=1; measured so far on AMD's Windows driver in a window)
vk: the render thread (600 presents, ...): its jobs 10.85 ms a frame (submits 3.17, presents 0.76, others 6.92), idle 3.39
vk: the render thread (600 presents, ...): its jobs 10.45 ms a frame (submits 3.03, presents 0.74, others 6.69), idle 3.49
vk: the window's image (600 presents): waited for 0.03 ms a present (its acquire and its fence); asked for a present ahead (RX_VK_ACQUIRE_AHEAD=1) 600 times: 583 free at their present, 17 waited for there, 0 let go with their swapchain; 0 times none given at once

Flags and settings

One new switch, off by default on every PC; nothing else changes.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_ACQUIRE_AHEAD env, renderer (attempt), read by value once not there: each image asked for at its own present unset or 0: as before; =1: the next image asked for right after each present, never waited for there the wait for the window's image overlaps the next frame's work; not with frame generation, RX_VK_PRESENT_THREAD=1 or FIFO (V-Sync On), each logged helps: RX 9070 XT, AMD 26.11.1, Windows 11, in a window (+8.4 % fps); full screen there: no wait to hide (0.74 against 0.87 ms presents); untested: NVIDIA, Intel, Linux, the Steam Deck, a 60 Hz desktop, VRR off for everyone until the Test Farm's runs; then a candidate for on everywhere, since it is one mechanism and not a vendor workaround

Testing

Tested:

  • In the game, Windows 11, RX 9070 XT, AMD 26.11.1, this PR's renderer at 0ceaa6ab with the switch on, besides the A/B above:

    • The first reading with the switch on: 600 of 600 presents had an image asked for ahead, 547-600 of them free at their present, never "none given at once": AMD's driver hands an image over at a timeout of 0.
    • Window toggles: three rounds of the window resized (1600x900, 1000x600, back), F11 to full screen and back, and Insert pressed twice: 17 swapchains made, 14 images asked for ahead let go with their swapchain, no hold, no error line; the log's host lines against the same session without the switch differ only in statistics.
    • The same toggles with Vulkan validation (RX_VK_VALIDATION=1, the Khronos layer, VK_LAYER_VALIDATE_SYNC=1): no message about the swapchain, the acquire, the present or fences (the messages there were about shader outputs, image creation and query pools, code this PR does not touch).
    • Frame generation 2x for about 2 minutes: acquire ahead: not now, frame generation runs, interpolation ran, no error line. V-Sync On: acquire ahead: not now, the swapchain is FIFO, presents 4.0 ms a frame as before.
    • #1458's case, full screen with a window over the whole display for 40 s, twice: frames went on, no hold, no hang, no error line, with and without the switch (but see Not tested).
    • Full screen: presents 0.74-0.75 ms a frame with the switch, 0.87 without.
  • Test Farm (results, commit 2f24a499 against main 430eef4f). The plan:

    • Hyrule Field from a new save, in a window, vsync=2 (V-Sync Off: the immediate mode, which the switch does not hold off) and frame generation off.
    • Each report ran one 180 s run a side: main against this PR, without the switch (field-default) and with RX_VK_ACQUIRE_AHEAD=1 on the PR side (field-acquire-ahead).
    • Threaded rendering was on in both reports' logs.

    The reports came from two PCs:

    Report PC p99 without the switch (main → PR) p99 with the switch (main → PR) stutters with the switch (main → PR) fps
    rp_8db0f25f3bc6c740 Windows, RTX 3090 (621.24.0), Ryzen 9 5900X 20.30 → 20.65 ms 20.54 → 25.33 ms 1 → 13 60.0 both (the 60 cap)
    rp_b854f1dd81aaa143 Linux, RTX 4070 (615.71.9), Ryzen 7 5800X3D 18.91 → 18.96 ms 18.59 → 18.92 ms 0 → 1 60.0 both
    rp_bb166040791326c5 the same Linux RTX 4070 PC 19.34 → 18.84 ms 18.86 → 18.91 ms 7 → 0 60.0 both
    • No crash, no forbidden log line, and no picture difference against main.
    • The NVIDIA cell's "fail" is its fps rule (more than 0 % below main) at the 60 cap: 60.00 → 59.99.
    • Its p99 of 19.6 → 22.1 ms is the median of the 3090's and the 4070's reports, so the whole rise is the 3090's one run.
    • Linux's second report (rp_903bc676955bce4a, Arch Linux) timed out before play and has no numbers.
    • Whether the switch engaged there is not shown. The reports publish only the end of one PR-side log. None of those ends has the vk: the window's image (600 presents) line, which the switch prints every 600 presents whenever it is set, so they cannot show the switch's state either way.
  • Steam Deck OLED (dukenheimer; SteamOS, RADV, 1280x800 through gamescope's mailbox swapchain, Threaded rendering at Auto (off)): the same build on main 430eef4f, the switch unset against =1, three interleaved rounds.

    • It engaged: every counter line in a measured window read 600 free, 0 waited, 0 dropped, 0 none given.
    • Kokiri, standing, three pairs: fps 25.42 → 25.53 (arm medians, about +0.4 %); p95 lower in all three pairs; frames over 50 ms lower in two and tied in one; p99 and the longest frame mixed.
    • Hyrule Field: no admitted pair.
    • No GPU fault or reset.
    • Not shown: the image wait without the switch, the displayed frames, and the effect of the Deck's memory sampler.
  • tests/test_present_acquire_ahead.py: the order (the next image asked for after the present is queued, never with the queue's lock held, one asked for ahead at most, none while one is held, never with a signaled or pending fence); an image given back after 20 ms (none dropped, waited for no longer than needed); #1458's hidden window (no GPU wait in any copy, no copy into an image not given back, the first hidden present waits exactly 250 ms, shown again once given back); the swapchain made again with an image out, by a resize and by the present's own SUBOPTIMAL; an ahead acquire answered out of date; the gates (frame generation, the presenter thread, FIFO, the start-up screen's presents); NVIDIA-like (the ahead acquire never waits); a lost device at the ahead acquire; with the switch unset or 0, no counter line. Eleven broken variants each fail for their own reason (among them: the ahead acquire before the present, the wait at the present removed, the drop at a new swapchain removed, each gate removed, the switch's value ignored, the counter run with the switch off). It fails on main and passes here; it passes on Windows (llvm-mingw clang++) and on Linux (WSL Ubuntu, g++ and clang++). #1458's own tests/test_present_image_free.py passes (its fixture only given env_on).

  • python -I -B tests/run_all.py --jobs 4 (Windows, llvm-mingw clang 20261104) on this branch @ 2f24a499 and on main @ 430eef4f: this branch 684 passed, 46 failed, 51 skipped (the Linux-only checks); main 683 passed, 46 failed, 51 skipped. The 46 failures are the same list on both (they fail on this Windows checkout on main too, among them test_present_thread.py, whose later check expects an opt-in-only presenter queue, and test_tested_configurations.py's line-ending check of its CLI on Windows); the extra pass is tests/test_present_acquire_ahead.py. test_present_image_free.py and test_present_device_loss.py pass.

  • At 2f24a499, gpu/vk/vk_replay.cpp compiled to an object for Linux (WSL clang 21 with the Linux build's flags) and for Windows (llvm-mingw clang++ 20261104, -Wall: one warning, main's own, a VkClearColorValue initializer it does not touch); the whole renderer was built with llvm-mingw at 0ceaa6ab for the A/B (210 files, no warnings). The game-free tests pass on WSL Ubuntu with g++ and clang++ at 2f24a499 too.

Not testable by hand: NVIDIA, Intel, Linux and the Steam Deck: not on this PC. The game-free test's NVIDIA-like model stands in for the "wait inside the acquire" drivers (the ahead acquire never waits there). The Test Farm and a Deck owner ran what is above; the rest is below.

Not tested:

  • #1458's hidden-window case with the display on: the run above was made with the display asleep, and AMD's driver then held no image in either arm, so the held-image path was not reached in the game (the game-free test covers it).
  • The picture: no frame log on against off (a repeated or skipped frame would show there); frame generation's picture with the switch set.
  • Whether synchronization validation really ran in the validation session (it printed no SYNC- message at all), and the same session without the switch.
  • The Insert menu really opening from the posted key; V-Sync and HDR changed at run time from the menu (V-Sync On was checked from the start).
  • Threaded rendering Off (Auto turns it off under 12 processor threads, the Steam Deck among them): then the wait is on the game's submitting thread; the switch acts the same way there, but no run was made.
  • A 60 Hz desktop, VRR, a second monitor, a long session with many resizes.
  • The third A/B pair (rejected by the harness; not replaced).
  • Whether the RTX 3090's higher p99 with the switch comes from the switch: one run a side, no engagement line published, and that report also has the larger longest-frame change without the switch (27.2 → 37.0 ms).

Must be tested:

  • nvidia, windows: Hyrule Field in a window with V-Sync Off and frame generation off, at least 3 runs a side without and with RX_VK_ACQUIRE_AHEAD=1 in longshot_env.txt.
    • Expected with the switch: acquire ahead: on, and the log's vk: the window's image line near 0 ms a present.
    • Expected: fps not lower, p99 not higher than without the switch, no error line.
    • The farm's one-run RTX 3090 report is the open question: p99 20.54 → 25.33 ms with the switch, and no engagement line published (Test Farm: @Beanstalk, or a tester).
  • intel, windows: the same, expecting the same (Test Farm: @Beanstalk; queued, no tester online yet)
  • linux, radv, X11 and Wayland: the same, and once with the window covered by another for 40 s, expecting frames to resume, no hang. Linux NVIDIA ran on the farm (above). The covered window is by hand, since the farm cannot do it: look for frames coming back and no hang (Test Farm: @Beanstalk for RADV).
  • steamdeck: Hyrule Field in game mode (gamescope), expecting no lower fps and no stutter. Kokiri ran (above); Hyrule had no admitted pair (Test Farm: @Beanstalk; queued, or by hand: fps, p99 and frames over 50 ms).

Risks

What could break: only with the switch set. The swapchain's image is asked for earlier: on a driver that answers a timeout of 0 with "not ready", the switch does nothing (the counter's "none given at once" says so). Swapchain remakes (resize, full screen, HDR, V-Sync) let an image asked for ahead go; its fence is then replaced by a new one when it is not signaled yet, as #1458 does after a 250 ms hold, so one VkFence can be left over per remake made in the ~3 ms before the image came back (bounded, a small object; reusing such fences once signaled is a follow-up that would touch #1458's path for everyone). Right after frame generation is turned off its last presents ahead may still hold images, and the image asked for ahead is then one more out, as the next present's own acquire would be without the switch (it cannot block: a timeout of 0). Also left as found: a failed vkResetFences (out of memory) after a wait leaves the fence signaled, on #1458's path as on this one.

Turning it off: leave RX_VK_ACQUIRE_AHEAD unset or set 0.

Compatibility: Nothing changes for a player: no save, options file, shader or pipeline cache, or vk ABI change (no vk_api.h or shader translator file touched).

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (the renderer's file, compiled to objects for both)
  • Docs updated.

🤖 Generated with Claude Code

**Type:** perf · **Risk:** low · **Tested on:** Windows 11, RX 9070 XT (AMD 26.11.1); Test Farm: Windows RTX 3090, Linux RTX 4070; Steam Deck OLED (dukenheimer) · **Needs:** Intel on Windows; Linux RADV (X11 and Wayland); NVIDIA with the switch's log lines ## TL;DR Since #1458 the renderer waits on the CPU for the window's next image right before it draws into it. On an RX 9070 XT in a window that wait is about 3 ms of every frame on the thread the frame waits for. This PR adds an opt-in switch, `RX_VK_ACQUIRE_AHEAD=1` (off by default), that asks for the next image right after each present, so it comes back while the next frame is made. In the standard test in a window it went from 64.6 to 70.0 fps (+8.4 %, 2 pairs), with the game clock at 1.000 and no new stutter. The code is the same on every GPU; the Test Farm is asked for the others. ## Breakdown - **Who it helps:** anyone whose driver hands the window's image back late, measured so far on AMD's Windows driver with the game in a window (+8.4 % fps here); the same code runs on every GPU and system, so others may gain too, but no other one has been measured yet. - **What was wrong:** since #1458 each present asks for its image and then waits for it; in a window AMD's driver gives it back about 3 ms later, and the render thread spends that time waiting instead of working. - **What changes:** with the switch on, the next image is asked for right after each present without waiting (a timeout of 0), so its wait overlaps the next frame's work. - **What does not change:** the default (off on every PC: unset or `0` keeps #1458's order); #1458's fix for the window behind another one (no GPU-side wait anywhere); frame generation, the presenter thread and V-Sync On (FIFO) keep #1458's order even with the switch on; no shader cache or settings change. - **How it was checked:** the standard test (Hyrule Field, 2 alternating pairs, the third skipped by the harness), resize and full-screen toggles, a validation session, frame generation and V-Sync On runs, a game-free test with 11 broken variants, and the full test suite against clean main. - **What is still open:** every GPU and system except AMD on Windows; #1458's hidden-window case with the display on; a fence that can be left over per swapchain remake (listed under Risks). - **Risk:** low: off by default; with it on, at worst the image is waited for at its present as today. ## Why #1458 (HumanBean) moved the wait for the window's image from the GPU's queue to the CPU, so that a window behind another one no longer stops the GPU's work (#1376). Its text left one question open: "Frame pacing on AMD with the CPU-side wait is the open question for the Test Farm." On this PC (RX 9070 XT, AMD's Windows driver, a 1280x720 window on a 144 Hz desktop) that wait costs 2.8-3.2 ms of each frame on the render thread: its presents take 3.6-4.1 ms a frame since #1458 against 0.9-1.0 ms before it, the CPU sampler finds 19.8 % of the thread blocked in that fence wait, and the render thread is what the frame waits for. Full screen has no such wait (0.88-0.90 ms presents). Why the gain should carry beyond this PC: the change is not AMD-specific. Every driver makes the program wait for the window's image somewhere, in the acquire's fence (AMD's on Windows, which hands the image back at once and leaves the wait to the fence) or inside the acquire call itself (NVIDIA's, Mesa's, as #1458 says). Asking for the image a present earlier, without waiting, gives it the next frame's work to come back in, whichever of the two holds the wait. Where the image is already back early (full screen here), nothing changes but where the acquire is called. This PC can only show AMD's Windows driver, hence the Test Farm request below and the switch off by default. See #1458, #1376. ## What changed One switch, off by default. With `RX_VK_ACQUIRE_AHEAD=1`, right after each present of a game frame the renderer asks for the next present's image with a timeout of 0 and keeps it as an image already out, the state #1458 already has for an image it acquired and found busy. Its present then looks at it without a new acquire. - renderer: `gpu/vk/vk_replay.cpp` - `acquire_ahead()` (new), called at the end of `present_image()` after `present_out()` returned the present as made, with the queue's lock let go: nothing while an image is held, no swapchain or no unsignaled fence (`acquire_fence_ready()`, #1458's rule); `vkAcquireNextImageKHR` with a timeout of 0 into `acquire_fence`. `VK_NOT_READY`, `VK_TIMEOUT`, out of date or a lost surface: nothing is out and the next present acquires as without the switch. A lost device is reported as at every other acquire. - `HeldImage` gets `ahead`. At its present an image asked for ahead is looked at without waiting; not free yet, it is waited for up to `kImageFreeNs` (250 ms), as an image acquired at that present would be, and only then held as #1458 holds one. So a slow compositor drops no frame that is shown today. - `held_image_drop()` (a swapchain made again while an image is out) also lets go an image asked for ahead. - `acquire_ahead_wanted()`: the switch read once by value (`0`, `off`, `no`, `false` or unset: off), logged at the first present; not while frame generation runs, with the presenter thread (`RX_VK_PRESENT_THREAD=1`: the swapchain is one thread's at a time), or under FIFO (V-Sync On, where the acquire is what paces). Each change of that answer is logged once: `vk: acquire ahead: not now, <why>`. - A counter: every 600 presents `vk: the window's image (600 presents): waited for X ms a present (its acquire and its fence)`, and what became of the images asked for ahead; with the switch only. Unset or `0`, nothing is counted or logged beyond the one `acquire ahead: off` line at the first present: the switch costs nothing while off. - `gpu/vk/switches.def`: the row, `attempt`, off on every PC. `docs/development.md`: the row beside `RX_VK_PRESENT_THREAD`. - tests: `tests/test_present_acquire_ahead.py` (new, run by `tests/run_all.py`) cuts `present_image`'s acquire, its copy's submit, its end and the new helpers out of `vk_replay.cpp`, compiles them against a model presentation engine (AMD-like: an image at once, its fence later, never while the window is hidden; NVIDIA-like: the wait in the acquire, nothing at a timeout of 0) and runs both `_WIN32` sides with the switch unset, `0` and `1`. `tests/test_present_device_loss.py` counts the new acquire among the WSI sites that must route a lost device; `tests/test_present_thread.py`'s needle reads `present_image`'s end with the present's result kept (its later check fails on main too); `tests/test_present_image_free.py`'s fixture gets the switch reader `env_on`, answering off (#1458's order, which it checks). - `docs/tested/`: the four admitted standard-test runs, one file each. ## Measurements **Verdict:** helps on AMD's Windows driver in a window: +8.4 % fps (64.59 to 69.99, median of 2 pairs), CPU time a frame -6.7 %, the render thread's presents 3.9-4.2 to 0.73-0.76 ms a frame, every switch-on run faster than every control run; game clock 1.000-1.001 in both arms, p99 not worse, no frame over 100 ms in either. n = 2 pairs (the harness rejected the third pair's control run and skipped the pair, by its rules), so the harness labels it "diagnostic". Not measured on any other GPU or system. Baseline: the runs were made before this branch was rebased onto main 430eef4f: "Before" is main as it was then, ef6038ab, and "After" is this PR's renderer at 0ceaa6ab over the same game build. The rebase changed none of this PR's commits (`git range-diff`: identical), and of main's 13 newer commits none touches `present_image` or the acquire (`vk_replay.cpp` changed in 5 lines elsewhere); later commits here change a comment, the docs row, the test and `docs/tested/`, and make the image-wait counter run with the switch only (a052b5eb: with the switch set, the same calls and counts as the measured renderer; unset, no counting). Hardware: Windows 11 Home (26300), AMD Radeon RX 9070 XT (driver 26.11.1), Ryzen 7 5700X3D (8 cores, 16 threads), 64 GB; one 5120x1440 144 Hz display Scene: Hyrule Field, the camera turning at full speed; a 1280x720 window (swapchain 1280x720, 4 images, immediate), 2048x1152 output (16:9), a fixed options profile (frame generation off, V-Sync off), no frame rate cap (`HOS_FPS_MAX=240`), threaded rendering on (`RX_VK_ASYNC=1`), a fixed background GPU load beside the game (500 blended quads a frame at 100 fps; it keeps the GPU's clock steady between runs) Method: our standard test: a 20 s window from the area's load, alternating pairs control / switch on, no warm-up runs, a rejected run skips its pair; one game build (exe 0a53b387) in both arms, only `longshot_vk.dll` differs (control ed1771bb, this PR 59884440); fps, CPU time a frame, p99 and worst frame from the presents in the window, the game clock against real time from `HOS_FPS_LOG=1`, the render thread's time from its 600-present log line How to reproduce: a window in Hyrule Field with V-Sync Off (immediate) and frame generation off; run once without and once with `RX_VK_ACQUIRE_AHEAD=1` in `longshot_env.txt`, and compare the log's `vk: the render thread (600 presents ...)` lines (`presents` in them) and the FPS counter | | Before: main @ ef6038ab | After, RX_VK_ACQUIRE_AHEAD=1: this PR @ 0ceaa6ab | |---|---|---| | fps (median; the runs) | 64.59 (64.89, 64.29) | 69.99 (70.14, 69.84) | | CPU ms a frame, all threads | 73.57 (71.71, 75.44) | 68.66 (69.32, 68.00) | | p99 frame (ms) | 21.42 (20.52, 22.32) | 19.88 (19.97, 19.79) | | worst frame (ms) | 90.4, 47.7 | 95.7, 80.7 | | frames over 50 / 100 / 250 ms (sum) | 1 / 0 / 0 | 2 / 0 / 0 | | game clock | 1.000, 1.001 | 1.001, 1.000 | | the render thread's presents, ms a frame (in play) | 3.94-4.16 | 0.74-0.76 | | the render thread idle, ms a frame (in play) | 1.07-1.23 | 3.37-3.55 | | GPU ms a frame (the log) | 7.6, 7.7 | 7.2, 7.1 | The frame over 50 ms (90.4, 95.7 and 80.7 ms, 47.7 in the fourth run) is one and the same event in every run, about 1 s into the window: the turn's first stream-in. The third pair's control run was rejected for the game clock's coverage (a probe at 1.013 after a 26 s pause in the load); its pair was skipped, not replaced. ``` control (main ef6038ab), in play: vk: the render thread (600 presents, ...): its jobs 14.06 ms a frame (submits 2.18, presents 4.16, others 7.71), idle 1.07 vk: the render thread (600 presents, ...): its jobs 14.12 ms a frame (submits 2.30, presents 4.08, others 7.74), idle 1.17 RX_VK_ACQUIRE_AHEAD=1 (this PR), in play: vk: acquire ahead: on: the next image asked for right after each present (RX_VK_ACQUIRE_AHEAD=1; measured so far on AMD's Windows driver in a window) vk: the render thread (600 presents, ...): its jobs 10.85 ms a frame (submits 3.17, presents 0.76, others 6.92), idle 3.39 vk: the render thread (600 presents, ...): its jobs 10.45 ms a frame (submits 3.03, presents 0.74, others 6.69), idle 3.49 vk: the window's image (600 presents): waited for 0.03 ms a present (its acquire and its fence); asked for a present ahead (RX_VK_ACQUIRE_AHEAD=1) 600 times: 583 free at their present, 17 waited for there, 0 let go with their swapchain; 0 times none given at once ``` ### Flags and settings One new switch, off by default on every PC; nothing else changes. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_ACQUIRE_AHEAD` | env, renderer (attempt), read by value once | not there: each image asked for at its own present | unset or `0`: as before; `=1`: the next image asked for right after each present, never waited for there | the wait for the window's image overlaps the next frame's work; not with frame generation, `RX_VK_PRESENT_THREAD=1` or FIFO (V-Sync On), each logged | helps: RX 9070 XT, AMD 26.11.1, Windows 11, in a window (+8.4 % fps); full screen there: no wait to hide (0.74 against 0.87 ms presents); untested: NVIDIA, Intel, Linux, the Steam Deck, a 60 Hz desktop, VRR | off for everyone until the Test Farm's runs; then a candidate for on everywhere, since it is one mechanism and not a vendor workaround | ## Testing **Tested:** - In the game, Windows 11, RX 9070 XT, AMD 26.11.1, this PR's renderer at 0ceaa6ab with the switch on, besides the A/B above: - The first reading with the switch on: 600 of 600 presents had an image asked for ahead, 547-600 of them free at their present, never "none given at once": AMD's driver hands an image over at a timeout of 0. - Window toggles: three rounds of the window resized (1600x900, 1000x600, back), F11 to full screen and back, and Insert pressed twice: 17 swapchains made, 14 images asked for ahead let go with their swapchain, no hold, no error line; the log's host lines against the same session without the switch differ only in statistics. - The same toggles with Vulkan validation (`RX_VK_VALIDATION=1`, the Khronos layer, `VK_LAYER_VALIDATE_SYNC=1`): no message about the swapchain, the acquire, the present or fences (the messages there were about shader outputs, image creation and query pools, code this PR does not touch). - Frame generation 2x for about 2 minutes: `acquire ahead: not now, frame generation runs`, interpolation ran, no error line. V-Sync On: `acquire ahead: not now, the swapchain is FIFO`, presents 4.0 ms a frame as before. - #1458's case, full screen with a window over the whole display for 40 s, twice: frames went on, no hold, no hang, no error line, with and without the switch (but see Not tested). - Full screen: presents 0.74-0.75 ms a frame with the switch, 0.87 without. - **Test Farm** ([results](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1574#issuecomment-48803), commit 2f24a499 against main 430eef4f). The plan: - Hyrule Field from a new save, in a window, `vsync=2` (V-Sync Off: the immediate mode, which the switch does not hold off) and frame generation off. - Each report ran one 180 s run a side: main against this PR, without the switch (`field-default`) and with `RX_VK_ACQUIRE_AHEAD=1` on the PR side (`field-acquire-ahead`). - Threaded rendering was on in both reports' logs. The reports came from two PCs: | Report | PC | p99 without the switch (main → PR) | p99 with the switch (main → PR) | stutters with the switch (main → PR) | fps | |---|---|---|---|---|---| | [rp_8db0f25f3bc6c740](https://beanstalk.magicbean.dev/reports/rp_8db0f25f3bc6c740) | Windows, RTX 3090 (621.24.0), Ryzen 9 5900X | 20.30 → 20.65 ms | 20.54 → 25.33 ms | 1 → 13 | 60.0 both (the 60 cap) | | [rp_b854f1dd81aaa143](https://beanstalk.magicbean.dev/reports/rp_b854f1dd81aaa143) | Linux, RTX 4070 (615.71.9), Ryzen 7 5800X3D | 18.91 → 18.96 ms | 18.59 → 18.92 ms | 0 → 1 | 60.0 both | | [rp_bb166040791326c5](https://beanstalk.magicbean.dev/reports/rp_bb166040791326c5) | the same Linux RTX 4070 PC | 19.34 → 18.84 ms | 18.86 → 18.91 ms | 7 → 0 | 60.0 both | - No crash, no forbidden log line, and no picture difference against main. - The NVIDIA cell's "fail" is its fps rule (more than 0 % below main) at the 60 cap: 60.00 → 59.99. - Its p99 of 19.6 → 22.1 ms is the median of the 3090's and the 4070's reports, so the whole rise is the 3090's one run. - Linux's second report ([rp_903bc676955bce4a](https://beanstalk.magicbean.dev/reports/rp_903bc676955bce4a), Arch Linux) timed out before play and has no numbers. - **Whether the switch engaged there is not shown.** The reports publish only the end of one PR-side log. None of those ends has the `vk: the window's image (600 presents)` line, which the switch prints every 600 presents whenever it is set, so they cannot show the switch's state either way. - **Steam Deck OLED** ([dukenheimer](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1574#issuecomment-48993); SteamOS, RADV, 1280x800 through gamescope's mailbox swapchain, Threaded rendering at Auto (off)): the same build on main 430eef4f, the switch unset against `=1`, three interleaved rounds. - It engaged: every counter line in a measured window read 600 free, 0 waited, 0 dropped, 0 none given. - Kokiri, standing, three pairs: fps 25.42 → 25.53 (arm medians, about +0.4 %); p95 lower in all three pairs; frames over 50 ms lower in two and tied in one; p99 and the longest frame mixed. - Hyrule Field: no admitted pair. - No GPU fault or reset. - Not shown: the image wait without the switch, the displayed frames, and the effect of the Deck's memory sampler. - `tests/test_present_acquire_ahead.py`: the order (the next image asked for after the present is queued, never with the queue's lock held, one asked for ahead at most, none while one is held, never with a signaled or pending fence); an image given back after 20 ms (none dropped, waited for no longer than needed); #1458's hidden window (no GPU wait in any copy, no copy into an image not given back, the first hidden present waits exactly 250 ms, shown again once given back); the swapchain made again with an image out, by a resize and by the present's own SUBOPTIMAL; an ahead acquire answered out of date; the gates (frame generation, the presenter thread, FIFO, the start-up screen's presents); NVIDIA-like (the ahead acquire never waits); a lost device at the ahead acquire; with the switch unset or `0`, no counter line. Eleven broken variants each fail for their own reason (among them: the ahead acquire before the present, the wait at the present removed, the drop at a new swapchain removed, each gate removed, the switch's value ignored, the counter run with the switch off). It fails on main and passes here; it passes on Windows (llvm-mingw clang++) and on Linux (WSL Ubuntu, g++ and clang++). #1458's own `tests/test_present_image_free.py` passes (its fixture only given `env_on`). - `python -I -B tests/run_all.py --jobs 4` (Windows, llvm-mingw clang 20261104) on this branch @ 2f24a499 and on main @ 430eef4f: this branch 684 passed, 46 failed, 51 skipped (the Linux-only checks); main 683 passed, 46 failed, 51 skipped. The 46 failures are the same list on both (they fail on this Windows checkout on main too, among them `test_present_thread.py`, whose later check expects an opt-in-only presenter queue, and `test_tested_configurations.py`'s line-ending check of its CLI on Windows); the extra pass is `tests/test_present_acquire_ahead.py`. `test_present_image_free.py` and `test_present_device_loss.py` pass. - At 2f24a499, `gpu/vk/vk_replay.cpp` compiled to an object for Linux (WSL clang 21 with the Linux build's flags) and for Windows (llvm-mingw clang++ 20261104, `-Wall`: one warning, main's own, a `VkClearColorValue` initializer it does not touch); the whole renderer was built with llvm-mingw at 0ceaa6ab for the A/B (210 files, no warnings). The game-free tests pass on WSL Ubuntu with g++ and clang++ at 2f24a499 too. **Not testable by hand:** NVIDIA, Intel, Linux and the Steam Deck: not on this PC. The game-free test's NVIDIA-like model stands in for the "wait inside the acquire" drivers (the ahead acquire never waits there). The Test Farm and a Deck owner ran what is above; the rest is below. **Not tested:** - #1458's hidden-window case with the display on: the run above was made with the display asleep, and AMD's driver then held no image in either arm, so the held-image path was not reached in the game (the game-free test covers it). - The picture: no frame log on against off (a repeated or skipped frame would show there); frame generation's picture with the switch set. - Whether synchronization validation really ran in the validation session (it printed no `SYNC-` message at all), and the same session without the switch. - The Insert menu really opening from the posted key; V-Sync and HDR changed at run time from the menu (V-Sync On was checked from the start). - Threaded rendering Off (Auto turns it off under 12 processor threads, the Steam Deck among them): then the wait is on the game's submitting thread; the switch acts the same way there, but no run was made. - A 60 Hz desktop, VRR, a second monitor, a long session with many resizes. - The third A/B pair (rejected by the harness; not replaced). - Whether the RTX 3090's higher p99 with the switch comes from the switch: one run a side, no engagement line published, and that report also has the larger longest-frame change without the switch (27.2 → 37.0 ms). **Must be tested:** - nvidia, windows: Hyrule Field in a window with V-Sync Off and frame generation off, at least 3 runs a side without and with `RX_VK_ACQUIRE_AHEAD=1` in `longshot_env.txt`. - Expected with the switch: `acquire ahead: on`, and the log's `vk: the window's image` line near 0 ms a present. - Expected: fps not lower, p99 not higher than without the switch, no error line. - The farm's one-run RTX 3090 report is the open question: p99 20.54 → 25.33 ms with the switch, and no engagement line published (Test Farm: @Beanstalk, or a tester). - intel, windows: the same, expecting the same (Test Farm: @Beanstalk; queued, no tester online yet) - linux, radv, X11 and Wayland: the same, and once with the window covered by another for 40 s, expecting frames to resume, no hang. Linux NVIDIA ran on the farm (above). The covered window is by hand, since the farm cannot do it: look for frames coming back and no hang (Test Farm: @Beanstalk for RADV). - steamdeck: Hyrule Field in game mode (gamescope), expecting no lower fps and no stutter. Kokiri ran (above); Hyrule had no admitted pair (Test Farm: @Beanstalk; queued, or by hand: fps, p99 and frames over 50 ms). ## Risks **What could break:** only with the switch set. The swapchain's image is asked for earlier: on a driver that answers a timeout of 0 with "not ready", the switch does nothing (the counter's "none given at once" says so). Swapchain remakes (resize, full screen, HDR, V-Sync) let an image asked for ahead go; its fence is then replaced by a new one when it is not signaled yet, as #1458 does after a 250 ms hold, so one `VkFence` can be left over per remake made in the ~3 ms before the image came back (bounded, a small object; reusing such fences once signaled is a follow-up that would touch #1458's path for everyone). Right after frame generation is turned off its last presents ahead may still hold images, and the image asked for ahead is then one more out, as the next present's own acquire would be without the switch (it cannot block: a timeout of 0). Also left as found: a failed `vkResetFences` (out of memory) after a wait leaves the fence signaled, on #1458's path as on this one. **Turning it off:** leave `RX_VK_ACQUIRE_AHEAD` unset or set `0`. **Compatibility:** Nothing changes for a player: no save, options file, shader or pipeline cache, or vk ABI change (no `vk_api.h` or shader translator file touched). ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (the renderer's file, compiled to objects for both) - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Since #1458 the window's image is waited for on the CPU at its present. With the switch the next
present's image is asked for right after each present, with a timeout of 0 and the queue's lock let go,
so it has the next frame's work to come back in. One image out at most; its present still waits up to
kImageFreeNs for it and then holds it, as #1376's path does; a new swapchain lets it go. Not with frame
generation, the presenter thread or FIFO. Unset or 0: the same Vulkan calls in the same order as before;
a counter line every 600 presents says how long the presents waited for the image.

tests/test_present_acquire_ahead.py: the acquire, copy and end of present_image cut from the source and
run against a model presentation engine (AMD-like and NVIDIA-like), with the switch unset, 0 and 1, and
five broken variants that must fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_present_device_loss routes device loss at the ahead acquire too (ten sites); test_present_thread
reads present_image's end with the present's result kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The swapchain out of date at the ahead acquire (switch off: at the present's own): no image is taken from that answer,
the fence is left as it was, the next present makes the swapchain again and the presents after it copy. Broken variants
that must fail, beside the five before: the frame generation gate removed, the presenter thread's gate removed, an
out-of-date answer to the ahead acquire taken as an image, and the switch's value ignored (run with it unset, so the
check that unset keeps #1458's order is shown to see an ahead acquire).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the window hidden, the first present waits for the image exactly kImageFreeNs and then goes on (before, its time was
not looked at, so a wait without that bound passed). A broken variant with the bound at 30 s must fail. (The sol review
of ef6038ab..0ceaa6ab, job1118-2-r1.md, point 4.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Right after frame generation is turned off its last presents ahead may still hold
images of their own, so the image asked for ahead can be one more out (as the
present's own acquire is without the switch). The comment no longer states an
invariant that transition breaks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The two admitted pairs of the A/B (control and RX_VK_ACQUIRE_AHEAD=1), one file a run,
Hyrule Field's standard test with the fixed background load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CONTRIBUTING.md asks that a switch cost nothing while off. The counter of the window's
image waits (two clock reads a present and a log line every 600 presents) ran for
every player; it now runs with RX_VK_ACQUIRE_AHEAD=1 only, and with the switch unset or
0 present_image makes #1458's calls and nothing else but one read of the switch's
cached value. On Linux the 100 ms acquire that finds the window not shown is now
counted too (the review's point: it returned before the note).

The test checks that unset and =0 log no counter line, with a broken variant that runs
the counter with the switch off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test(vk): #1458's image-free check gives its fixture the switch reader the present now calls
Some checks failed
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
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
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
beanstalk/nvidia 1/1 fail
beanstalk/linux 1/1 pass
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by futondestroyer (reviewed)
beanstalk/intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 0 running, 2 queued
2f24a499ca
present_image reads RX_VK_ACQUIRE_AHEAD (acquire_ahead_set) before its acquire, inside the
helpers the check cuts out; its fixture gets env_on, answering off: #1458's order, which it
checks, unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RX 9070 XT (AMD 26.11.1), Ryzen 7 5700X3D: this PR's renderer (at 0ceaa6ab, before the rebase; same code with the switch set) in Hyrule Field's standard test in a 1280x720 window, 2 pairs against main ef6038ab: 64.6 -> 70.0 fps, game clock 1.000-1.001 both arms, no frame over 100 ms; window resizes, F11 full screen and back, Insert, a Vulkan validation session (no swapchain/acquire/present/fence message), frame generation 2x and V-Sync On (the switch holds off and logs why), and a full-screen window covered for 40 s twice: no error line, no hang.

Tested in game: Windows 11, RX 9070 XT (AMD 26.11.1), Ryzen 7 5700X3D: this PR's renderer (at 0ceaa6ab, before the rebase; same code with the switch set) in Hyrule Field's standard test in a 1280x720 window, 2 pairs against main ef6038ab: 64.6 -> 70.0 fps, game clock 1.000-1.001 both arms, no frame over 100 ms; window resizes, F11 full screen and back, Insert, a Vulkan validation session (no swapchain/acquire/present/fence message), frame generation 2x and V-Sync On (the switch holds off and logs why), and a full-screen window covered for 40 s twice: no error line, no hang.
klimovich008 changed title from WIP: perf(vk): RX_VK_ACQUIRE_AHEAD=1 asks for the window's next image right after a present, so the render thread no longer waits for it (off by default) to perf(vk): RX_VK_ACQUIRE_AHEAD=1 asks for the window's next image right after a present, so the render thread no longer waits for it (off by default) 2026-11-18 10:34:00 +00:00
Author
Contributor

@Beanstalk nvidia, intel, linux, steamdeck: in Hyrule Field, in a window, with V-Sync Off and frame generation off, play 3 minutes without the switch, then 3 minutes with RX_VK_ACQUIRE_AHEAD=1 in longshot_env.txt, and post both runs' fps, your Threaded rendering setting, the switch run's vk: the window's image (600 presents) lines, and with Threaded rendering on both runs' vk: the render thread (600 presents ...) lines. Expect with the switch: acquire ahead: on in the log, the window's image waited for near 0 ms a present, fps not lower. On Linux, also cover the window with another one for 40 s, then uncover it: frames must come back. Fail on a hang, a crash, a lost device, flashing or repeated frames, lower fps, or error lines in the log.

@Beanstalk nvidia, intel, linux, steamdeck: in Hyrule Field, in a window, with V-Sync Off and frame generation off, play 3 minutes without the switch, then 3 minutes with `RX_VK_ACQUIRE_AHEAD=1` in `longshot_env.txt`, and post both runs' fps, your Threaded rendering setting, the switch run's `vk: the window's image (600 presents)` lines, and with Threaded rendering on both runs' `vk: the render thread (600 presents ...)` lines. Expect with the switch: `acquire ahead: on` in the log, the window's image waited for near 0 ms a present, fps not lower. On Linux, also cover the window with another one for 40 s, then uncover it: frames must come back. Fail on a hang, a crash, a lost device, flashing or repeated frames, lower fps, or error lines in the log.
Member

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

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

@klimovich008 Yes, we'll run it on our Steam Deck OLED (SteamOS, RADV, handheld 1280×800, Threaded rendering at Auto, so off). It'll be the same build with RX_VK_ACQUIRE_AHEAD unset vs =1, interleaved, in Kokiri standing and Hyrule Field turning. We'll check engagement from acquire ahead: on and report fps, p99, frames over 50 ms and the vk: the window's image (600 presents) lines.

It's queued after the block that's running on the Deck now, so expect results later today. The Deck presents through gamescope, not a desktop window, so we'll also note the swapchain and present mode from the log, since the acquire wait may look different there.

@klimovich008 Yes, we'll run it on our Steam Deck OLED (SteamOS, RADV, handheld 1280×800, Threaded rendering at Auto, so off). It'll be the same build with `RX_VK_ACQUIRE_AHEAD` unset vs `=1`, interleaved, in Kokiri standing and Hyrule Field turning. We'll check engagement from `acquire ahead: on` and report fps, p99, frames over 50 ms and the `vk: the window's image (600 presents)` lines. It's queued after the block that's running on the Deck now, so expect results later today. The Deck presents through gamescope, not a desktop window, so we'll also note the swapchain and present mode from the log, since the acquire wait may look different there.
Member

Beanstalk test farm

Commit 2f24a49 · tier reviewed · approved by futondestroyer (👍 on klimovich008's request) · dashboard

What will be tested · AI plan (gpt-6.1-terra)

On NVIDIA, Intel, Linux and Steam Deck PCs, the plan compares main and the PR in Hyrule Field for three minutes per run, with acquire-ahead off and on. It measures FPS, frame times and hitches, compares still images, and fails on lower FPS, crashes, device-loss or fatal GPU-hang logs. Intel and Steam Deck targets will wait for matching testers. The headless farm cannot cover and uncover a desktop window, verify repeated frames throughout a run, or enforce the requested per-present wait and threaded-rendering log details. No tester online now matches intel, steamdeck: those targets wait for one.

  • Where: nvidia (1-2 reports), intel (1-2 reports), linux (1-2 reports), steamdeck (1-2 reports).
  • Matrix: 1 cell, each on main and the PR: RX_VK_ACQUIRE_AHEAD 1 (PR only).
  • field-default: from a new save (settings vsync=2, fullscreen=0, frame_generation=0), then teleport to Hyrule Field, take the picture field-default to compare with main, measure field for 3 min (after 10 s warm-up); 1 run on each side.
  • field-acquire-ahead: from a new save (settings vsync=2, fullscreen=0, frame_generation=0), then teleport to Hyrule Field, take the picture field-ahead to compare with main, measure field for 3 min (after 10 s warm-up); 1 run on each side.
  • Measured: crashes, draws and frame rate, frame times, stutters and hitches, the game's log.
  • The PR fails if: it crashes; or frame rate is more than 0% below main; or a picture differs from main by more than 5%; or forbidden log lines is above 0.
  • Time: about 37 min of game runs per tester (4 game starts), plus the two builds.

Started at 13:08 UTC.

Estimate: done in about 1 h 15 min, from the queue and the testers online now; some jobs can't start yet.

Target Reports Crash Frame p99 (ms) vs main VRAM peak (MB) vs main Result
nvidia · 1: windows+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 3090, 621.24.0; 2: linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 4070, 615.71.9 2/1 1 2 none 19.8 vs 19.6 (+1%) — fail ⚠ outlier
intel 0/1 — — — queued
linux · 1: linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 4070, 615.71.9; 2: linux+other unknown, unknown 2/1 1 2 none 18.8 vs 19.3 (−3%) — pass
steamdeck 0/1 — — — queued

Measurements · nvidia

Verdict: fail on nvidia (2/1 report): field-acquire-ahead field.fps_mean.min_delta_pct (+0.0%) failed.

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 3090, 621.24.0 AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 4070, 615.71.9 AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM
Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ 430eef4 After: this PR @ 2f24a49
field-default · field · frame rate 60.0 60.0 (+0%)
field-default · forbidden log lines 0.0 0.0
field-default · field · frame time (p99) (ms) 19.6 19.8 (+1%)
field-acquire-ahead · RX_VK_ACQUIRE_AHEAD=1 (PR only) · field · frame rate 60.0 60.0 (+0%)
field-acquire-ahead · RX_VK_ACQUIRE_AHEAD=1 (PR only) · forbidden log lines 0.0 0.0
field-acquire-ahead · RX_VK_ACQUIRE_AHEAD=1 (PR only) · field · frame time (p99) (ms) 19.6 22.1 (+13%)

Flags and settings

Flag What it is Values tried Before this PR After this PR Effect (frame rate) Helps / doesn't help / untested
RX_VK_ACQUIRE_AHEAD switch the PR adds (set on the PR side only) 1 not in main the PR's default field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) no clear effect
Markdown for the PR description
## Measurements

**Verdict:** fail on nvidia (2/1 report): `field-acquire-ahead field.fps_mean.min_delta_pct (+0.0%)` failed.

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3090, 621.24.0` `AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAM`; 2: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM`  
Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ 430eef4 | After: this PR @ 2f24a49 |
|---|---|---|
| field-default · field · frame rate | 60.0 | 60.0 (+0%) |
| field-default · forbidden log lines | 0.0 | 0.0 |
| field-default · field · frame time (p99) (ms) | 19.6 | 19.8 (+1%) |
| field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame rate | 60.0 | 60.0 (+0%) |
| field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · forbidden log lines | 0.0 | 0.0 |
| field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame time (p99) (ms) | 19.6 | 22.1 (+13%) |

### Flags and settings

| Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame rate) | Helps / doesn't help / untested |
|---|---|---|---|---|---|---|
| `RX_VK_ACQUIRE_AHEAD` | switch the PR adds (set on the PR side only) | `1` | not in main | the PR's default | field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) | no clear effect |

Measurements · linux

Verdict: pass on linux (2/1 report): no rule failed and no PR run crashed.

Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 4070, 615.71.9 AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM; 2: linux+other unknown, unknown AMD Ryzen 7 5700X3D 8-Core Processor, 128 GB RAM
Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ 430eef4 After: this PR @ 2f24a49
field-default · field · frame rate 60.0 60.0 (+0%)
field-default · forbidden log lines 0.0 0.0
field-default · field · frame time (p99) (ms) 19.3 18.8 (−3%)
field-acquire-ahead · RX_VK_ACQUIRE_AHEAD=1 (PR only) · field · frame rate 60.0 60.0 (+0%)
field-acquire-ahead · RX_VK_ACQUIRE_AHEAD=1 (PR only) · forbidden log lines 0.0 0.0
field-acquire-ahead · RX_VK_ACQUIRE_AHEAD=1 (PR only) · field · frame time (p99) (ms) 18.9 18.9 (+0%)

Flags and settings

Flag What it is Values tried Before this PR After this PR Effect (frame rate) Helps / doesn't help / untested
RX_VK_ACQUIRE_AHEAD switch the PR adds (set on the PR side only) 1 not in main the PR's default field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) no clear effect
Markdown for the PR description
## Measurements

**Verdict:** pass on linux (2/1 report): no rule failed and no PR run crashed.

Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM`; 2: linux+other `unknown, unknown` `AMD Ryzen 7 5700X3D 8-Core Processor, 128 GB RAM`  
Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ 430eef4 | After: this PR @ 2f24a49 |
|---|---|---|
| field-default · field · frame rate | 60.0 | 60.0 (+0%) |
| field-default · forbidden log lines | 0.0 | 0.0 |
| field-default · field · frame time (p99) (ms) | 19.3 | 18.8 (−3%) |
| field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame rate | 60.0 | 60.0 (+0%) |
| field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · forbidden log lines | 0.0 | 0.0 |
| field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame time (p99) (ms) | 18.9 | 18.9 (+0%) |

### Flags and settings

| Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame rate) | Helps / doesn't help / untested |
|---|---|---|---|---|---|---|
| `RX_VK_ACQUIRE_AHEAD` | switch the PR adds (set on the PR side only) | `1` | not in main | the PR's default | field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) | no clear effect |
<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `2f24a49` · tier **reviewed** · approved by futondestroyer (👍 on klimovich008's request) · [dashboard](https://beanstalk.magicbean.dev/prs/1574) **What will be tested** · AI plan (`gpt-6.1-terra`) On NVIDIA, Intel, Linux and Steam Deck PCs, the plan compares main and the PR in Hyrule Field for three minutes per run, with acquire-ahead off and on. It measures FPS, frame times and hitches, compares still images, and fails on lower FPS, crashes, device-loss or fatal GPU-hang logs. Intel and Steam Deck targets will wait for matching testers. The headless farm cannot cover and uncover a desktop window, verify repeated frames throughout a run, or enforce the requested per-present wait and threaded-rendering log details. No tester online now matches intel, steamdeck: those targets wait for one. - **Where:** nvidia (1-2 reports), intel (1-2 reports), linux (1-2 reports), steamdeck (1-2 reports). - **Matrix:** 1 cell, each on main and the PR: RX_VK_ACQUIRE_AHEAD `1` (PR only). - **field-default:** from a new save (settings vsync=2, fullscreen=0, frame_generation=0), then teleport to Hyrule Field, take the picture field-default to compare with main, measure field for 3 min (after 10 s warm-up); 1 run on each side. - **field-acquire-ahead:** from a new save (settings vsync=2, fullscreen=0, frame_generation=0), then teleport to Hyrule Field, take the picture field-ahead to compare with main, measure field for 3 min (after 10 s warm-up); 1 run on each side. - **Measured:** crashes, draws and frame rate, frame times, stutters and hitches, the game's log. - **The PR fails if:** it crashes; or frame rate is more than 0% below main; or a picture differs from main by more than 5%; or forbidden log lines is above 0. - **Time:** about 37 min of game runs per tester (4 game starts), plus the two builds. Started at 13:08 UTC. **Estimate:** done in about 1 h 15 min, from the queue and the testers online now; some jobs can't start yet. | Target | Reports | Crash | Frame p99 (ms) vs main | VRAM peak (MB) vs main | Result | | --- | --- | --- | --- | --- | --- | | nvidia · 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3090, 621.24.0`; 2: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9` | 2/1 [1](https://beanstalk.magicbean.dev/reports/rp_8db0f25f3bc6c740) [2](https://beanstalk.magicbean.dev/reports/rp_b854f1dd81aaa143) | none | 19.8 vs 19.6 (+1%) | — | fail ⚠ outlier | | intel | 0/1 | — | — | — | queued | | linux · 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9`; 2: linux+other `unknown, unknown` | 2/1 [1](https://beanstalk.magicbean.dev/reports/rp_bb166040791326c5) [2](https://beanstalk.magicbean.dev/reports/rp_903bc676955bce4a) | none | 18.8 vs 19.3 (−3%) | — | pass | | steamdeck | 0/1 | — | — | — | queued | #### Measurements · nvidia **Verdict:** fail on nvidia (2/1 report): `field-acquire-ahead field.fps_mean.min_delta_pct (+0.0%)` failed. Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3090, 621.24.0` `AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAM`; 2: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM` Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 430eef4 | After: this PR @ 2f24a49 | |---|---|---| | field-default · field · frame rate | 60.0 | 60.0 (+0%) | | field-default · forbidden log lines | 0.0 | 0.0 | | field-default · field · frame time (p99) (ms) | 19.6 | 19.8 (+1%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame rate | 60.0 | 60.0 (+0%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame time (p99) (ms) | 19.6 | 22.1 (+13%) | ### Flags and settings | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame rate) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_ACQUIRE_AHEAD` | switch the PR adds (set on the PR side only) | `1` | not in main | the PR's default | field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) | no clear effect | <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** fail on nvidia (2/1 report): `field-acquire-ahead field.fps_mean.min_delta_pct (+0.0%)` failed. Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3090, 621.24.0` `AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAM`; 2: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM` Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 430eef4 | After: this PR @ 2f24a49 | |---|---|---| | field-default · field · frame rate | 60.0 | 60.0 (+0%) | | field-default · forbidden log lines | 0.0 | 0.0 | | field-default · field · frame time (p99) (ms) | 19.6 | 19.8 (+1%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame rate | 60.0 | 60.0 (+0%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame time (p99) (ms) | 19.6 | 22.1 (+13%) | ### Flags and settings | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame rate) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_ACQUIRE_AHEAD` | switch the PR adds (set on the PR side only) | `1` | not in main | the PR's default | field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) | no clear effect | ``` </details> #### Measurements · linux **Verdict:** pass on linux (2/1 report): no rule failed and no PR run crashed. Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM`; 2: linux+other `unknown, unknown` `AMD Ryzen 7 5700X3D 8-Core Processor, 128 GB RAM` Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 430eef4 | After: this PR @ 2f24a49 | |---|---|---| | field-default · field · frame rate | 60.0 | 60.0 (+0%) | | field-default · forbidden log lines | 0.0 | 0.0 | | field-default · field · frame time (p99) (ms) | 19.3 | 18.8 (−3%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame rate | 60.0 | 60.0 (+0%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame time (p99) (ms) | 18.9 | 18.9 (+0%) | ### Flags and settings | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame rate) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_ACQUIRE_AHEAD` | switch the PR adds (set on the PR side only) | `1` | not in main | the PR's default | field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) | no clear effect | <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** pass on linux (2/1 report): no rule failed and no PR run crashed. Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 4070, 615.71.9` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM`; 2: linux+other `unknown, unknown` `AMD Ryzen 7 5700X3D 8-Core Processor, 128 GB RAM` Scene: field-default, from a new save (vsync=2, fullscreen=0, frame_generation=0); field-acquire-ahead, from a new save (vsync=2, fullscreen=0, frame_generation=0); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-default: 1 game start a side, field 180 s after 10 s warm-up; field-acquire-ahead: 1 game start a side, field 180 s after 10 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 430eef4 | After: this PR @ 2f24a49 | |---|---|---| | field-default · field · frame rate | 60.0 | 60.0 (+0%) | | field-default · forbidden log lines | 0.0 | 0.0 | | field-default · field · frame time (p99) (ms) | 19.3 | 18.8 (−3%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame rate | 60.0 | 60.0 (+0%) | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · forbidden log lines | 0.0 | 0.0 | | field-acquire-ahead · `RX_VK_ACQUIRE_AHEAD=1 (PR only)` · field · frame time (p99) (ms) | 18.9 | 18.9 (+0%) | ### Flags and settings | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame rate) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `RX_VK_ACQUIRE_AHEAD` | switch the PR adds (set on the PR side only) | `1` | not in main | the PR's default | field-acquire-ahead, main without it → the PR with 1: 60.0 → 60.0 (+0%) | no clear effect | ``` </details>
Contributor

@klimovich008 the Steam Deck run you asked for.

Setup: Steam Deck OLED (SteamOS, RADV), built-in 1280×800 display through gamescope's mailbox swapchain, Minimum preset with a fixed 50% render, Threaded rendering at Auto (off). The same build of this PR on main 430eef4f, with RX_VK_ACQUIRE_AHEAD unset (U) vs =1 (A), three interleaved rounds.

  • Engagement: ahead acquisition actually succeeded, and the images were reported ready at their next present. Every A counter line ending inside a measured window read 600 free, 0 waited, 0 dropped, 0 none given.

  • Kokiri standing, three pairs:

    • fps: A was +0.038, +0.171 and +0.071 fps; arm medians 25.42 → 25.53 (about +0.4%, median paired +0.28%);
    • p95: lower by 0.050, 0.559 and 0.791 ms;
    • frames over 50 ms: lower in 2 pairs, tied in 1;
    • p99 and the longest frame: mixed.

    That's a small positive directional signal, not an established practical or general win.

  • Hyrule Field: no admitted measured pair.

  • What this can't show:

    • The U arm's image wait isn't recorded, so there's no before/after wait comparison.
    • Displayed-frame correctness wasn't checked, since the screenshots weren't inspected.
    • An observer effect from our /proc memory sampler is unresolved.
  • No GPU fault or reset in any run.

No default recommendation from this.

@klimovich008 the Steam Deck run you asked for. **Setup:** Steam Deck OLED (SteamOS, RADV), built-in 1280×800 display through gamescope's mailbox swapchain, Minimum preset with a fixed 50% render, Threaded rendering at Auto (off). The same build of this PR on main `430eef4f`, with `RX_VK_ACQUIRE_AHEAD` unset (U) vs `=1` (A), three interleaved rounds. - **Engagement:** ahead acquisition actually succeeded, and the images were reported ready at their next present. Every A counter line ending inside a measured window read 600 free, 0 waited, 0 dropped, 0 none given. - **Kokiri standing, three pairs:** - fps: A was +0.038, +0.171 and +0.071 fps; arm medians 25.42 → 25.53 (about +0.4%, median paired +0.28%); - p95: lower by 0.050, 0.559 and 0.791 ms; - frames over 50 ms: lower in 2 pairs, tied in 1; - p99 and the longest frame: mixed. That's a small positive directional signal, not an established practical or general win. - **Hyrule Field:** no admitted measured pair. - **What this can't show:** - The U arm's image wait isn't recorded, so there's no before/after wait comparison. - Displayed-frame correctness wasn't checked, since the screenshots weren't inspected. - An observer effect from our /proc memory sampler is unresolved. - **No GPU fault or reset** in any run. No default recommendation from this.
Author
Contributor

@dukenheimer, thank you: that is the case I could not run here (gamescope's mailbox swapchain, threaded rendering off). How I read it:

  • It engages on the Deck: 600 of 600 images free at their present, none waited or dropped.
  • Kokiri: +0.4 % fps with lower p95 in all three pairs, which is within what three pairs can call. So no gain is claimed for the Deck, and it does no harm there. No GPU faults.

I'll add it to Testing. The farm's NVIDIA cell shows p99 19.6 -> 22.1 ms with the switch set (its fps rule fails at +0.0 % because both sides sit at the 60 cap). I'm checking whether the switch was engaged in those runs at all, and I'll report here.

@dukenheimer, thank you: that is the case I could not run here (gamescope's mailbox swapchain, threaded rendering off). How I read it: - **It engages on the Deck:** 600 of 600 images free at their present, none waited or dropped. - **Kokiri:** +0.4 % fps with lower p95 in all three pairs, which is within what three pairs can call. So no gain is claimed for the Deck, and it does no harm there. No GPU faults. I'll add it to Testing. The farm's NVIDIA cell shows p99 19.6 -> 22.1 ms with the switch set (its fps rule fails at +0.0 % because both sides sit at the 60 cap). I'm checking whether the switch was engaged in those runs at all, and I'll report here.
Author
Contributor

Following up on my comment above about the farm's NVIDIA cell. I went through the four reports.

Did the switch engage? The settings allowed it, but the reports don't show it.

  • The farm ran vsync=2, which is V-Sync Off (the immediate mode), with frame generation off. Threaded rendering was on. The switch holds off only for FIFO (V-Sync On), frame generation and the presenter thread, so from the source it should have engaged wherever RX_VK_ACQUIRE_AHEAD=1 reached the game.
  • The reports publish only the end of one PR-side log. With the switch set, vk: the window's image (600 presents) is printed every 600 presents whether or not it engages, and none of the published log ends has that line. So the reports can't show whether the switch was on in the measured runs, either way.

Is the p99 rise real? It comes from one run on one PC. That run neither proves nor rules out an effect.

  • The cell's 19.6 → 22.1 ms is the median of two reports:
  • The 4070's second report (the Linux cell, rp_bb166040791326c5) has 18.86 → 18.91 ms, with stutters 7 → 0.
  • Each report is one 180 s run a side.
  • The farm marks the 3090 report as disagreeing with its peers. Without the switch, that report's PR run also had the larger longest-frame change (27.2 → 37.0 ms).
  • So the rise is the 3090's single run, and I can't say from it whether the switch caused it. Settling it needs repeat runs on an NVIDIA Windows PC with the switch's log lines visible.
  • The cell's "fail" is the fps rule at the 60 cap: 60.00 → 59.99.

Testing now has the farm's three reports with their p99, stutters and fps, and the Arch Linux report that timed out before play. It also has the Steam Deck run (thank you @dukenheimer): engaged, Kokiri about +0.4 % fps, no GPU faults, Hyrule with no admitted pair. Must be tested lists the NVIDIA repeat as the open question. No code changed (head 2f24a499).

Following up on [my comment above](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1574#issuecomment-49627) about the farm's NVIDIA cell. I went through the four reports. **Did the switch engage?** The settings allowed it, but the reports don't show it. - The farm ran `vsync=2`, which is V-Sync **Off** (the immediate mode), with frame generation off. Threaded rendering was on. The switch holds off only for FIFO (V-Sync On), frame generation and the presenter thread, so from the source it should have engaged wherever `RX_VK_ACQUIRE_AHEAD=1` reached the game. - The reports publish only the end of one PR-side log. With the switch set, `vk: the window's image (600 presents)` is printed every 600 presents whether or not it engages, and none of the published log ends has that line. So the reports can't show whether the switch was on in the measured runs, either way. **Is the p99 rise real?** It comes from one run on one PC. That run neither proves nor rules out an effect. - The cell's 19.6 → 22.1 ms is the median of two reports: - [the Windows RTX 3090](https://beanstalk.magicbean.dev/reports/rp_8db0f25f3bc6c740): 20.54 → 25.33 ms, stutters 1 → 13. - [the Linux RTX 4070](https://beanstalk.magicbean.dev/reports/rp_b854f1dd81aaa143): 18.59 → 18.92 ms. - The 4070's second report (the Linux cell, [rp_bb166040791326c5](https://beanstalk.magicbean.dev/reports/rp_bb166040791326c5)) has 18.86 → 18.91 ms, with stutters 7 → 0. - Each report is one 180 s run a side. - The farm marks the 3090 report as disagreeing with its peers. Without the switch, that report's PR run also had the larger longest-frame change (27.2 → 37.0 ms). - So the rise is the 3090's single run, and I can't say from it whether the switch caused it. Settling it needs repeat runs on an NVIDIA Windows PC with the switch's log lines visible. - The cell's "fail" is the fps rule at the 60 cap: 60.00 → 59.99. **Testing** now has the farm's three reports with their p99, stutters and fps, and the Arch Linux report that timed out before play. It also has the Steam Deck run (thank you @dukenheimer): engaged, Kokiri about +0.4 % fps, no GPU faults, Hyrule with no admitted pair. Must be tested lists the NVIDIA repeat as the open question. No code changed (head `2f24a499`).
Some checks failed
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
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
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
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
beanstalk/nvidia 1/1 fail
beanstalk/linux 1/1 pass
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by futondestroyer (reviewed)
beanstalk/intel 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 0/1 pass, 0 running, 2 queued
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/acquire-ahead:klimovich008-perf/acquire-ahead'
git switch 'klimovich008-perf/acquire-ahead'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!1574
No description provided.