perf(vk): the Steam Deck's GPU held at amdgpu's peak power state while the game runs (RX_VK_GPU_CLOCK, on by default on the Deck) #1053

Merged
HumanBean merged 7 commits from zeldaootr/Longshot:gpu-peak-power-state into main 2026-11-16 17:48:59 +00:00
Contributor

Type: perf · Risk: low · Tested on: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH), ours and dukenheimer's; Steam Deck LCD (omgitsgela); RX 580 with RX_VK_GPU_CLOCK=peak (Linux, RADV, HumanBean); Linux x86-64 game-free checks; the renderer built for Windows (llvm-mingw) · Needs: none (follow-ups on a Deck by hand, not gates: battery and a long session)

Why

On the Steam Deck the GPU's automatic clocks do not keep up with the game. The frame waits on reads of GPU results, the GPU looks idle for a moment, and its clock drops: in Kokiri Forest it spends about 30% of the time at 1040 MHz, about 27% at 200 MHz and the rest in between. Held at 1300 MHz, the same frame takes 32 ms of GPU time instead of 58, and Kokiri Forest at handheld settings goes from 11.1 to 16.2 fps on a Deck OLED, with no frame over 100 ms where there were 130 to 170 in 45 s. The kernel lets any program ask for this clock for itself, with no root and no system setting written, and gives it back when the program ends. See #716, which asks for a way for the game to raise the Deck's GPU clock.

The idea, the code and the first measurements are sheep's. They built it in their fork, https://git.magicbean.dev/sheep/BunnyHood (GPL-3.0), commit sheep/BunnyHood@16db7519a8, and measured it on a Deck LCD (their numbers are below, labelled as theirs). Their commit is here as they wrote it (cherry-pick -x, their authorship kept), with a [port: ...] line for the fork's names mapped to Longshot's. The one code change of ours makes it opt-in. sheep is welcome to take this PR over, send commits to it, or leave it with us.

On by default on the Steam Deck (RX_VK_GPU_CLOCK=0 turns it off). This is a power decision on a handheld. In Kokiri Forest the APU is already at its 15 W limit, so the gain costs no more power there. In Hyrule Field it is not, and the same clock costs 4 W more. It was first ported opt-in; HumanBean made it the Deck's default at review (e91acea6; the decision: #1053 (comment)), with the battery and long-session runs as a follow-up. Off the Deck it stays asked for by name.

The tracker was searched (RX_VK_GPU_CLOCK, "GPU clock", "peak power", "stable pstate", "power state", "pin the GPU", priv-write): #716 (the issue; omgitsgela proposes there a different way, SteamOS's steamos-priv-write helper writing the level, and offers to build it) and #968 (the Deck playbook, merged, which documents setting the clock by hand) came up. No other pull request does this.

What changed

On a Steam Deck whose GPU power level is auto (by default, or RX_VK_GPU_CLOCK=1), the renderer asks the kernel's amdgpu driver, through an amdgpu context of its own on the GPU's render node, to hold the GPU at its peak stable power state (1300 MHz on the Deck) while the game runs. The kernel gives the level back when the game's file on the render node closes, which happens when the game exits, crashes or is killed. Off the Deck, unset, nothing is opened, read or asked: everything is as on main. RX_VK_GPU_CLOCK=0 is main on the Deck too.

  • vk, the request (sheep's commit): gpu/vk/vk_gpu_clock.cpp gpu_clock_device_created, called once from create_device in gpu/vk/vk_main.cpp after the device is made. It finds the device's render node from VK_EXT_physical_device_drm, reads /sys/dev/char/<major>:<minor>/device/power_dpm_force_performance_level, opens /dev/dri/renderD<minor> (checking it is that device), makes an amdgpu context (DRM_IOCTL_AMDGPU_CTX, AMDGPU_CTX_OP_ALLOC_CTX) and sets its stable power state (AMDGPU_CTX_OP_SET_STABLE_PSTATE). The file stays open until the process ends; nothing is submitted on the context. The ioctl is written out, so the build needs neither libdrm nor the kernel's headers (a build on Ubuntu 22.04's headers, the release sysroot's, has the whole feature); the test compares it with <drm/amdgpu_drm.h> where the system has it. One log line says what it did. Linux only: on Windows the function is empty.
  • vk, the rule (sheep's commit): gpu/vk/gpu_clock.h choose, no Vulkan and no system calls. The peak only on the Deck's APU (Custom GPU 0405 or 0932, or Steam's SteamDeck=1) and only while the level is auto, so a level someone chose (manual, high, a profile) stays theirs. RX_VK_GPU_CLOCK=peak or standard asks for that state on any AMD GPU, whatever its level, for measuring elsewhere.
  • HumanBean's commit at review (e91acea6): unset is the Deck's rule on the Deck's own APU (deck_apu: Custom GPU 0405 or 0932, by its name), and nothing is read elsewhere (looked_at). Another handheld with Steam's SteamDeck=1 needs =1: it was not measured. tests/test_gpu_clock.cpp checks unset on the Deck (the peak, a chosen level left alone, an unread level), on a SteamDeck=1 handheld and on another AMD GPU; tests/test_gpu_clock.py checks that the APU is known before the early return. The doc row and docs/steam-deck-playbook.md say so.
  • Our commit (1f692f10, off by default before e91acea6): unset, empty, 0 or off is the driver's own clocks on every GPU, with nothing opened or read and no log line; =1 is the fork's Deck rule. SteamDeck=1 counts only on an integrated GPU, as auto_profile's hw.handheld does, since Steam sets it in Gaming Mode on desktops with a discrete card too.
  • tests: tests/test_gpu_clock.cpp (the rule's cases, unset and =1, SteamDeck=1 on a discrete card, the ioctl's numbers against the kernel's header) and tests/test_gpu_clock.py (the call after the device is made, the level read before the choice, the file kept open once the state is held, the early return when unset). The check builds the rules twice, the second time against a copy of the system's header without the stable power states, as before Linux 5.18 (Ubuntu 22.04's linux-libc-dev 5.15, where it failed to compile: dukenheimer's report). Where the header lacks them, test_gpu_clock.cpp writes their numbers as the kernel's UAPI gives them and still checks the rest of the ioctl against it (1c25587b the check, failing; fda1b886 the fix).
  • docs: the switch's row in docs/development.md (with ac385b8e: the peak state's 1300 MHz is below the 1600 MHz a clock set by hand reaches), and nine run files in docs/tested/ (2026-11-16-gpu-clock-zeldaootr-*, a commit of ours). The fork's row in docs/tested-configurations.md is left out: that table is frozen here.

Measurements

Verdict: helps on the Steam Deck OLED and LCD, against automatic clocks. Kokiri Forest at handheld settings: 11.12 -> 16.21 fps (+45.8%), 1% low 6.77 -> 12.06, no frame over 100 ms, at the same ~15 W. Hyrule Field native: 14.98 -> 17.88 fps (+19.4%), 1% low 13.19 -> 14.75, for 4.0 W more. The power level was auto again after every exit and after a kill -9. Two testers confirmed it since, on this PR's commits: a Deck LCD (omgitsgela: +7.7% standing, +10-20% turning, with noise) and a Deck OLED play build at native with frame generation (dukenheimer: +27%, about 4 W more). It is not the Deck's top clock: the peak state is 1300 MHz, and a clock of 1600 MHz set by hand did as well or better at about the same power (dukenheimer, below). The switch is for a player who doesn't set the clock themselves; amdgpu offers a program nothing higher without root. Off the Deck, RX_VK_GPU_CLOCK=peak on a desktop RX 580 took GPU time down 9-11% and fps up 7-12% in every phase of two interleaved rounds, with no root and the level auto again after every run (HumanBean); its power was not measured, so peak beyond the Deck stays a separate question.

Baseline: both columns are one renderer pack built with scripts/dev_packs.py on the Deck's development base, main 9c9d69ed, as Testing a change against a base describes: 9c9d69ed plus this PR's gpu/ diff (local tree ed4549ea, renderer longshot_vk.so sha256 d79401a56fab6f6ebb340857c297a4c9a390686c1280d8fb084b2e49ff867e62, the game binary main's). "Before" is that pack with RX_VK_GPU_CLOCK unset, which is main's path (nothing is asked or read, no log line); "After" is =1. The pack is on an older main than this PR, but the PR's code in it is the same: gpu/vk/gpu_clock.h, gpu/vk/vk_gpu_clock.cpp and gpu/vk/vk_gpu_clock.h are byte-identical (the same git blobs) to this PR's head, and this PR's gpu/ diff is the pack's line for line, the four lines in vk_main.cpp included. Why the result holds on today's main: what the change does, asking the kernel for a power state once at start-up, does not depend on the renderer, and the level's behaviour (held, then auto again) is the kernel's. The renderer's commits since 9c9d69ed change how much GPU work a frame has, so the absolute fps and the size of the gain on today's main will differ from these; the direction holds as long as the GPU's clock is what the frame waits on.
Hardware: Steam Deck OLED, AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel (git-5c65d4fc31), SteamOS 3.9.5 (20261023.100, kernel 7.2.7-valve2), Zen 2 4C/8T, 16 GB shared; plugged in, headless, nothing else running
Scene: Kokiri Forest, the child save's spot outside Link's house (~2,200 draws a frame), handheld settings: output 1280x720, render resolution 50%, the game's own upscaler, frame generation off. Hyrule Field, native: 1280x800, render resolution 100%, the game's upscaler, frame generation off. No frame rate cap (headless); precompile off with warm caches
Method: one session on 2026-11-16, 03:30-04:04 UTC. For each scene, after a warm-up run, interleaved off, on, on, off; 75 s warm-up then 45 s standing; the median of each arm. fps and frame times from the present trace (HOS_PRESENT_TRACE) over the 45 s sample. 1% low: 1000 divided by the mean of the slowest 1% of present intervals in that same sample (5 to 9 intervals a run). GPU time and host waits from the log's vk: GPU time and host time in GPU resource waits lines inside the sample. GPU clock, busy, APU power (power1_average) and temperature from sysfs at 10 Hz. power_dpm_force_performance_level read (never written) every 2 s for the whole session
How to reproduce: the child Kokiri save; RX_VK_GPU_CLOCK=1 against unset, nothing else in the environment but RX_VK_PRECOMPILE=0, warm caches copied fresh into each run, no longshot_env.txt; Hyrule Field by teleport from the same save; read /sys/class/drm/card*/device/power_dpm_force_performance_level before, during and after

Kokiri Forest, handheld (median of 2 runs each) Before, RX_VK_GPU_CLOCK unset: dev pack on main 9c9d69ed @ ed4549ea After, RX_VK_GPU_CLOCK=1: dev pack on main 9c9d69ed @ ed4549ea
fps (runs) 11.12 (10.85, 11.39) 16.21 (16.16, 16.26), +45.8%
1% low fps (runs) 6.77 (6.68, 6.86) 12.06 (11.97, 12.14), +78%
frame time p50 / p95 / p99 83.4 / 128.5 / 140.8 ms 60.8 / 72.9 / 80.6 ms
frames over 100 ms in 45 s 170, 131 0, 0
GPU time a frame 58.1 ms 31.9 ms
host waits on the GPU a frame 53.8 ms 25.5 ms
a waited readback 22.0 ms each 8.7 ms each
GPU clock in the sample 1040 MHz 31%, 200 MHz 27%, the rest between (median of the two runs' shares) 1300 MHz, 100% of samples
GPU busy 79% 58%
APU power mean (max) 14.84 W (17.41) 15.02 W (18.32)
APU temperature max 69 C 72 C
Hyrule Field, native (median of 2 runs each) Before, RX_VK_GPU_CLOCK unset: dev pack on main 9c9d69ed @ ed4549ea After, RX_VK_GPU_CLOCK=1: dev pack on main 9c9d69ed @ ed4549ea
fps (runs) 14.98 (15.01, 14.95) 17.88 (17.83, 17.93), +19.4%
1% low fps (runs) 13.19 (12.77, 13.60) 14.75 (14.98, 14.51), +11.8%
frame time p50 / p95 / p99 66.6 / 70.4 / 73.4 ms 55.8 / 59.2 / 61.5 ms
frames over 100 ms in 45 s 0, 0 0, 1
GPU time a frame 45.0 ms 35.9 ms
GPU clock in the sample 1040 MHz 88%, 200 MHz 12% 1300 MHz, 100% of samples
GPU busy 74% 70%
APU power mean (max) 8.14 W (13.06) 12.17 W (17.53), +4.0 W
APU temperature max 63 C 72 C

The power level (power_dpm_force_performance_level, read every 2 s, never written): auto before the series and through every off run. In every on run, profile_peak (1300 MHz) from the first or second sample after the game started until it exited, and auto again within one 2 s sample of the exit:

run profile_peak from last profile_peak auto again the game's exit
gc-on-kH-1 03:34:29 03:37:59 03:38:01, 200 MHz 03:38:01
gc-on-kH-2 03:38:22 03:42:00 03:42:02 03:42:03
gc-on-fN-1 03:50:17 03:53:55 03:53:57, 200 MHz 03:53:59
gc-on-fN-2 03:54:14 03:57:50 03:57:52 03:57:52
gc-kill-1, kill -9 30 s after the line 04:02:39 04:03:08, 1300 MHz 04:03:09, 200 MHz; still auto 5 s and 20 s after killed

No kernel line about amdgpu or drm in the journal during the killed run. No device fault, VK_ERROR or validation line in any run; every timed run exited 0.

sheep's numbers, from BunnyHood (their commit message), not from this branch: Steam Deck LCD, Kokiri Forest standing, three interleaved runs each.

Steam Deck LCD, Kokiri Forest (sheep's, in BunnyHood) Automatic clocks Peak power state
median fps 11.7 13.9 (+19%)
1% low fps 10.4 12.0
GPU time a frame 57.4 ms 46.5 ms
GPU clock in play ~1040 MHz 1300 MHz
APU power ~9 W ~13.4 W (cap 15 W)

The OLED gains more than the LCD did in Kokiri Forest: there the OLED's automatic clocks fell to 200 MHz over a quarter of the time, where sheep's LCD held ~1040.

Testers' runs since, on this PR's two code commits (their numbers, from their comments; not ours):

omgitsgela, Steam Deck LCD (VANGOGH, SteamOS 3.x, Mesa 26.2.0-devel), desktop mode, stock clocks, a pack of their LCD runtime's base a4821d56 plus this PR's two code commits; the Kokiri Village benchmark save, standing then a steady camera spin, off, on, on, off (#1053 (comment)):

Deck LCD (omgitsgela) off 1 on 1 on 2 off 2
standing fps 23.3 24.4 24.4 22.0
turning fps 20.8 19.8 25.4 17.9

Standing, every on run is above every off run (+7.7% by the mean); turning, +16.8% by the mean but with about 3 fps of noise between runs (their reading: "idle always up ~8%, spin up ~10-20% with noise"). The log line was in every on run, the level profile_peak through each and auto within 4 s of each exit. On the LCD, too, the peak state tops out at 1300 MHz, where the high level and the automatic clocks' boost reach 1600.

dukenheimer, Steam Deck OLED (Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel, SteamOS 3.9.5), docked, Game Mode, a Deck play build (v3.0.0-rc.5 with this PR and nine others, the release toolchain), output 1280x800, the game's upscaler at 100%, frame generation 3x, RX_VK_READBACK_LATE=newest; their moving Kokiri route (80 s), 2 interleaved runs each (#1053 (comment)):

Deck OLED, native, frame generation 3x (dukenheimer) unset, automatic clocks =1 (1300 MHz) unset, 1600 MHz set by hand (manual)
game fps 13.4 / 12.7 17.3* / 15.8 17.3 / 17.3*
shown fps (3x) 37.7 / 36.0 50.5* / 45.7 51.0 / 51.2*
p99 (ms) 129.8 / 144.3 92.1 / 111.9 92.6 / 81.9
frames over 100 ms 77 / 92 36 / 48 34 / 31
GPU clock while busy (median) 1040 MHz 1300 MHz 1600 MHz
APU power, mean 9.8 / 8.8 W 13.5 / 13.2 W 13.3 / 13.8 W

* These runs went indoors for the last part of the route; the others stayed outside. =1 against automatic clocks: median 16.55 against 13.05 fps (+27%) for about 4 W more. The manual 1600 MHz did as well or better at about the same power: outside, 17.3 against =1's 15.8; with the indoor parts, 17.3 each. With #906's soa layout on top: =1 16.9 / 18.0, manual 1600 MHz 18.1 / 18.2.

Ours, with #977's early reads and #906's layout in one pack (same Deck OLED, Hyrule Field native, two runs each, empty shader caches; #1053 (comment)): nothing on 15.07 fps at 8.2 W, the hold alone 17.81 at 12.3 W, the other two 20.99 at 9.4 W, all three 24.64 at 13.6 W. The hold still pays once the readback waits are gone.

HumanBean, RX_VK_GPU_CLOCK=peak on a desktop card (#1053 (comment); their numbers): RX 580 8 GB (Polaris10), RADV/amdgpu, KDE, run as a normal user with no root; a build of this PR merged with main c167ec67, with #384 and #906 in it, each behind its own switch; =peak against unset, two interleaved rounds, plus main's own build (the same as unset); Kokiri Forest, Hyrule Field, the Market and Hyrule Field again, standing then turning:

RX 580, GPU ms (fps) (HumanBean) unset (2 runs) =peak (2 runs)
Kokiri, standing 35.60, 35.70 (21.0, 20.8) 32.20, 31.70 (23.1, 23.4)
Kokiri, turning 32.00, 31.65 (22.9, 22.2) 28.30, 28.30 (25.0, 25.0)
Hyrule Field, standing 24.00, 24.30 (28.5, 27.0) 21.85, 21.40 (29.7, 31.3)
Hyrule Field, turning 19.90, 19.90 (34.6, 33.5) 17.90, 17.90 (37.3, 37.6)
the Market, standing 28.80, 28.50 (24.2, 24.1) 25.95, 25.40 (26.2, 27.1)
the Market, turning 18.40, 17.35 (39.2, 35.8) 15.85, 15.90 (41.9, 39.2)
Hyrule Field again, turning 20.10, 20.50 (33.9, 32.0) 18.10, 17.70 (36.1, 38.4)

GPU time 9 to 11% lower and fps 7 to 12% higher in every phase and both rounds. The log had vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=peak; the power level auto -> profile_peak) and the level read auto again after every run. =1 does nothing there (not a Deck), as designed. Board power and temperature were not measured, so this says the desktop card's automatic level leaves performance unused, not what holding the peak costs.

on runs, once each:
vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=1 on the Steam Deck's APU; the power level auto -> profile_peak). RX_VK_GPU_CLOCK=0 leaves the clocks to the driver
off runs: no "vk: GPU clock" line

run          fps   p50  p95   p99   >100ms gpu_ms waits  clock samples (MHz x n)    APU W
gc-off-kH-1  10.85 86.6 131.1 141.8 170    59.7   54.98  1040x133 200x131 of 450    14.87
gc-on-kH-1   16.16 61.1 73.4  80.9  0      32.0   25.91  1300x450 of 450            15.03
gc-on-kH-2   16.26 60.5 72.4  80.3  0      31.8   25.12  1300x449 of 449            15.00
gc-off-kH-2  11.39 80.1 125.9 139.8 131    56.55  52.59  1040x150 200x115 of 450    14.81
gc-off-fN-1  15.01 66.4 70.4  74.2  0      44.9   38.39  1040x395 200x55 of 450     8.17
gc-on-fN-1   17.83 56.0 59.2  61.3  0      36.1   29.58  1300x451 of 451            12.11
gc-on-fN-2   17.93 55.5 59.2  61.7  1      35.6   28.99  1300x450 of 450            12.22
gc-off-fN-2  14.95 66.7 70.3  72.6  0      45.1   38.85  1040x394 200x56 of 450     8.11

gc-kill-1
04:02:33 before: auto | 1: 1040Mhz
04:03:08 during (30 s after the line): profile_peak | 2: 1300Mhz
kill -9 of the game's process
04:03:09 right after the kill: auto | 0: 200Mhz
04:03:14 5 s after: auto | 0: 200Mhz
04:03:29 20 s after: auto | 0: 200Mhz

Flags and settings

One switch is added, on by default on the Steam Deck's APU only: elsewhere nothing changes unless it is set.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_GPU_CLOCK amdgpu's stable power state, held while the game runs (Linux, AMD) absent the peak on a Steam Deck whose level is auto, by default; =0 off; =1 the same rule, with SteamDeck=1 handhelds too; peak or standard that state on any AMD GPU The Deck's GPU at 1300 MHz instead of automatic clocks (200-1040 MHz, boosting to 1600 at times); the same power where the APU is at its 15 W limit, about 4 W more where it is not Helps the Deck OLED (+45.8% Kokiri handheld, +19.4% Field native; +27% at native with frame generation, dukenheimer's) and the Deck LCD (+19% Kokiri in sheep's fork; +8% standing on this PR's commits, omgitsgela's); a clock of 1600 MHz set by hand does as well or better, and =1 leaves such a level alone; peak on a desktop RX 580: GPU time -9 to -11%, fps +7 to +12% (HumanBean), power not measured; untested on battery, over a long session, standard anywhere, and peak on other AMD GPUs On by default on the Deck (shipped so); peak beyond the Deck after a valid run on RDNA (warm caches) showing no cap below the boost clock, and a power figure

Testing

Tested:

  • In the game, Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel), plugged in: Kokiri Forest at handheld settings and Hyrule Field native, RX_VK_GPU_CLOCK unset against =1, 2 runs each interleaved, plus one run killed with kill -9: the numbers and the power level above. The code is this PR's, in a renderer pack on main 9c9d69ed (see Baseline).
  • Steam Deck LCD, by omgitsgela, and a Deck OLED play build at native with frame generation, by dukenheimer: on this PR's two code commits (Measurements).
  • RX_VK_GPU_CLOCK=peak on a desktop RX 580 (Linux, RADV, no root), by HumanBean: this PR merged with main c167ec67, two interleaved rounds against unset in four places, the log line in every =peak run and the level auto again after each (Measurements; #1053 (comment)).
  • Game-free, Linux x86-64, on this head: tests/test_gpu_clock.py with CXX=g++ (13.3) and CXX=clang++ (23.1.5), the ioctl's numbers checked against the system's <drm/amdgpu_drm.h> (Linux 6.8's) and against a copy of it without the stable power states, as before Linux 5.18: passes with both. At 1c25587b (the check alone) the second build fails as dukenheimer saw on Ubuntu 22.04 (AMDGPU_CTX_STABLE_PSTATE_NONE, _STANDARD, _PEAK and AMDGPU_CTX_OP_SET_STABLE_PSTATE not declared); at fda1b886 it passes and says the header is from before 5.18.
  • The full suite: python3 -I -B tests/run_all.py (clang++ 23.1.5, the Vulkan and SPIR-V headers found) on ac385b8e: 619 passed, 19 failed, 26 skipped. 17 fail on main e4d035e9 too, run there the same way: test_bug_report_defaults, test_crt_options, test_fsr_uniform_ownership, test_guest_imported, test_import_reach, test_linux_preflight, test_linux_update, test_make_game_cache, test_missing_nup, test_mods_size_table, test_nonuniform_image_arrays, test_parallel_init_order, test_pending_guest_import, test_replay_write_order, test_run_all_changed, test_vk_occlusion_queries and test_walk_key. The other two, test_seed_reader and test_recorder_sync (a timeout), failed only under the full run's load (a load average over 40) and both pass run alone on this head (with test_gpu_clock) Before those commits, at e8e49640: python3 -I -B tests/run_all.py --changed forge/main (the 52 checks that read what changed) with each compiler, and one full python3 -I -B tests/run_all.py: --changed: 50 passed, 2 failed, 5 skipped with each compiler; the full run: 570 passed, 12 failed, 82 skipped. Every failure also fails on main e4d035e9 (run there the same way): test_bug_report_defaults, test_crt_options, test_guest_imported, test_linux_preflight, test_linux_update, test_make_game_cache, test_missing_nup, test_mods_size_table, test_pending_guest_import, test_run_all_changed, test_vk_occlusion_queries and test_walk_key in the full run; test_vk_occlusion_queries and test_walk_key in --changed, with both compilers.
  • The renderer built and linked for Windows with llvm-mingw 20261104 (RX_VK_ONLY=1 RX_TARGET=windows: longshot_vk.dll) on this head, and for Linux by the pack above.

Not tested:

  • On battery, and a long session's temperature and battery drain: every run was on the charger, with 45 s samples.
  • The Deck LCD in Game Mode (omgitsgela's run was in desktop mode).
  • A level set by hand (manual, high) being left alone: the code path was read, not run.
  • standard on any AMD GPU, and peak on AMD GPUs other than the Deck and the RX 580.
  • The RX 580's board power and temperature with peak: what offering it beyond the Deck would cost.
  • Windows in the game: unaffected by construction (gpu_clock_device_created is empty there, and nothing else reads the switch).
  • Follow-up, steamdeck, SteamOS, on battery: 20 minutes of play with RX_VK_GPU_CLOCK unset (the default) against 20 minutes with =0, expecting the drain and the APU temperature to rise by about what the APU power above says (the same in Kokiri Forest at the 15 W limit, about 4 W more in Hyrule Field), no throttling below the automatic clocks, and the level auto after exit (by hand: the battery percentage, the APU power and temperature, the fan)
  • Follow-up, steamdeck, SteamOS: the GPU clock set by hand in the Quick Access menu (the level manual), then the game with RX_VK_GPU_CLOCK unset, expecting the GPU's power level was chosen (not auto): it stays in the log and the level still manual after exit (by hand)

Must be tested: None. By the maintainer's decision (#1053 (comment)) the battery and long-session runs and the manual level's check are follow-ups, under Not tested.

Risks

What could break: on the Steam Deck by default, elsewhere only with RX_VK_GPU_CLOCK=1, peak or standard set:

  • More power and heat on a handheld: the same power in Kokiri Forest, where the APU was already at its 15 W limit, but 4 W more in Hyrule Field, and 3 to 9 C warmer, so a shorter battery life wherever the automatic clocks would have stayed under the limit.
  • A profiling power state also turns off the GPU's power and clock gating while it is held (by our reading of amdgpu), so a paused game or a menu draws more than with automatic clocks too. Not measured.
  • peak or standard asked by name over a level someone set by hand (manual, high): what the kernel gives back at exit is auto, not their level. =1 never asks over a chosen level.
  • Someone or SteamOS writing power_dpm_force_performance_level while the game runs wins: the context's hold is dropped, and nothing is changed back over their choice at exit.
  • It does not reach the Deck's top clock: the peak state is 1300 MHz on the Deck (OLED and LCD), where a clock set by hand reaches 1600 and did as well or better at about the same power (dukenheimer's run). amdgpu lets a program ask, without root, only for its stable power states (none, standard, the lowest shader or memory clock, peak), and none is higher. A player who sets 1600 MHz in Steam's performance settings gets more than =1, and =1 leaves that level alone.
  • Only one process may hold a stable state at a time: a profiler holding one (RGP, RADV_PROFILE_PSTATE) makes amdgpu refuse ours, and the log says so.

Turning it off: RX_VK_GPU_CLOCK=0.

Compatibility: Nothing changes: no shader translator file (the shader caches stay valid), MKWVK_API_VERSION unchanged (vk_api.h untouched), no option, ini key or menu row.

Issues

See #716

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).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main: at review onto 26ce01b5, commit by commit with no conflict, head e91acea6 (the default on top). Before that: on e4d035e9; merges with current main 71b1edd8 without a conflict (git merge-tree).
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). Run at ac385b8e; e91acea6 was not run (a code-only review): tests/test_gpu_clock.py is the check it changes. (python3 -I -B tests/run_all.py (clang++ 23.1.5, the Vulkan and SPIR-V headers found) on ac385b8e: 619 passed, 19 failed, 26 skipped. 17 fail on main e4d035e9 too, run there the same way: test_bug_report_defaults, test_crt_options, test_fsr_uniform_ownership, test_guest_imported, test_import_reach, test_linux_preflight, test_linux_update, test_make_game_cache, test_missing_nup, test_mods_size_table, test_nonuniform_image_arrays, test_parallel_init_order, test_pending_guest_import, test_replay_write_order, test_run_all_changed, test_vk_occlusion_queries and test_walk_key. The other two, test_seed_reader and test_recorder_sync (a timeout), failed only under the full run's load (a load average over 40) and both pass run alone on this head (with test_gpu_clock))
  • 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 check under tests/ that reads changed source updated in this PR, not weakened. (tests/test_gpu_clock.py, new, reads vk_main.cpp, gpu_clock.h and vk_gpu_clock.cpp; it now also builds against a header from before Linux 5.18, which it failed to, and still checks the ioctl's other numbers there)
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
    (the switch's row, now with the 1300 MHz against 1600 set by hand)
**Type:** perf · **Risk:** low · **Tested on:** Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH), ours and dukenheimer's; Steam Deck LCD (omgitsgela); RX 580 with `RX_VK_GPU_CLOCK=peak` (Linux, RADV, HumanBean); Linux x86-64 game-free checks; the renderer built for Windows (llvm-mingw) · **Needs:** none (follow-ups on a Deck by hand, not gates: battery and a long session) ## Why On the Steam Deck the GPU's automatic clocks do not keep up with the game. The frame waits on reads of GPU results, the GPU looks idle for a moment, and its clock drops: in Kokiri Forest it spends about 30% of the time at 1040 MHz, about 27% at 200 MHz and the rest in between. Held at 1300 MHz, the same frame takes 32 ms of GPU time instead of 58, and Kokiri Forest at handheld settings goes from 11.1 to 16.2 fps on a Deck OLED, with no frame over 100 ms where there were 130 to 170 in 45 s. The kernel lets any program ask for this clock for itself, with no root and no system setting written, and gives it back when the program ends. See https://git.magicbean.dev/MagicBeanDev/Longshot/issues/716, which asks for a way for the game to raise the Deck's GPU clock. **The idea, the code and the first measurements are sheep's.** They built it in their fork, https://git.magicbean.dev/sheep/BunnyHood (GPL-3.0), commit https://git.magicbean.dev/sheep/BunnyHood/commit/16db7519a80c5419860ef02e083ba095484e28bb, and measured it on a Deck LCD (their numbers are below, labelled as theirs). Their commit is here as they wrote it (`cherry-pick -x`, their authorship kept), with a `[port: ...]` line for the fork's names mapped to Longshot's. The one code change of ours makes it opt-in. sheep is welcome to take this PR over, send commits to it, or leave it with us. **On by default on the Steam Deck** (`RX_VK_GPU_CLOCK=0` turns it off). This is a power decision on a handheld. In Kokiri Forest the APU is already at its 15 W limit, so the gain costs no more power there. In Hyrule Field it is not, and the same clock costs 4 W more. It was first ported opt-in; HumanBean made it the Deck's default at review (`e91acea6`; the decision: https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-37190), with the battery and long-session runs as a follow-up. Off the Deck it stays asked for by name. The tracker was searched (`RX_VK_GPU_CLOCK`, "GPU clock", "peak power", "stable pstate", "power state", "pin the GPU", `priv-write`): https://git.magicbean.dev/MagicBeanDev/Longshot/issues/716 (the issue; omgitsgela proposes there a different way, SteamOS's `steamos-priv-write` helper writing the level, and offers to build it) and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/968 (the Deck playbook, merged, which documents setting the clock by hand) came up. No other pull request does this. ## What changed On a Steam Deck whose GPU power level is `auto` (by default, or `RX_VK_GPU_CLOCK=1`), the renderer asks the kernel's amdgpu driver, through an amdgpu context of its own on the GPU's render node, to hold the GPU at its peak stable power state (1300 MHz on the Deck) while the game runs. The kernel gives the level back when the game's file on the render node closes, which happens when the game exits, crashes or is killed. Off the Deck, unset, nothing is opened, read or asked: everything is as on main. `RX_VK_GPU_CLOCK=0` is main on the Deck too. - vk, the request (sheep's commit): `gpu/vk/vk_gpu_clock.cpp` `gpu_clock_device_created`, called once from `create_device` in `gpu/vk/vk_main.cpp` after the device is made. It finds the device's render node from `VK_EXT_physical_device_drm`, reads `/sys/dev/char/<major>:<minor>/device/power_dpm_force_performance_level`, opens `/dev/dri/renderD<minor>` (checking it is that device), makes an amdgpu context (`DRM_IOCTL_AMDGPU_CTX`, `AMDGPU_CTX_OP_ALLOC_CTX`) and sets its stable power state (`AMDGPU_CTX_OP_SET_STABLE_PSTATE`). The file stays open until the process ends; nothing is submitted on the context. The ioctl is written out, so the build needs neither libdrm nor the kernel's headers (a build on Ubuntu 22.04's headers, the release sysroot's, has the whole feature); the test compares it with `<drm/amdgpu_drm.h>` where the system has it. One log line says what it did. Linux only: on Windows the function is empty. - vk, the rule (sheep's commit): `gpu/vk/gpu_clock.h` `choose`, no Vulkan and no system calls. The peak only on the Deck's APU (Custom GPU 0405 or 0932, or Steam's `SteamDeck=1`) and only while the level is `auto`, so a level someone chose (`manual`, `high`, a profile) stays theirs. `RX_VK_GPU_CLOCK=peak` or `standard` asks for that state on any AMD GPU, whatever its level, for measuring elsewhere. - HumanBean's commit at review (`e91acea6`): unset is the Deck's rule on the Deck's own APU (`deck_apu`: Custom GPU 0405 or 0932, by its name), and nothing is read elsewhere (`looked_at`). Another handheld with Steam's `SteamDeck=1` needs `=1`: it was not measured. `tests/test_gpu_clock.cpp` checks unset on the Deck (the peak, a chosen level left alone, an unread level), on a `SteamDeck=1` handheld and on another AMD GPU; `tests/test_gpu_clock.py` checks that the APU is known before the early return. The doc row and `docs/steam-deck-playbook.md` say so. - Our commit (`1f692f10`, off by default before `e91acea6`): unset, empty, `0` or `off` is the driver's own clocks on every GPU, with nothing opened or read and no log line; `=1` is the fork's Deck rule. `SteamDeck=1` counts only on an integrated GPU, as `auto_profile`'s `hw.handheld` does, since Steam sets it in Gaming Mode on desktops with a discrete card too. - tests: `tests/test_gpu_clock.cpp` (the rule's cases, unset and `=1`, `SteamDeck=1` on a discrete card, the ioctl's numbers against the kernel's header) and `tests/test_gpu_clock.py` (the call after the device is made, the level read before the choice, the file kept open once the state is held, the early return when unset). The check builds the rules twice, the second time against a copy of the system's header without the stable power states, as before Linux 5.18 (Ubuntu 22.04's linux-libc-dev 5.15, where it failed to compile: dukenheimer's report). Where the header lacks them, `test_gpu_clock.cpp` writes their numbers as the kernel's UAPI gives them and still checks the rest of the ioctl against it (`1c25587b` the check, failing; `fda1b886` the fix). - docs: the switch's row in `docs/development.md` (with `ac385b8e`: the peak state's 1300 MHz is below the 1600 MHz a clock set by hand reaches), and nine run files in `docs/tested/` (`2026-11-16-gpu-clock-zeldaootr-*`, a commit of ours). The fork's row in `docs/tested-configurations.md` is left out: that table is frozen here. ## Measurements **Verdict:** helps on the Steam Deck OLED and LCD, against automatic clocks. Kokiri Forest at handheld settings: **11.12 -> 16.21 fps (+45.8%)**, 1% low 6.77 -> 12.06, no frame over 100 ms, at the same ~15 W. Hyrule Field native: **14.98 -> 17.88 fps (+19.4%)**, 1% low 13.19 -> 14.75, for **4.0 W more**. The power level was `auto` again after every exit and after a `kill -9`. Two testers confirmed it since, on this PR's commits: a Deck LCD (omgitsgela: +7.7% standing, +10-20% turning, with noise) and a Deck OLED play build at native with frame generation (dukenheimer: +27%, about 4 W more). **It is not the Deck's top clock:** the peak state is 1300 MHz, and a clock of 1600 MHz set by hand did as well or better at about the same power (dukenheimer, below). The switch is for a player who doesn't set the clock themselves; amdgpu offers a program nothing higher without root. Off the Deck, `RX_VK_GPU_CLOCK=peak` on a desktop RX 580 took GPU time down 9-11% and fps up 7-12% in every phase of two interleaved rounds, with no root and the level `auto` again after every run (HumanBean); its power was not measured, so `peak` beyond the Deck stays a separate question. Baseline: both columns are one renderer pack built with `scripts/dev_packs.py` on the Deck's development base, main 9c9d69ed, as [Testing a change against a base](docs/development.md#testing-a-change-against-a-base) describes: 9c9d69ed plus this PR's `gpu/` diff (local tree ed4549ea, renderer `longshot_vk.so` sha256 `d79401a56fab6f6ebb340857c297a4c9a390686c1280d8fb084b2e49ff867e62`, the game binary main's). "Before" is that pack with `RX_VK_GPU_CLOCK` unset, which is main's path (nothing is asked or read, no log line); "After" is `=1`. The pack is on an older main than this PR, but the PR's code in it is the same: `gpu/vk/gpu_clock.h`, `gpu/vk/vk_gpu_clock.cpp` and `gpu/vk/vk_gpu_clock.h` are byte-identical (the same git blobs) to this PR's head, and this PR's `gpu/` diff is the pack's line for line, the four lines in `vk_main.cpp` included. Why the result holds on today's main: what the change does, asking the kernel for a power state once at start-up, does not depend on the renderer, and the level's behaviour (held, then `auto` again) is the kernel's. The renderer's commits since 9c9d69ed change how much GPU work a frame has, so the absolute fps and the size of the gain on today's main will differ from these; the direction holds as long as the GPU's clock is what the frame waits on. Hardware: Steam Deck OLED, AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel (git-5c65d4fc31), SteamOS 3.9.5 (20261023.100, kernel 7.2.7-valve2), Zen 2 4C/8T, 16 GB shared; plugged in, headless, nothing else running Scene: Kokiri Forest, the child save's spot outside Link's house (~2,200 draws a frame), handheld settings: output 1280x720, render resolution 50%, the game's own upscaler, frame generation off. Hyrule Field, native: 1280x800, render resolution 100%, the game's upscaler, frame generation off. No frame rate cap (headless); precompile off with warm caches Method: one session on 2026-11-16, 03:30-04:04 UTC. For each scene, after a warm-up run, interleaved off, on, on, off; 75 s warm-up then 45 s standing; the median of each arm. fps and frame times from the present trace (`HOS_PRESENT_TRACE`) over the 45 s sample. 1% low: 1000 divided by the mean of the slowest 1% of present intervals in that same sample (5 to 9 intervals a run). GPU time and host waits from the log's `vk: GPU time` and `host time in GPU resource waits` lines inside the sample. GPU clock, busy, APU power (`power1_average`) and temperature from sysfs at 10 Hz. `power_dpm_force_performance_level` read (never written) every 2 s for the whole session How to reproduce: the child Kokiri save; `RX_VK_GPU_CLOCK=1` against unset, nothing else in the environment but `RX_VK_PRECOMPILE=0`, warm caches copied fresh into each run, no `longshot_env.txt`; Hyrule Field by teleport from the same save; read `/sys/class/drm/card*/device/power_dpm_force_performance_level` before, during and after | Kokiri Forest, handheld (median of 2 runs each) | Before, `RX_VK_GPU_CLOCK` unset: dev pack on main 9c9d69ed @ ed4549ea | After, `RX_VK_GPU_CLOCK=1`: dev pack on main 9c9d69ed @ ed4549ea | |---|---|---| | fps (runs) | **11.12** (10.85, 11.39) | **16.21** (16.16, 16.26), +45.8% | | 1% low fps (runs) | **6.77** (6.68, 6.86) | **12.06** (11.97, 12.14), +78% | | frame time p50 / p95 / p99 | 83.4 / 128.5 / 140.8 ms | 60.8 / 72.9 / 80.6 ms | | frames over 100 ms in 45 s | 170, 131 | 0, 0 | | GPU time a frame | 58.1 ms | 31.9 ms | | host waits on the GPU a frame | 53.8 ms | 25.5 ms | | a waited readback | 22.0 ms each | 8.7 ms each | | GPU clock in the sample | 1040 MHz 31%, 200 MHz 27%, the rest between (median of the two runs' shares) | 1300 MHz, 100% of samples | | GPU busy | 79% | 58% | | APU power mean (max) | 14.84 W (17.41) | 15.02 W (18.32) | | APU temperature max | 69 C | 72 C | | Hyrule Field, native (median of 2 runs each) | Before, `RX_VK_GPU_CLOCK` unset: dev pack on main 9c9d69ed @ ed4549ea | After, `RX_VK_GPU_CLOCK=1`: dev pack on main 9c9d69ed @ ed4549ea | |---|---|---| | fps (runs) | **14.98** (15.01, 14.95) | **17.88** (17.83, 17.93), +19.4% | | 1% low fps (runs) | **13.19** (12.77, 13.60) | **14.75** (14.98, 14.51), +11.8% | | frame time p50 / p95 / p99 | 66.6 / 70.4 / 73.4 ms | 55.8 / 59.2 / 61.5 ms | | frames over 100 ms in 45 s | 0, 0 | 0, 1 | | GPU time a frame | 45.0 ms | 35.9 ms | | GPU clock in the sample | 1040 MHz 88%, 200 MHz 12% | 1300 MHz, 100% of samples | | GPU busy | 74% | 70% | | APU power mean (max) | 8.14 W (13.06) | **12.17 W** (17.53), +4.0 W | | APU temperature max | 63 C | 72 C | **The power level** (`power_dpm_force_performance_level`, read every 2 s, never written): `auto` before the series and through every off run. In every on run, `profile_peak` (1300 MHz) from the first or second sample after the game started until it exited, and `auto` again within one 2 s sample of the exit: | run | `profile_peak` from | last `profile_peak` | `auto` again | the game's exit | |---|---|---|---|---| | gc-on-kH-1 | 03:34:29 | 03:37:59 | 03:38:01, 200 MHz | 03:38:01 | | gc-on-kH-2 | 03:38:22 | 03:42:00 | 03:42:02 | 03:42:03 | | gc-on-fN-1 | 03:50:17 | 03:53:55 | 03:53:57, 200 MHz | 03:53:59 | | gc-on-fN-2 | 03:54:14 | 03:57:50 | 03:57:52 | 03:57:52 | | gc-kill-1, `kill -9` 30 s after the line | 04:02:39 | 04:03:08, 1300 MHz | 04:03:09, 200 MHz; still `auto` 5 s and 20 s after | killed | No kernel line about amdgpu or drm in the journal during the killed run. No device fault, `VK_ERROR` or validation line in any run; every timed run exited 0. sheep's numbers, from BunnyHood (their commit message), not from this branch: Steam Deck LCD, Kokiri Forest standing, three interleaved runs each. | Steam Deck LCD, Kokiri Forest (sheep's, in BunnyHood) | Automatic clocks | Peak power state | |---|---|---| | median fps | 11.7 | 13.9 (+19%) | | 1% low fps | 10.4 | 12.0 | | GPU time a frame | 57.4 ms | 46.5 ms | | GPU clock in play | ~1040 MHz | 1300 MHz | | APU power | ~9 W | ~13.4 W (cap 15 W) | The OLED gains more than the LCD did in Kokiri Forest: there the OLED's automatic clocks fell to 200 MHz over a quarter of the time, where sheep's LCD held ~1040. **Testers' runs since, on this PR's two code commits** (their numbers, from their comments; not ours): omgitsgela, Steam Deck LCD (VANGOGH, SteamOS 3.x, Mesa 26.2.0-devel), desktop mode, stock clocks, a pack of their LCD runtime's base a4821d56 plus this PR's two code commits; the Kokiri Village benchmark save, standing then a steady camera spin, off, on, on, off (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-34528): | Deck LCD (omgitsgela) | off 1 | on 1 | on 2 | off 2 | |---|---|---|---|---| | standing fps | 23.3 | 24.4 | 24.4 | 22.0 | | turning fps | 20.8 | 19.8 | 25.4 | 17.9 | Standing, every on run is above every off run (+7.7% by the mean); turning, +16.8% by the mean but with about 3 fps of noise between runs (their reading: "idle always up ~8%, spin up ~10-20% with noise"). The log line was in every on run, the level `profile_peak` through each and `auto` within 4 s of each exit. On the LCD, too, the peak state tops out at 1300 MHz, where the `high` level and the automatic clocks' boost reach 1600. dukenheimer, Steam Deck OLED (Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel, SteamOS 3.9.5), docked, Game Mode, a Deck play build (v3.0.0-rc.5 with this PR and nine others, the release toolchain), output 1280x800, the game's upscaler at 100%, frame generation 3x, `RX_VK_READBACK_LATE=newest`; their moving Kokiri route (80 s), 2 interleaved runs each (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-35041): | Deck OLED, native, frame generation 3x (dukenheimer) | unset, automatic clocks | `=1` (1300 MHz) | unset, 1600 MHz set by hand (`manual`) | |---|---|---|---| | game fps | 13.4 / 12.7 | 17.3* / 15.8 | 17.3 / 17.3* | | shown fps (3x) | 37.7 / 36.0 | 50.5* / 45.7 | 51.0 / 51.2* | | p99 (ms) | 129.8 / 144.3 | 92.1 / 111.9 | 92.6 / 81.9 | | frames over 100 ms | 77 / 92 | 36 / 48 | 34 / 31 | | GPU clock while busy (median) | 1040 MHz | 1300 MHz | 1600 MHz | | APU power, mean | 9.8 / 8.8 W | 13.5 / 13.2 W | 13.3 / 13.8 W | \* These runs went indoors for the last part of the route; the others stayed outside. `=1` against automatic clocks: median 16.55 against 13.05 fps (+27%) for about 4 W more. The manual 1600 MHz did as well or better at about the same power: outside, 17.3 against `=1`'s 15.8; with the indoor parts, 17.3 each. With https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/906's `soa` layout on top: `=1` 16.9 / 18.0, manual 1600 MHz 18.1 / 18.2. Ours, with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/977's early reads and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/906's layout in one pack (same Deck OLED, Hyrule Field native, two runs each, empty shader caches; https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-34267): nothing on 15.07 fps at 8.2 W, the hold alone 17.81 at 12.3 W, the other two 20.99 at 9.4 W, all three 24.64 at 13.6 W. The hold still pays once the readback waits are gone. HumanBean, `RX_VK_GPU_CLOCK=peak` on a desktop card (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-35735; their numbers): RX 580 8 GB (Polaris10), RADV/amdgpu, KDE, run as a normal user with no root; a build of this PR merged with `main` c167ec67, with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/384 and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/906 in it, each behind its own switch; `=peak` against unset, two interleaved rounds, plus main's own build (the same as unset); Kokiri Forest, Hyrule Field, the Market and Hyrule Field again, standing then turning: | RX 580, GPU ms (fps) (HumanBean) | unset (2 runs) | `=peak` (2 runs) | |---|---|---| | Kokiri, standing | 35.60, 35.70 (21.0, 20.8) | 32.20, 31.70 (23.1, 23.4) | | Kokiri, turning | 32.00, 31.65 (22.9, 22.2) | 28.30, 28.30 (25.0, 25.0) | | Hyrule Field, standing | 24.00, 24.30 (28.5, 27.0) | 21.85, 21.40 (29.7, 31.3) | | Hyrule Field, turning | 19.90, 19.90 (34.6, 33.5) | 17.90, 17.90 (37.3, 37.6) | | the Market, standing | 28.80, 28.50 (24.2, 24.1) | 25.95, 25.40 (26.2, 27.1) | | the Market, turning | 18.40, 17.35 (39.2, 35.8) | 15.85, 15.90 (41.9, 39.2) | | Hyrule Field again, turning | 20.10, 20.50 (33.9, 32.0) | 18.10, 17.70 (36.1, 38.4) | GPU time 9 to 11% lower and fps 7 to 12% higher in every phase and both rounds. The log had `vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=peak; the power level auto -> profile_peak)` and the level read `auto` again after every run. `=1` does nothing there (not a Deck), as designed. Board power and temperature were not measured, so this says the desktop card's automatic level leaves performance unused, not what holding the peak costs. ``` on runs, once each: vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=1 on the Steam Deck's APU; the power level auto -> profile_peak). RX_VK_GPU_CLOCK=0 leaves the clocks to the driver off runs: no "vk: GPU clock" line run fps p50 p95 p99 >100ms gpu_ms waits clock samples (MHz x n) APU W gc-off-kH-1 10.85 86.6 131.1 141.8 170 59.7 54.98 1040x133 200x131 of 450 14.87 gc-on-kH-1 16.16 61.1 73.4 80.9 0 32.0 25.91 1300x450 of 450 15.03 gc-on-kH-2 16.26 60.5 72.4 80.3 0 31.8 25.12 1300x449 of 449 15.00 gc-off-kH-2 11.39 80.1 125.9 139.8 131 56.55 52.59 1040x150 200x115 of 450 14.81 gc-off-fN-1 15.01 66.4 70.4 74.2 0 44.9 38.39 1040x395 200x55 of 450 8.17 gc-on-fN-1 17.83 56.0 59.2 61.3 0 36.1 29.58 1300x451 of 451 12.11 gc-on-fN-2 17.93 55.5 59.2 61.7 1 35.6 28.99 1300x450 of 450 12.22 gc-off-fN-2 14.95 66.7 70.3 72.6 0 45.1 38.85 1040x394 200x56 of 450 8.11 gc-kill-1 04:02:33 before: auto | 1: 1040Mhz 04:03:08 during (30 s after the line): profile_peak | 2: 1300Mhz kill -9 of the game's process 04:03:09 right after the kill: auto | 0: 200Mhz 04:03:14 5 s after: auto | 0: 200Mhz 04:03:29 20 s after: auto | 0: 200Mhz ``` ### Flags and settings One switch is added, on by default on the Steam Deck's APU only: elsewhere nothing changes unless it is set. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_GPU_CLOCK` | amdgpu's stable power state, held while the game runs (Linux, AMD) | absent | the peak on a Steam Deck whose level is `auto`, by default; `=0` off; `=1` the same rule, with `SteamDeck=1` handhelds too; `peak` or `standard` that state on any AMD GPU | The Deck's GPU at 1300 MHz instead of automatic clocks (200-1040 MHz, boosting to 1600 at times); the same power where the APU is at its 15 W limit, about 4 W more where it is not | Helps the Deck OLED (+45.8% Kokiri handheld, +19.4% Field native; +27% at native with frame generation, dukenheimer's) and the Deck LCD (+19% Kokiri in sheep's fork; +8% standing on this PR's commits, omgitsgela's); a clock of 1600 MHz set by hand does as well or better, and `=1` leaves such a level alone; `peak` on a desktop RX 580: GPU time -9 to -11%, fps +7 to +12% (HumanBean), power not measured; untested on battery, over a long session, `standard` anywhere, and `peak` on other AMD GPUs | On by default on the Deck (shipped so); `peak` beyond the Deck after a valid run on RDNA (warm caches) showing no cap below the boost clock, and a power figure | ## Testing **Tested:** - In the game, Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel), plugged in: Kokiri Forest at handheld settings and Hyrule Field native, `RX_VK_GPU_CLOCK` unset against `=1`, 2 runs each interleaved, plus one run killed with `kill -9`: the numbers and the power level above. The code is this PR's, in a renderer pack on main 9c9d69ed (see Baseline). - Steam Deck LCD, by omgitsgela, and a Deck OLED play build at native with frame generation, by dukenheimer: on this PR's two code commits (Measurements). - `RX_VK_GPU_CLOCK=peak` on a desktop RX 580 (Linux, RADV, no root), by HumanBean: this PR merged with `main` c167ec67, two interleaved rounds against unset in four places, the log line in every `=peak` run and the level `auto` again after each (Measurements; https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-35735). - Game-free, Linux x86-64, on this head: `tests/test_gpu_clock.py` with `CXX=g++` (13.3) and `CXX=clang++` (23.1.5), the ioctl's numbers checked against the system's `<drm/amdgpu_drm.h>` (Linux 6.8's) and against a copy of it without the stable power states, as before Linux 5.18: passes with both. At `1c25587b` (the check alone) the second build fails as dukenheimer saw on Ubuntu 22.04 (`AMDGPU_CTX_STABLE_PSTATE_NONE`, `_STANDARD`, `_PEAK` and `AMDGPU_CTX_OP_SET_STABLE_PSTATE` not declared); at `fda1b886` it passes and says the header is from before 5.18. - The full suite: `python3 -I -B tests/run_all.py` (clang++ 23.1.5, the Vulkan and SPIR-V headers found) on `ac385b8e`: 619 passed, 19 failed, 26 skipped. 17 fail on main e4d035e9 too, run there the same way: `test_bug_report_defaults`, `test_crt_options`, `test_fsr_uniform_ownership`, `test_guest_imported`, `test_import_reach`, `test_linux_preflight`, `test_linux_update`, `test_make_game_cache`, `test_missing_nup`, `test_mods_size_table`, `test_nonuniform_image_arrays`, `test_parallel_init_order`, `test_pending_guest_import`, `test_replay_write_order`, `test_run_all_changed`, `test_vk_occlusion_queries` and `test_walk_key`. The other two, `test_seed_reader` and `test_recorder_sync` (a timeout), failed only under the full run's load (a load average over 40) and both pass run alone on this head (with `test_gpu_clock`) Before those commits, at `e8e49640`: `python3 -I -B tests/run_all.py --changed forge/main` (the 52 checks that read what changed) with each compiler, and one full `python3 -I -B tests/run_all.py`: `--changed`: 50 passed, 2 failed, 5 skipped with each compiler; the full run: 570 passed, 12 failed, 82 skipped. Every failure also fails on main e4d035e9 (run there the same way): `test_bug_report_defaults`, `test_crt_options`, `test_guest_imported`, `test_linux_preflight`, `test_linux_update`, `test_make_game_cache`, `test_missing_nup`, `test_mods_size_table`, `test_pending_guest_import`, `test_run_all_changed`, `test_vk_occlusion_queries` and `test_walk_key` in the full run; `test_vk_occlusion_queries` and `test_walk_key` in `--changed`, with both compilers. - The renderer built and linked for Windows with llvm-mingw 20261104 (`RX_VK_ONLY=1 RX_TARGET=windows`: `longshot_vk.dll`) on this head, and for Linux by the pack above. **Not tested:** - On battery, and a long session's temperature and battery drain: every run was on the charger, with 45 s samples. - The Deck LCD in Game Mode (omgitsgela's run was in desktop mode). - A level set by hand (`manual`, `high`) being left alone: the code path was read, not run. - `standard` on any AMD GPU, and `peak` on AMD GPUs other than the Deck and the RX 580. - The RX 580's board power and temperature with `peak`: what offering it beyond the Deck would cost. - Windows in the game: unaffected by construction (`gpu_clock_device_created` is empty there, and nothing else reads the switch). - Follow-up, steamdeck, SteamOS, on battery: 20 minutes of play with `RX_VK_GPU_CLOCK` unset (the default) against 20 minutes with `=0`, expecting the drain and the APU temperature to rise by about what the APU power above says (the same in Kokiri Forest at the 15 W limit, about 4 W more in Hyrule Field), no throttling below the automatic clocks, and the level `auto` after exit (by hand: the battery percentage, the APU power and temperature, the fan) - Follow-up, steamdeck, SteamOS: the GPU clock set by hand in the Quick Access menu (the level `manual`), then the game with `RX_VK_GPU_CLOCK` unset, expecting `the GPU's power level was chosen (not auto): it stays` in the log and the level still `manual` after exit (by hand) **Must be tested:** None. By the maintainer's decision (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-37190) the battery and long-session runs and the manual level's check are follow-ups, under Not tested. ## Risks **What could break:** on the Steam Deck by default, elsewhere only with `RX_VK_GPU_CLOCK=1`, `peak` or `standard` set: - More power and heat on a handheld: the same power in Kokiri Forest, where the APU was already at its 15 W limit, but 4 W more in Hyrule Field, and 3 to 9 C warmer, so a shorter battery life wherever the automatic clocks would have stayed under the limit. - A profiling power state also turns off the GPU's power and clock gating while it is held (by our reading of amdgpu), so a paused game or a menu draws more than with automatic clocks too. Not measured. - `peak` or `standard` asked by name over a level someone set by hand (`manual`, `high`): what the kernel gives back at exit is `auto`, not their level. `=1` never asks over a chosen level. - Someone or SteamOS writing `power_dpm_force_performance_level` while the game runs wins: the context's hold is dropped, and nothing is changed back over their choice at exit. - It does not reach the Deck's top clock: the peak state is 1300 MHz on the Deck (OLED and LCD), where a clock set by hand reaches 1600 and did as well or better at about the same power (dukenheimer's run). amdgpu lets a program ask, without root, only for its stable power states (none, standard, the lowest shader or memory clock, peak), and none is higher. A player who sets 1600 MHz in Steam's performance settings gets more than `=1`, and `=1` leaves that level alone. - Only one process may hold a stable state at a time: a profiler holding one (RGP, `RADV_PROFILE_PSTATE`) makes amdgpu refuse ours, and the log says so. **Turning it off:** `RX_VK_GPU_CLOCK=0`. **Compatibility:** Nothing changes: no shader translator file (the shader caches stay valid), `MKWVK_API_VERSION` unchanged (`vk_api.h` untouched), no option, ini key or menu row. ## Issues See https://git.magicbean.dev/MagicBeanDev/Longshot/issues/716 ## 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] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`: at review onto 26ce01b5, commit by commit with no conflict, head `e91acea6` (the default on top). Before that: on e4d035e9; merges with current `main` 71b1edd8 without a conflict (`git merge-tree`). - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). Run at `ac385b8e`; `e91acea6` was not run (a code-only review): `tests/test_gpu_clock.py` is the check it changes. (`python3 -I -B tests/run_all.py` (clang++ 23.1.5, the Vulkan and SPIR-V headers found) on `ac385b8e`: 619 passed, 19 failed, 26 skipped. 17 fail on main e4d035e9 too, run there the same way: `test_bug_report_defaults`, `test_crt_options`, `test_fsr_uniform_ownership`, `test_guest_imported`, `test_import_reach`, `test_linux_preflight`, `test_linux_update`, `test_make_game_cache`, `test_missing_nup`, `test_mods_size_table`, `test_nonuniform_image_arrays`, `test_parallel_init_order`, `test_pending_guest_import`, `test_replay_write_order`, `test_run_all_changed`, `test_vk_occlusion_queries` and `test_walk_key`. The other two, `test_seed_reader` and `test_recorder_sync` (a timeout), failed only under the full run's load (a load average over 40) and both pass run alone on this head (with `test_gpu_clock`)) - [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 check under `tests/` that reads changed source updated in this PR, not weakened. (`tests/test_gpu_clock.py`, new, reads `vk_main.cpp`, `gpu_clock.h` and `vk_gpu_clock.cpp`; it now also builds against a header from before Linux 5.18, which it failed to, and still checks the ioctl's other numbers there) - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. (the switch's row, now with the 1300 MHz against 1600 set by hand)
On the Steam Deck LCD the GPU's automatic clocks held it at 1040 MHz of
its 1600 in Kokiri Forest while it was what the frame waited for (99%
busy, the APU at about 9 W of its 15 W cap). An amdgpu context may ask
the driver for a stable power state, as profilers do, with no privilege:
the render node every user has. Its peak holds the Deck's GPU at 1300
MHz. Three interleaved runs each of kokiri_stand: 13.9 fps median where
automatic clocks gave 11.7, 1% low 12.0 for 10.4, GPU 46.5 ms a frame for
57.4; the APU at about 13.4 W, still under its cap; the CPU's replay no
slower.

vk_gpu_clock.cpp opens the device's render node once more
(VK_EXT_physical_device_drm), makes an amdgpu context on it and sets its
stable power state, then keeps the file open until the process ends; the
driver then frees the context and puts back the level it found, after a
crash too. gpu_clock.h decides: the peak on the Steam Deck's APU (as
auto_profile tells it) while the device's power_dpm_force_performance_level
is auto, so a level the player or SteamOS chose stays theirs (and a
later write to it goes over the context's). RX_VK_GPU_CLOCK=0 leaves the
clocks to the driver; peak or standard asks for that state on any AMD
GPU. Elsewhere nothing changes. The ioctl is written out: no libdrm or
kernel headers to build; the test compares it with <drm/amdgpu_drm.h>.

tests/test_gpu_clock.cpp: the cases (the Deck at auto, a chosen level,
another APU, the switch). test_gpu_clock.py: the call after the device is
made, the level read before the choice, the file kept open once held, the
Deck told apart as auto_profile tells it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 16db7519a80c5419860ef02e083ba095484e28bb)
[port: the fork's names as Longshot's ((hookshot) comment tags as (longshot); docs/steam-deck.md as docs/steam-deck-playbook.md); its docs/tested-configurations.md row left out: that table is frozen here, runs go in docs/tested/]
The fork holds amdgpu's peak power state on every Steam Deck whose power level is auto. Here it is asked for: it raises a
handheld's power draw (about 4 W in the fork's Deck LCD runs) and its heat, so whether it becomes the Deck's default is the
maintainers' and its author's call once it is measured on more Decks, OLED included, and on battery.

- gpu_clock.h: unset (or empty, 0, off) is the driver's own clocks on every GPU; RX_VK_GPU_CLOCK=1 is the fork's rule (the
  peak on the Steam Deck's APU while its level is auto); peak and standard as before. asked() says whether the switch
  asks for anything. Steam's SteamDeck=1 counts only on an integrated GPU, as vk_main.cpp auto_profile's hw.handheld:
  Steam sets it in Gaming Mode on desktops with a discrete card too.
- vk_gpu_clock.cpp: unset, it returns before anything is asked of the device, opened or read, with no log line.
- tests/test_gpu_clock.cpp and .py: the cases unset and with =1, SteamDeck=1 on a discrete card, the early return.
- docs/development.md: the row says it is off by default and what =1 does.

Assisted-by: Claude
docs(tested): the GPU clock hold on a Steam Deck OLED, Kokiri handheld and Hyrule Field native, off and on, and a killed run
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 3s
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
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
e8e4964024
Nine runs of 2026-11-16, one file each: `RX_VK_GPU_CLOCK` unset against `=1`, interleaved off, on, on, off in each scene,
and one run killed with `kill -9` while the peak state was held.

Assisted-by: Claude
Author
Contributor

Tested in game: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel), this branch's gpu/ change as a renderer pack on an older main: Kokiri Forest at handheld settings and Hyrule Field at 1280x800, the switch unset and set, interleaved off, on, on, off, and one run killed with -9. Kokiri 11.12 to 16.21 fps at the same 15 W, the Field 14.98 to 17.88 fps for 4 W more; the GPU's power level read auto again after every exit and after the kill.

Tested in game: Steam Deck OLED (SteamOS 3.9.5, RADV VANGOGH, Mesa 26.2.0-devel), this branch's gpu/ change as a renderer pack on an older main: Kokiri Forest at handheld settings and Hyrule Field at 1280x800, the switch unset and set, interleaved off, on, on, off, and one run killed with -9. Kokiri 11.12 to 16.21 fps at the same 15 W, the Field 14.98 to 17.88 fps for 4 W more; the GPU's power level read auto again after every exit and after the kill.
Author
Contributor

Hi @sheep! This PR brings your GPU clock hold (BunnyHood 16db7519a: the Deck's GPU at amdgpu's peak power state, asked for through the game's own render-node context, no root) to Longshot. Your commit is cherry-picked as you wrote it, your authorship kept, with only the fork's names mapped back. Thank you: #716 has been asking for this, and the context trick is a neat way to get it without a helper.

It has now run on a Deck OLED, beside your LCD numbers:

  • Your LCD, Kokiri Forest: 11.7 -> 13.9 fps (+19%), the APU ~9 -> ~13.4 W.
  • OLED, Kokiri Forest, handheld settings: 11.12 -> 16.21 fps (+45.8%), 1% low 6.77 -> 12.06, at the same ~15 W (the APU was already at its limit; the automatic clocks dropped to 200 MHz over a quarter of the time).
  • OLED, Hyrule Field, native: 14.98 -> 17.88 fps (+19.4%) for 4 W more. The level was auto again after every exit and after a kill -9.

One change of ours: here it is opt-in (RX_VK_GPU_CLOCK=1), and SteamDeck=1 counts only on an integrated GPU. The reason is power, not doubt about the result. On a handheld it costs nothing where the APU is already at 15 W, but 4 W where it isn't, so making it the Deck's default feels like a call for you and the maintainers, in its own PR, once someone has run it on battery and over a long session.

It's yours as much as ours: take the PR over, send commits to it, or leave it with us, whichever you prefer. If you'd like it on by default, or want to run those battery tests yourself, say so and we'll follow your lead.

Hi @sheep! This PR brings your GPU clock hold (BunnyHood `16db7519a`: the Deck's GPU at amdgpu's peak power state, asked for through the game's own render-node context, no root) to Longshot. Your commit is cherry-picked as you wrote it, your authorship kept, with only the fork's names mapped back. Thank you: #716 has been asking for this, and the context trick is a neat way to get it without a helper. It has now run on a Deck OLED, beside your LCD numbers: - **Your LCD, Kokiri Forest:** 11.7 -> 13.9 fps (+19%), the APU ~9 -> ~13.4 W. - **OLED, Kokiri Forest, handheld settings:** 11.12 -> 16.21 fps (+45.8%), 1% low 6.77 -> 12.06, at the same ~15 W (the APU was already at its limit; the automatic clocks dropped to 200 MHz over a quarter of the time). - **OLED, Hyrule Field, native:** 14.98 -> 17.88 fps (+19.4%) for 4 W more. The level was `auto` again after every exit and after a `kill -9`. One change of ours: here it is opt-in (`RX_VK_GPU_CLOCK=1`), and `SteamDeck=1` counts only on an integrated GPU. The reason is power, not doubt about the result. On a handheld it costs nothing where the APU is already at 15 W, but 4 W where it isn't, so making it the Deck's default feels like a call for you and the maintainers, in its own PR, once someone has run it on battery and over a long session. It's yours as much as ours: take the PR over, send commits to it, or leave it with us, whichever you prefer. If you'd like it on by default, or want to run those battery tests yourself, say so and we'll follow your lead.
Author
Contributor

@Beanstalk steamdeck (an LCD especially): Kokiri Forest and Hyrule Field, a few minutes each, with and without RX_VK_GPU_CLOCK=1 in longshot_env.txt. Expecting the log line vk: GPU clock: amdgpu's peak power state held while the game runs when set, higher fps, and power_dpm_force_performance_level reading auto again after the game exits. Unset must match main, with no vk: GPU clock line.

@Beanstalk steamdeck (an LCD especially): Kokiri Forest and Hyrule Field, a few minutes each, with and without `RX_VK_GPU_CLOCK=1` in `longshot_env.txt`. Expecting the log line `vk: GPU clock: amdgpu's peak power state held while the game runs` when set, higher fps, and `power_dpm_force_performance_level` reading `auto` again after the game exits. Unset must match main, with no `vk: GPU clock` line.
Member

@zeldaootr only members of BigBeans can start the farm.

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

@zeldaootr only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it.~~ This request was for `e8e4964`, and the PR has changed since (`ac385b8`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Author
Contributor

Measured together with early reads (#977) and the fallback record layout (#906) in one build, same Deck OLED, each arm twice in mirrored order, empty shader caches in every run:

Hyrule Field, 1280x800 fps (two runs) APU power
nothing on 15.04, 15.10 8.2 W
the clock hold 17.83, 17.80 12.3 W
early reads + layout 20.63, 21.36 9.4 W
all three 24.64, 24.65 13.6 W

Kokiri Forest at handheld settings: 12.97 and 9.87 fps with nothing on, 19.39 and 19.83 with all three; early reads plus the hold take the host's wait on the GPU from 52 ms a frame to under 1 ms. So the hold still pays once the readback wait is gone. The power level read auto after every one of the 18 runs (2,864 samples, none off auto with no game running).

Measured together with early reads (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/977) and the fallback record layout (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/906) in one build, same Deck OLED, each arm twice in mirrored order, empty shader caches in every run: | Hyrule Field, 1280x800 | fps (two runs) | APU power | |---|---|---| | nothing on | 15.04, 15.10 | 8.2 W | | the clock hold | 17.83, 17.80 | 12.3 W | | early reads + layout | 20.63, 21.36 | 9.4 W | | all three | 24.64, 24.65 | 13.6 W | Kokiri Forest at handheld settings: 12.97 and 9.87 fps with nothing on, 19.39 and 19.83 with all three; early reads plus the hold take the host's wait on the GPU from 52 ms a frame to under 1 ms. So the hold still pays once the readback wait is gone. The power level read `auto` after every one of the 18 runs (2,864 samples, none off `auto` with no game running).
Contributor

Steam Deck LCD run, since the PR's Needs line asks for one (my prior run was OLED): Jupiter/VANGOGH (same GPU chipset as OLED, ~1100 MT/s slower memory), SteamOS 3.x, Mesa 26.2.0-devel. Your pinned head verified against refs/pull/1053/head (e8e4964024e9…) before building, and the pack is honest: source = our LCD runtime's own base a4821d56 + exactly your two commits (clean cherry-pick, zero conflicts), so the renderer differs from our control by the clock change and nothing else.

Method: desktop mode (no gamescope treatment), stock clocks — no sysfs written by hand anywhere (that is your claim under test: the game asks, the kernel gives, the kernel takes back). Same runtime both arms, only RX_VK_GPU_CLOCK flips. Kokiri Village benchmark save, walk-in/settle then idle×4 samples, then a steady right-stick spin×4 samples, arms interleaved off/on/on/off, first-launch pipeline prep paid warm once.

arm env idle fps spin fps
off1 none 23.3 20.8
on1 RX_VK_GPU_CLOCK=1 24.4 19.8
on2 RX_VK_GPU_CLOCK=1 24.4 25.4
off2 none 22.0 17.9
  • Mechanism: proven live, exactly as you describe. Every on-arm game log carries vk: GPU clock: amdgpu's peak power state held while the game runs (… auto -> profile_peak), and a 2-second watcher (read-only) saw level=profile_peak for the whole arm and level=auto again within 4 s of exit — both times, no hand-reset. Nothing on desktop or Game Mode needs sudo or a group change.
  • fps, honest read: idle is consistently up: 24.4/24.4 vs 23.3/22.0 (+7.7% mean, every on-arm ≥ every off-arm). Spin is up by mean, 22.6 vs 19.35 (+16.8%), but the spread is real — on1 (19.8) sat inside the off-arm range while on2 (25.4) beat everything. LCD spin arms have ±3 fps run-to-run noise; I would claim "idle always up ~8%, spin up ~10-20% with noise", not more.
  • A Deck LCD-specific catch worth knowing: on this image profile_peak's sclk table tops out at 1300 MHz (watcher: 0: 1300 1: 1100 2: 1300), while the classic high force exposes 1600 and auto does boost to 1600 under load (*2: 1600Mhz). So peak-state-hold is not "pinned to 1600"; part of the gain here is presumably never dipping to 200-1100 between/within frames rather than a higher ceiling. If a later toggle ever exposed 1600 under peak, this LCD's numbers might go up; I can re-run the same arms if you change that.
  • No crashes, no refused ioctls (amdgpu refused never appeared), no effect seen on CPU governors (left powersave both arms).

Verdict from my side: on LCD it works, is automatic in both modes, and self-releases; worth shipping for the Deck defaults discussion. Not tested: Game Mode fps deltas (same runtime in gamescope) — if useful I can run the same four arms from the couch tile.

Steam Deck **LCD** run, since the PR's Needs line asks for one (my prior run was OLED): Jupiter/VANGOGH (same GPU chipset as OLED, ~1100 MT/s slower memory), SteamOS 3.x, Mesa 26.2.0-devel. Your pinned head verified against `refs/pull/1053/head` (`e8e4964024e9…`) before building, and the pack is honest: source = our LCD runtime's own base `a4821d56` + exactly your two commits (clean cherry-pick, zero conflicts), so the renderer differs from our control by the clock change and nothing else. **Method:** desktop mode (no gamescope treatment), stock clocks — no sysfs written by hand anywhere (that is your claim under test: the game asks, the kernel gives, the kernel takes back). Same runtime both arms, only `RX_VK_GPU_CLOCK` flips. Kokiri Village benchmark save, walk-in/settle then idle×4 samples, then a steady right-stick spin×4 samples, arms interleaved off/on/on/off, first-launch pipeline prep paid warm once. | arm | env | idle fps | spin fps | |---|---|---:|---:| | off1 | none | 23.3 | 20.8 | | on1 | `RX_VK_GPU_CLOCK=1` | 24.4 | 19.8 | | on2 | `RX_VK_GPU_CLOCK=1` | 24.4 | 25.4 | | off2 | none | 22.0 | 17.9 | - **Mechanism: proven live, exactly as you describe.** Every on-arm game log carries `vk: GPU clock: amdgpu's peak power state held while the game runs (… auto -> profile_peak)`, and a 2-second watcher (read-only) saw `level=profile_peak` for the whole arm and `level=auto` again within 4 s of exit — both times, no hand-reset. Nothing on desktop or Game Mode needs sudo or a group change. - **fps, honest read:** idle is consistently up: 24.4/24.4 vs 23.3/22.0 (**+7.7%** mean, every on-arm ≥ every off-arm). Spin is up by mean, 22.6 vs 19.35 (**+16.8%**), but the spread is real — on1 (19.8) sat inside the off-arm range while on2 (25.4) beat everything. LCD spin arms have ±3 fps run-to-run noise; I would claim "**idle always up ~8%, spin up ~10-20% with noise**", not more. - **A Deck LCD-specific catch worth knowing:** on this image `profile_peak`'s sclk table tops out at **1300 MHz** (watcher: `0: 1300 1: 1100 2: 1300`), while the classic `high` force exposes **1600** and auto does boost to 1600 under load (`*2: 1600Mhz`). So peak-state-hold is *not* "pinned to 1600"; part of the gain here is presumably never dipping to 200-1100 between/within frames rather than a higher ceiling. If a later toggle ever exposed 1600 under peak, this LCD's numbers might go up; I can re-run the same arms if you change that. - No crashes, no refused ioctls (`amdgpu refused` never appeared), no effect seen on CPU governors (left `powersave` both arms). Verdict from my side: on LCD it works, is automatic in both modes, and self-releases; worth shipping for the Deck defaults discussion. Not tested: Game Mode fps deltas (same runtime in gamescope) — if useful I can run the same four arms from the couch tile.
Contributor

Deck OLED: RX_VK_GPU_CLOCK=1 against stock clocks and a manual 1600 MHz, at native 1280x800

Hardware: Steam Deck OLED (AMD Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel), SteamOS 3.9.5, docked, in Game Mode through Steam.
Build: a Deck play build, v3.0.0-rc.5 + #225 + #227 + #222 + #977 (off) + #1086 + #1053 + #906 + #790 + #391 + #568 (for #1086, #391 and #568 their own commits, since they sit on newer mains). Linux, the release toolchain (LLVM 23.1.5), x86-64-v3 with the play profile.
Settings: Docked, output 1280x800, the game's own upscaler at 100%, frame generation 3x; longshot_env.txt sets RX_VK_READBACK_LATE=newest.
Method: our moving Kokiri route (80 s), 2 interleaved runs per arm: unset at stock clocks; =1; unset with the GPU pinned at 1600 MHz by hand (power level manual, as Steam's Manual GPU Clock Control sets it).

unset, stock =1 unset, manual 1600 MHz
game fps 13.4 / 12.7 17.3* / 15.8 17.3 / 17.3*
shown fps (frame generation 3x) 37.7 / 36.0 50.5* / 45.7 51.0 / 51.2*
p95 (ms) 61.7 / 62.1 49.6 / 49.5 49.4 / 49.1
p99 (ms) 129.8 / 144.3 92.1 / 111.9 92.6 / 81.9
frames over 100 ms 77 / 92 36 / 48 34 / 31
GPU clock while busy (median) 1040 MHz 1300 MHz 1600 MHz
APU power, mean (W) 9.8 / 8.8 13.5 / 13.2 13.3 / 13.8

* These runs went indoors for the last part of the route: =1's first went into the shop and stood in the item pose, the manual run's second went into a house. The other runs stayed outside.

  • =1 against stock: median game fps 16.55 against 13.05 (+27%), for about 4 W more. vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=1 on the Steam Deck's APU; the power level auto -> profile_peak) appeared in every =1 run, and the level read auto after every exit.
  • On the OLED the peak state is 1300 MHz, against a manual 1600 MHz. The manual pin did as well or better: outside, 17.3 against 15.8; with the indoor parts, 17.3 each. Power was about the same. The owner keeps his manual pin, so the switch isn't in his env.
  • With #906's RX_VK_MESH_FB_LAYOUT=soa on top: =1 16.9 / 18.0, manual 1600 MHz 18.1 / 18.2.

Checks:

  • tests/test_gpu_clock.py fails to compile tests/test_gpu_clock.cpp in an Ubuntu 22.04 container. Its <drm/amdgpu_drm.h> (linux-libc-dev 5.15) has no AMDGPU_CTX_OP_SET_STABLE_PSTATE or AMDGPU_CTX_STABLE_PSTATE_*. This happens with g++ 11.4 and clang++ 23.1.5, on this PR's head e8e49640 too. The __has_include guard finds the old header; also checking for AMDGPU_CTX_OP_SET_STABLE_PSTATE would cover it.
  • On a stack with #225 the source check also fails, with auto_profile no longer has: "Custom GPU 0405". #225 moves the Deck's names and getenv("SteamDeck") into deck_found() and handheld_found(), which auto_profile calls. Reading those two functions as well makes the check pass (our local, test-only change); the build itself is unaffected.
**Deck OLED: `RX_VK_GPU_CLOCK=1` against stock clocks and a manual 1600 MHz, at native 1280x800** Hardware: Steam Deck OLED (AMD Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel), SteamOS 3.9.5, docked, in Game Mode through Steam. Build: a Deck play build, v3.0.0-rc.5 + #225 + #227 + #222 + #977 (off) + #1086 + #1053 + #906 + #790 + #391 + #568 (for #1086, #391 and #568 their own commits, since they sit on newer mains). Linux, the release toolchain (LLVM 23.1.5), `x86-64-v3` with the play profile. Settings: Docked, output 1280x800, the game's own upscaler at 100%, frame generation 3x; `longshot_env.txt` sets `RX_VK_READBACK_LATE=newest`. Method: our moving Kokiri route (80 s), 2 interleaved runs per arm: unset at stock clocks; `=1`; unset with the GPU pinned at 1600 MHz by hand (power level `manual`, as Steam's Manual GPU Clock Control sets it). | | unset, stock | `=1` | unset, manual 1600 MHz | |---|---|---|---| | game fps | 13.4 / 12.7 | 17.3* / 15.8 | 17.3 / 17.3* | | shown fps (frame generation 3x) | 37.7 / 36.0 | 50.5* / 45.7 | 51.0 / 51.2* | | p95 (ms) | 61.7 / 62.1 | 49.6 / 49.5 | 49.4 / 49.1 | | p99 (ms) | 129.8 / 144.3 | 92.1 / 111.9 | 92.6 / 81.9 | | frames over 100 ms | 77 / 92 | 36 / 48 | 34 / 31 | | GPU clock while busy (median) | 1040 MHz | 1300 MHz | 1600 MHz | | APU power, mean (W) | 9.8 / 8.8 | 13.5 / 13.2 | 13.3 / 13.8 | \* These runs went indoors for the last part of the route: `=1`'s first went into the shop and stood in the item pose, the manual run's second went into a house. The other runs stayed outside. - `=1` against stock: median game fps 16.55 against 13.05 (+27%), for about 4 W more. `vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=1 on the Steam Deck's APU; the power level auto -> profile_peak)` appeared in every `=1` run, and the level read `auto` after every exit. - **On the OLED the peak state is 1300 MHz, against a manual 1600 MHz.** The manual pin did as well or better: outside, 17.3 against 15.8; with the indoor parts, 17.3 each. Power was about the same. The owner keeps his manual pin, so the switch isn't in his env. - With #906's `RX_VK_MESH_FB_LAYOUT=soa` on top: `=1` 16.9 / 18.0, manual 1600 MHz 18.1 / 18.2. Checks: - `tests/test_gpu_clock.py` fails to compile `tests/test_gpu_clock.cpp` in an Ubuntu 22.04 container. Its `<drm/amdgpu_drm.h>` (linux-libc-dev 5.15) has no `AMDGPU_CTX_OP_SET_STABLE_PSTATE` or `AMDGPU_CTX_STABLE_PSTATE_*`. This happens with g++ 11.4 and clang++ 23.1.5, on this PR's head `e8e49640` too. The `__has_include` guard finds the old header; also checking for `AMDGPU_CTX_OP_SET_STABLE_PSTATE` would cover it. - On a stack with #225 the source check also fails, with `auto_profile no longer has: "Custom GPU 0405"`. #225 moves the Deck's names and `getenv("SteamDeck")` into `deck_found()` and `handheld_found()`, which `auto_profile` calls. Reading those two functions as well makes the check pass (our local, test-only change); the build itself is unaffected.
`tests/test_gpu_clock.py` builds `tests/test_gpu_clock.cpp` a second time against a copy of the system's
`<drm/amdgpu_drm.h>` with `AMDGPU_CTX_OP_*_STABLE_PSTATE` and `AMDGPU_CTX_STABLE_PSTATE_*` taken out, as the header is
before Linux 5.18 (Ubuntu 22.04's linux-libc-dev 5.15). It fails here: the `__has_include` guard finds that header and
the static_asserts name constants it does not have, as reported on Ubuntu 22.04 with g++ 11.4 and clang++ 23.1.5.

Assisted-by: Claude
Where `<drm/amdgpu_drm.h>` has no `AMDGPU_CTX_OP_SET_STABLE_PSTATE` (before Linux 5.18: Ubuntu 22.04's
linux-libc-dev 5.15), `tests/test_gpu_clock.cpp` writes the stable power states' numbers as the kernel's UAPI gives
them (SET_STABLE_PSTATE 6; NONE 0, STANDARD 1, PEAK 4) and still checks the rest of the ioctl against that header:
the alloc op, `DRM_COMMAND_BASE`, `DRM_AMDGPU_CTX`, `DRM_IOCTL_BASE` and the union's size. Its line says which header
it had. The renderer is unchanged: `gpu/vk/vk_gpu_clock.cpp` never included the header, so it built and held the
state on such a system already.

Assisted-by: Claude
docs: RX_VK_GPU_CLOCK's 1300 MHz is the peak state's, below a 1600 MHz clock set by hand
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/linux+amd+dgpu+gpu-rx-6*_rx-7* 1/1 fail
beanstalk/linux+amd+igpu 1/1 fail
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
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
ac385b8e6f
On the Deck OLED and LCD the peak stable power state holds 1300 MHz, where a GPU clock set by hand (or the automatic
clocks' boost) reaches 1600, and a manual 1600 MHz did as well or better in a Deck OLED play build. The switch's row
says so, and that no stable power state an unprivileged program may ask for is higher.

Assisted-by: Claude
Author
Contributor

Three commits on top, no renderer change. 1c25587b makes tests/test_gpu_clock.py also build against an amdgpu_drm.h from before Linux 5.18; it fails there as dukenheimer saw on Ubuntu 22.04. fda1b886 fixes the check: the stable power states' numbers are written in where the header lacks them, and the rest is still checked against it. The renderer never included that header, so it builds with the feature on the release sysroot. ac385b8e updates the switch's docs row: the peak state's 1300 MHz is below the 1600 MHz a clock set by hand reaches, and no state a program may ask for without root is higher. The description now has omgitsgela's Deck LCD run (which removes the LCD from Needs) and dukenheimer's OLED run at native: +27% against automatic clocks, but a manual 1600 MHz did as well or better. The fixed check is the same with both compilers, and the full suite was run again on this head.

Three commits on top, no renderer change. `1c25587b` makes `tests/test_gpu_clock.py` also build against an `amdgpu_drm.h` from before Linux 5.18; it fails there as dukenheimer saw on Ubuntu 22.04. `fda1b886` fixes the check: the stable power states' numbers are written in where the header lacks them, and the rest is still checked against it. The renderer never included that header, so it builds with the feature on the release sysroot. `ac385b8e` updates the switch's docs row: the peak state's 1300 MHz is below the 1600 MHz a clock set by hand reaches, and no state a program may ask for without root is higher. The description now has omgitsgela's Deck LCD run (which removes the LCD from Needs) and dukenheimer's OLED run at native: +27% against automatic clocks, but a manual 1600 MHz did as well or better. The fixed check is the same with both compilers, and the full suite was run again on this head.
Author
Contributor

Thanks @dukenheimer, this was very useful. All three points are in the description now.

The header check on Ubuntu 22.04. Reproduced and fixed. It was only the test: the renderer never includes <drm/amdgpu_drm.h>. gpu/vk/vk_gpu_clock.cpp writes the ioctl out and needs only <sys/ioctl.h> and <sys/sysmacros.h>, so a build on the release sysroot (glibc 2.35, the same 5.15 headers) has the whole feature, as your play build's vk: GPU clock: ... held line shows. Two commits on top of e8e49640:

  • 1c25587b makes tests/test_gpu_clock.py build the check a second time, against a copy of the system's header with the stable power states taken out (as before Linux 5.18). It fails with your errors (AMDGPU_CTX_STABLE_PSTATE_NONE, _STANDARD, _PEAK and AMDGPU_CTX_OP_SET_STABLE_PSTATE not declared), with g++ 13.3 and clang++ 23.1.5.
  • fda1b886: where the header lacks AMDGPU_CTX_OP_SET_STABLE_PSTATE, test_gpu_clock.cpp defines those four with the kernel's UAPI values (6; 0, 1, 4). It still checks the rest against the old header: the alloc op, DRM_COMMAND_BASE, DRM_AMDGPU_CTX, DRM_IOCTL_BASE and the union's size. Its line says which header it had. Both builds pass with both compilers.

With #225. Your local change works, but we'd rather leave it to whichever of the two lands second than make our check accept both shapes now. The check isn't there to find the names somewhere. It is there to keep gpu_clock.h's own Deck test (steam_deck) the same rule as auto_profile's. #225 changes that rule: deck_found adds the PCI IDs (0x163F, 0x1435) and no longer counts SteamDeck=1, which moves to handheld_found because Steam sets it on other handhelds too. A check that followed the calls into those two functions would pass while gpu_clock.h kept the old rule. That divergence is exactly what it should catch. So:

  • If #225 lands first, we rebase this PR, make RX_VK_GPU_CLOCK=1 follow deck_found (the Deck's APU, not any handheld with SteamDeck=1: we measured it only on Decks), and point the check at deck_found.
  • If this one lands first, #225 updates tests/test_gpu_clock.py the way you did locally, and keeps gpu_clock.h in line with its rule.

1300 against 1600 MHz. Thanks for measuring the manual pin. Measurements and Risks now say plainly that the peak state is 1300 MHz and that a manual 1600 MHz did as well or better at about the same power. The switch is for players who don't set the clock themselves. =1 leaves a manual level alone, so your owner's setup is untouched. We looked for an unprivileged way to 1600 and found none. Our reading of the kernel:

  • AMDGPU_CTX_OP_SET_STABLE_PSTATE takes one of five states: NONE, STANDARD, MIN_SCLK, MIN_MCLK and PEAK; anything above PEAK is -EINVAL. amdgpu_ctx.c maps them to the forced levels auto, profile_standard, profile_min_sclk, profile_min_mclk and profile_peak. There's no capability check (the render node is enough), and only one context may hold a state at a time (-EBUSY otherwise). There's no context op for high or manual.
  • On Van Gogh (vangogh_ppt.c, swsmu), the profile levels are fixed UMD pstate clocks, not the hardware's range: profile_peak 1300 MHz and profile_standard 1100 MHz, which is what you and omgitsgela saw. profile_min_sclk is the shader clock's floor (200 MHz) and profile_min_mclk the memory clock's floor. high is the one that sets the shader clock to its 1600 MHz maximum. Uncertain: the clock values are from our memory of the kernel source, not read from it today. 1300 and 1100 match the runs; the two min levels and high's exact behaviour weren't run.
  • high, manual with pp_od_clk_voltage, and the power profiles are all sysfs files that only root can write. That's what Steam's GPU clock slider uses through SteamOS's privileged helper (#716's steamos-priv-write route). RADV_PROFILE_PSTATE goes through the same context op, so it has the same five states.

So 1600 MHz is the player's call through Steam's own setting (or that helper route), not something a program can ask for. The docs row now says so too (ac385b8e).

Thanks @dukenheimer, this was very useful. All three points are in the description now. **The header check on Ubuntu 22.04.** Reproduced and fixed. It was only the test: the renderer never includes `<drm/amdgpu_drm.h>`. `gpu/vk/vk_gpu_clock.cpp` writes the ioctl out and needs only `<sys/ioctl.h>` and `<sys/sysmacros.h>`, so a build on the release sysroot (glibc 2.35, the same 5.15 headers) has the whole feature, as your play build's `vk: GPU clock: ... held` line shows. Two commits on top of `e8e49640`: - `1c25587b` makes `tests/test_gpu_clock.py` build the check a second time, against a copy of the system's header with the stable power states taken out (as before Linux 5.18). It fails with your errors (`AMDGPU_CTX_STABLE_PSTATE_NONE`, `_STANDARD`, `_PEAK` and `AMDGPU_CTX_OP_SET_STABLE_PSTATE` not declared), with g++ 13.3 and clang++ 23.1.5. - `fda1b886`: where the header lacks `AMDGPU_CTX_OP_SET_STABLE_PSTATE`, `test_gpu_clock.cpp` defines those four with the kernel's UAPI values (6; 0, 1, 4). It still checks the rest against the old header: the alloc op, `DRM_COMMAND_BASE`, `DRM_AMDGPU_CTX`, `DRM_IOCTL_BASE` and the union's size. Its line says which header it had. Both builds pass with both compilers. **With https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/225.** Your local change works, but we'd rather leave it to whichever of the two lands second than make our check accept both shapes now. The check isn't there to find the names somewhere. It is there to keep `gpu_clock.h`'s own Deck test (`steam_deck`) the same rule as `auto_profile`'s. https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/225 changes that rule: `deck_found` adds the PCI IDs (0x163F, 0x1435) and no longer counts `SteamDeck=1`, which moves to `handheld_found` because Steam sets it on other handhelds too. A check that followed the calls into those two functions would pass while `gpu_clock.h` kept the old rule. That divergence is exactly what it should catch. So: - If https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/225 lands first, we rebase this PR, make `RX_VK_GPU_CLOCK=1` follow `deck_found` (the Deck's APU, not any handheld with `SteamDeck=1`: we measured it only on Decks), and point the check at `deck_found`. - If this one lands first, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/225 updates `tests/test_gpu_clock.py` the way you did locally, and keeps `gpu_clock.h` in line with its rule. **1300 against 1600 MHz.** Thanks for measuring the manual pin. Measurements and Risks now say plainly that the peak state is 1300 MHz and that a manual 1600 MHz did as well or better at about the same power. The switch is for players who don't set the clock themselves. `=1` leaves a manual level alone, so your owner's setup is untouched. We looked for an unprivileged way to 1600 and found none. Our reading of the kernel: - `AMDGPU_CTX_OP_SET_STABLE_PSTATE` takes one of five states: `NONE`, `STANDARD`, `MIN_SCLK`, `MIN_MCLK` and `PEAK`; anything above `PEAK` is `-EINVAL`. `amdgpu_ctx.c` maps them to the forced levels `auto`, `profile_standard`, `profile_min_sclk`, `profile_min_mclk` and `profile_peak`. There's no capability check (the render node is enough), and only one context may hold a state at a time (`-EBUSY` otherwise). There's no context op for `high` or `manual`. - On Van Gogh (`vangogh_ppt.c`, swsmu), the profile levels are fixed UMD pstate clocks, not the hardware's range: `profile_peak` 1300 MHz and `profile_standard` 1100 MHz, which is what you and omgitsgela saw. `profile_min_sclk` is the shader clock's floor (200 MHz) and `profile_min_mclk` the memory clock's floor. `high` is the one that sets the shader clock to its 1600 MHz maximum. *Uncertain:* the clock values are from our memory of the kernel source, not read from it today. 1300 and 1100 match the runs; the two `min` levels and `high`'s exact behaviour weren't run. - `high`, `manual` with `pp_od_clk_voltage`, and the power profiles are all sysfs files that only root can write. That's what Steam's GPU clock slider uses through SteamOS's privileged helper (https://git.magicbean.dev/MagicBeanDev/Longshot/issues/716's `steamos-priv-write` route). `RADV_PROFILE_PSTATE` goes through the same context op, so it has the same five states. So 1600 MHz is the player's call through Steam's own setting (or that helper route), not something a program can ask for. The docs row now says so too (`ac385b8e`).
Author
Contributor

Thanks @omgitsgela for the LCD run. It's in the description now under Measurements (idle +7.7% with every on run above every off run, the turning numbers with your noise caveat). It also settles the PR's LCD need, so that Test Farm item is gone.

On your 1300 against 1600 MHz catch: dukenheimer saw the same on an OLED, and a manual 1600 MHz did as well or better there. We looked for a way to get 1600 without root and found none. The context op takes only amdgpu's five stable states (none, standard, the lowest shader or memory clock, peak). On Van Gogh peak is a fixed 1300 MHz, as your watcher showed. high and a manual clock are sysfs writes that need root. So no later toggle on our side can raise the peak, and there's no need to re-run. A Game Mode run of the same four arms would still be welcome if you have the time; it isn't needed for this PR.

Thanks @omgitsgela for the LCD run. It's in the description now under Measurements (idle +7.7% with every on run above every off run, the turning numbers with your noise caveat). It also settles the PR's LCD need, so that Test Farm item is gone. On your 1300 against 1600 MHz catch: dukenheimer saw the same on an OLED, and a manual 1600 MHz did as well or better there. We looked for a way to get 1600 without root and found none. The context op takes only amdgpu's five stable states (none, standard, the lowest shader or memory clock, peak). On Van Gogh peak is a fixed 1300 MHz, as your watcher showed. `high` and a manual clock are sysfs writes that need root. So no later toggle on our side can raise the peak, and there's no need to re-run. A Game Mode run of the same four arms would still be welcome if you have the time; it isn't needed for this PR.
Owner

Tested RX_VK_GPU_CLOCK=peak on a desktop AMD GPU, which the description lists as untested.

Hardware: RX 580 8 GB (Polaris10), RADV/amdgpu, KDE, run as a normal user with no root.
Build: this PR merged with main c167ec67, together with #384 and #906, each behind its own switch.
Method: =peak (P) against unset (B), two interleaved rounds, plus main's own build (M). B and M are the same.
Route: Kokiri Forest, Hyrule Field, the Market, Hyrule Field again; standing, then turning.

It works with no root. The log has vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=peak; the power level auto -> profile_peak), and power_dpm_force_performance_level reads auto again after every run.

GPU ms (fps) B, unset (2 runs) P, =peak (2 runs)
Kokiri, standing 35.60, 35.70 (21.0, 20.8) 32.20, 31.70 (23.1, 23.4)
Kokiri, turning 32.00, 31.65 (22.9, 22.2) 28.30, 28.30 (25.0, 25.0)
Hyrule Field, standing 24.00, 24.30 (28.5, 27.0) 21.85, 21.40 (29.7, 31.3)
Hyrule Field, turning 19.90, 19.90 (34.6, 33.5) 17.90, 17.90 (37.3, 37.6)
the Market, standing 28.80, 28.50 (24.2, 24.1) 25.95, 25.40 (26.2, 27.1)
the Market, turning 18.40, 17.35 (39.2, 35.8) 15.85, 15.90 (41.9, 39.2)
Hyrule Field again, turning 20.10, 20.50 (33.9, 32.0) 18.10, 17.70 (36.1, 38.4)

GPU time is 9 to 11% lower and fps 7 to 12% higher, in every phase and both rounds. So even on a desktop card, amdgpu's auto level leaves performance unused in this game's load. I didn't measure board power or temperature.

=1 (the default when on) doesn't act here, since this isn't a Deck. The gain on a desktop Polaris card suggests offering peak beyond the Deck, but that needs a power measurement first.

🤖 Generated with Claude Code

Tested `RX_VK_GPU_CLOCK=peak` on a desktop AMD GPU, which the description lists as untested. **Hardware:** RX 580 8 GB (Polaris10), RADV/amdgpu, KDE, run as a normal user with no root. **Build:** this PR merged with `main` c167ec67, together with #384 and #906, each behind its own switch. **Method:** `=peak` (P) against unset (B), two interleaved rounds, plus main's own build (M). B and M are the same. **Route:** Kokiri Forest, Hyrule Field, the Market, Hyrule Field again; standing, then turning. It works with no root. The log has `vk: GPU clock: amdgpu's peak power state held while the game runs (RX_VK_GPU_CLOCK=peak; the power level auto -> profile_peak)`, and `power_dpm_force_performance_level` reads `auto` again after every run. | GPU ms (fps) | B, unset (2 runs) | P, `=peak` (2 runs) | |---|---|---| | Kokiri, standing | 35.60, 35.70 (21.0, 20.8) | **32.20, 31.70** (23.1, 23.4) | | Kokiri, turning | 32.00, 31.65 (22.9, 22.2) | **28.30, 28.30** (25.0, 25.0) | | Hyrule Field, standing | 24.00, 24.30 (28.5, 27.0) | **21.85, 21.40** (29.7, 31.3) | | Hyrule Field, turning | 19.90, 19.90 (34.6, 33.5) | **17.90, 17.90** (37.3, 37.6) | | the Market, standing | 28.80, 28.50 (24.2, 24.1) | **25.95, 25.40** (26.2, 27.1) | | the Market, turning | 18.40, 17.35 (39.2, 35.8) | **15.85, 15.90** (41.9, 39.2) | | Hyrule Field again, turning | 20.10, 20.50 (33.9, 32.0) | **18.10, 17.70** (36.1, 38.4) | GPU time is 9 to 11% lower and fps 7 to 12% higher, in every phase and both rounds. So even on a desktop card, amdgpu's `auto` level leaves performance unused in this game's load. I didn't measure board power or temperature. `=1` (the default when on) doesn't act here, since this isn't a Deck. The gain on a desktop Polaris card suggests offering `peak` beyond the Deck, but that needs a power measurement first. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Contributor

Description updated, no code change (head still ac385b8e): HumanBean's RX 580 run with RX_VK_GPU_CLOCK=peak (#1053 (comment)) is in Measurements, Testing and the flag's row. It takes peak on a desktop AMD card off Not tested (GPU time 9-11% lower, fps 7-12% higher, no root, the level back to auto); the card's power with peak and standard anywhere are what remain there. Needs and Must be tested are unchanged: the Deck's battery run and the manual-level check are still to do by hand.

Description updated, no code change (head still `ac385b8e`): HumanBean's RX 580 run with `RX_VK_GPU_CLOCK=peak` (https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-35735) is in Measurements, Testing and the flag's row. It takes `peak` on a desktop AMD card off Not tested (GPU time 9-11% lower, fps 7-12% higher, no root, the level back to `auto`); the card's power with `peak` and `standard` anywhere are what remain there. Needs and Must be tested are unchanged: the Deck's battery run and the manual-level check are still to do by hand.
Author
Contributor

Thanks @HumanBean, this covers a line the description had as untested: peak on a desktop card, as a normal user, with the log line and the level back to auto after every run, and GPU time lower in every phase of both rounds. It's in the description now under Measurements and Testing, and in the flag's row.

On offering peak beyond the Deck: agreed, it needs a power measurement first. By our reading of amdgpu, a profiling power state also turns off the GPU's power and clock gating while it's held, so a desktop card would draw more in menus and at idle too, not only in play. The board power and temperature over a session are the numbers that decide it. That would be its own PR, after this one: here =1 stays the Deck's, and peak/standard stay switches for measuring. If you can read the RX 580's board power (power1_average under its hwmon) in the same rounds, that would be the start of it.

Thanks @HumanBean, this covers a line the description had as untested: `peak` on a desktop card, as a normal user, with the log line and the level back to `auto` after every run, and GPU time lower in every phase of both rounds. It's in the description now under Measurements and Testing, and in the flag's row. On offering `peak` beyond the Deck: agreed, it needs a power measurement first. By our reading of amdgpu, a profiling power state also turns off the GPU's power and clock gating while it's held, so a desktop card would draw more in menus and at idle too, not only in play. The board power and temperature over a session are the numbers that decide it. That would be its own PR, after this one: here `=1` stays the Deck's, and `peak`/`standard` stay switches for measuring. If you can read the RX 580's board power (`power1_average` under its hwmon) in the same rounds, that would be the start of it.
Owner

Suggest turning the hold on by default rather than opt-in:

  • On the Steam Deck: the =1 rule, on by default. That's +45% in Kokiri and +19% in Hyrule Field on yours, and 15.07 → 24.64 fps with #977 and #906 together, for about 4 to 5 W.
  • On discrete AMD GPUs: peak behaviour on by default. On the RX 580 above it gave GPU time 9 to 11% lower and fps 7 to 12% higher in every phase of both rounds, with no root needed and auto restored after every run.
  • On other integrated AMD GPUs (laptops, APUs): leave it off, since battery and heat on those haven't been measured.

One thing to check before the desktop default: board power and temperature on a discrete card under peak, since I didn't measure them. Keep RX_VK_GPU_CLOCK=0 as the way back.

🤖 Generated with Claude Code

Suggest turning the hold on by default rather than opt-in: - **On the Steam Deck:** the `=1` rule, on by default. That's +45% in Kokiri and +19% in Hyrule Field on yours, and 15.07 → 24.64 fps with #977 and #906 together, for about 4 to 5 W. - **On discrete AMD GPUs:** `peak` behaviour on by default. On the RX 580 above it gave GPU time 9 to 11% lower and fps 7 to 12% higher in every phase of both rounds, with no root needed and `auto` restored after every run. - **On other integrated AMD GPUs (laptops, APUs):** leave it off, since battery and heat on those haven't been measured. One thing to check before the desktop default: board power and temperature on a discrete card under `peak`, since I didn't measure them. Keep `RX_VK_GPU_CLOCK=0` as the way back. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Owner

@Beanstalk please test this PR's RX_VK_GPU_CLOCK=peak against RX_VK_GPU_CLOCK unset on AMD hardware other than a Steam Deck or GCN. We need to know whether the hold should be on by default beyond those. Priority order:

  1. A discrete RDNA card, RDNA 2 or 3 if available (RX 6000 / 7000), Linux. Kokiri Forest and the Market, standing and turning, at least two sessions per arm, interleaved. Report fps, GPU time per frame, and the GPU clock while playing (/sys/class/drm/card*/device/pp_dpm_sclk, the active line) in both arms. Board power if the farm can read it (hwmon power1_average). The question is whether profile_peak pins the GPU below the boost clock auto reaches, which would make it slower.
  2. An AMD APU or laptop other than the Deck (a Ryzen with Radeon graphics), Linux, on AC. The same scenes and arms, plus the CPU clock and package power if available. The question is whether holding the GPU at peak takes power from the CPU and lowers fps in CPU-bound scenes.
  3. On any AMD machine above, a crash test. With =peak, kill the game with kill -9 while playing, then read power_dpm_force_performance_level. We need to know it goes back to auto and doesn't stay on profile_peak until reboot.

For reference, the RX 580 (GCN) runs in my comment above gave fps +7 to +12% and GPU time 9 to 11% lower. Either way, a log line like vk: GPU clock: amdgpu's peak power state held ... confirms the hold took effect.

🤖 Generated with Claude Code

@Beanstalk please test this PR's `RX_VK_GPU_CLOCK=peak` against `RX_VK_GPU_CLOCK` unset on AMD hardware other than a Steam Deck or GCN. We need to know whether the hold should be on by default beyond those. Priority order: 1. **A discrete RDNA card, RDNA 2 or 3 if available (RX 6000 / 7000), Linux.** Kokiri Forest and the Market, standing and turning, at least two sessions per arm, interleaved. Report fps, GPU time per frame, and the GPU clock while playing (`/sys/class/drm/card*/device/pp_dpm_sclk`, the active line) in both arms. Board power if the farm can read it (`hwmon` `power1_average`). The question is whether `profile_peak` pins the GPU *below* the boost clock `auto` reaches, which would make it slower. 2. **An AMD APU or laptop other than the Deck (a Ryzen with Radeon graphics), Linux, on AC.** The same scenes and arms, plus the CPU clock and package power if available. The question is whether holding the GPU at peak takes power from the CPU and lowers fps in CPU-bound scenes. 3. **On any AMD machine above, a crash test.** With `=peak`, kill the game with `kill -9` while playing, then read `power_dpm_force_performance_level`. We need to know it goes back to `auto` and doesn't stay on `profile_peak` until reboot. For reference, the RX 580 (GCN) runs in my comment above gave fps +7 to +12% and GPU time 9 to 11% lower. Either way, a log line like `vk: GPU clock: amdgpu's peak power state held ...` confirms the hold took effect. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Member
Beanstalk test farm · an earlier run: commit ac385b8 (the newer results are in a comment below)

Commit ac385b8 · tier reviewed · approved by HumanBean · dashboard

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

Two interleaved sessions compare main with GPU clocks unset against the PR with peak requested on Linux AMD hardware, sampling FPS and GPU time in Kokiri Forest and the Market before and after camera turns. The discrete target covers RX 6000 and 7000 cards; the integrated target may wait for a suitable non-Deck tester and cannot exclude Decks automatically. Each tester’s game runs take about 30 minutes; crashes, a 10% FPS drop, or a 15% GPU-time increase fail. The farm cannot read clocks or power, ensure AC power, confirm the peak-hold log only on the PR, or perform the requested kill-and-restoration test.

  • Where: linux+amd+dgpu+gpu-rx-6*_rx-7* (GPU "rx 6*" or "rx 7*", 1 report), linux+amd+igpu (1 report).
  • Matrix: 1 cell, each on main and the PR: RX_VK_GPU_CLOCK peak (PR only).
  • forest-market: from a new save, then measure forest-standing for 20 s (after 10 s warm-up), move the stick, measure forest-after-turn for 20 s (after 0 s warm-up), teleport to Market, measure market-standing for 20 s (after 10 s warm-up), measure market-after-turn for 20 s (after 0 s warm-up); 2 runs on each side.
  • Measured: crashes, frame times, stutters and hitches, draws and frame rate, GPU time per pass.
  • The PR fails if: it crashes; or frame rate is more than 10% below main; or GPU time a frame is more than 15% above main.
  • Time: about 31 min of game runs per tester (4 game starts), plus the two builds.

Done. Comment @Beanstalk to run it again.

Target Reports Crash Frame p99 (ms) vs main VRAM peak (MB) vs main Result
linux+amd+dgpu+gpu-rx-6*_rx-7* · 1: linux+amd+radv+dgpu AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7 1/1 1 none 1640.6 vs 1109.9 (+48%) — fail
linux+amd+igpu · 1: linux+amd+radv+igpu+handheld AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99 1/1 1 none 383.0 vs 221.3 (+73%) — fail

Measurements · linux+amd+dgpu+gpu-rx-6*_rx-7*

Verdict: fail on linux+amd+dgpu+gpu-rx-6*_rx-7* (1/1 report): forest-market forest-standing.fps_mean.min_delta_pct (-24.1%) failed.

Hardware: 1: linux+amd+radv+dgpu AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7 AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM
Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ e4d035e After: this PR @ ac385b8
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · forest-standing · frame rate 0.8 0.6 (−24%)
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · forest-standing · frame time (p99) (ms) 1,110 1,641 (+48%)

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_GPU_CLOCK switch the PR adds (set on the PR side only) peak not in main the PR's default forest-market, main without it → the PR with peak: 0.8 → 0.6 (−24%) doesn't help
Markdown for the PR description
## Measurements

**Verdict:** fail on linux+amd+dgpu+gpu-rx-6*_rx-7* (1/1 report): `forest-market forest-standing.fps_mean.min_delta_pct (-24.1%)` failed.

Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM`  
Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ e4d035e | After: this PR @ ac385b8 |
|---|---|---|
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame rate | 0.8 | 0.6 (−24%) |
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame time (p99) (ms) | 1,110 | 1,641 (+48%) |

### 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_GPU_CLOCK` | switch the PR adds (set on the PR side only) | `peak` | not in main | the PR's default | forest-market, main without it → the PR with peak: 0.8 → 0.6 (−24%) | doesn't help |

Measurements · linux+amd+igpu

Verdict: fail on linux+amd+igpu (1/1 report): forest-market forest-standing.fps_mean.min_delta_pct (-29.3%) failed.

Hardware: 1: linux+amd+radv+igpu+handheld AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99 AMD Custom APU 0932, 16 GB RAM
Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ e4d035e After: this PR @ ac385b8
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · forest-standing · frame rate 5.9 4.2 (−29%)
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · market-standing · frame rate 1.2 —
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · forest-after-turn · frame rate 7.2 —
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · forest-standing · frame time (p99) (ms) 221.3 383.0 (+73%)
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · market-standing · frame time (p99) (ms) 2,738 —
forest-market · RX_VK_GPU_CLOCK=peak (PR only) · forest-after-turn · frame time (p99) (ms) 177.2 —

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_GPU_CLOCK switch the PR adds (set on the PR side only) peak not in main the PR's default forest-market, main without it → the PR with peak: 5.9 → 4.2 (−29%) doesn't help
Markdown for the PR description
## Measurements

**Verdict:** fail on linux+amd+igpu (1/1 report): `forest-market forest-standing.fps_mean.min_delta_pct (-29.3%)` failed.

Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0932, 16 GB RAM`  
Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ e4d035e | After: this PR @ ac385b8 |
|---|---|---|
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame rate | 5.9 | 4.2 (−29%) |
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · market-standing · frame rate | 1.2 | — |
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-after-turn · frame rate | 7.2 | — |
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame time (p99) (ms) | 221.3 | 383.0 (+73%) |
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · market-standing · frame time (p99) (ms) | 2,738 | — |
| forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-after-turn · frame time (p99) (ms) | 177.2 | — |

### 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_GPU_CLOCK` | switch the PR adds (set on the PR side only) | `peak` | not in main | the PR's default | forest-market, main without it → the PR with peak: 5.9 → 4.2 (−29%) | doesn't help |
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>ac385b8</code> (the newer results are in a comment below)</summary> Commit `ac385b8` · tier **reviewed** · approved by HumanBean · [dashboard](https://beanstalk.magicbean.dev/prs/1053) **What will be tested** · AI plan (`gpt-6.1-terra`) Two interleaved sessions compare main with GPU clocks unset against the PR with peak requested on Linux AMD hardware, sampling FPS and GPU time in Kokiri Forest and the Market before and after camera turns. The discrete target covers RX 6000 and 7000 cards; the integrated target may wait for a suitable non-Deck tester and cannot exclude Decks automatically. Each tester’s game runs take about 30 minutes; crashes, a 10% FPS drop, or a 15% GPU-time increase fail. The farm cannot read clocks or power, ensure AC power, confirm the peak-hold log only on the PR, or perform the requested kill-and-restoration test. - **Where:** linux+amd+dgpu+gpu-rx-6*_rx-7* (GPU "rx 6*" or "rx 7*", 1 report), linux+amd+igpu (1 report). - **Matrix:** 1 cell, each on main and the PR: RX_VK_GPU_CLOCK `peak` (PR only). - **forest-market:** from a new save, then measure forest-standing for 20 s (after 10 s warm-up), move the stick, measure forest-after-turn for 20 s (after 0 s warm-up), teleport to Market, measure market-standing for 20 s (after 10 s warm-up), measure market-after-turn for 20 s (after 0 s warm-up); 2 runs on each side. - **Measured:** crashes, frame times, stutters and hitches, draws and frame rate, GPU time per pass. - **The PR fails if:** it crashes; or frame rate is more than 10% below main; or GPU time a frame is more than 15% above main. - **Time:** about 31 min of game runs per tester (4 game starts), plus the two builds. Done. Comment `@Beanstalk` to run it again. | Target | Reports | Crash | Frame p99 (ms) vs main | VRAM peak (MB) vs main | Result | | --- | --- | --- | --- | --- | --- | | linux+amd+dgpu+gpu-rx-6*_rx-7* · 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` | 1/1 [1](https://beanstalk.magicbean.dev/reports/rp_45147b58471bec61) | none | 1640.6 vs 1109.9 (+48%) | — | fail | | linux+amd+igpu · 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` | 1/1 [1](https://beanstalk.magicbean.dev/reports/rp_1c89b9203860fe47) | none | 383.0 vs 221.3 (+73%) | — | fail | #### Measurements · linux+amd+dgpu+gpu-rx-6*_rx-7* **Verdict:** fail on linux+amd+dgpu+gpu-rx-6*_rx-7* (1/1 report): `forest-market forest-standing.fps_mean.min_delta_pct (-24.1%)` failed. Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM` Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ e4d035e | After: this PR @ ac385b8 | |---|---|---| | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame rate | 0.8 | 0.6 (−24%) | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame time (p99) (ms) | 1,110 | 1,641 (+48%) | ### 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_GPU_CLOCK` | switch the PR adds (set on the PR side only) | `peak` | not in main | the PR's default | forest-market, main without it → the PR with peak: 0.8 → 0.6 (−24%) | doesn't help | <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** fail on linux+amd+dgpu+gpu-rx-6*_rx-7* (1/1 report): `forest-market forest-standing.fps_mean.min_delta_pct (-24.1%)` failed. Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM` Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ e4d035e | After: this PR @ ac385b8 | |---|---|---| | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame rate | 0.8 | 0.6 (−24%) | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame time (p99) (ms) | 1,110 | 1,641 (+48%) | ### 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_GPU_CLOCK` | switch the PR adds (set on the PR side only) | `peak` | not in main | the PR's default | forest-market, main without it → the PR with peak: 0.8 → 0.6 (−24%) | doesn't help | ``` </details> #### Measurements · linux+amd+igpu **Verdict:** fail on linux+amd+igpu (1/1 report): `forest-market forest-standing.fps_mean.min_delta_pct (-29.3%)` failed. Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0932, 16 GB RAM` Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ e4d035e | After: this PR @ ac385b8 | |---|---|---| | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame rate | 5.9 | 4.2 (−29%) | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · market-standing · frame rate | 1.2 | — | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-after-turn · frame rate | 7.2 | — | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame time (p99) (ms) | 221.3 | 383.0 (+73%) | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · market-standing · frame time (p99) (ms) | 2,738 | — | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-after-turn · frame time (p99) (ms) | 177.2 | — | ### 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_GPU_CLOCK` | switch the PR adds (set on the PR side only) | `peak` | not in main | the PR's default | forest-market, main without it → the PR with peak: 5.9 → 4.2 (−29%) | doesn't help | <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** fail on linux+amd+igpu (1/1 report): `forest-market forest-standing.fps_mean.min_delta_pct (-29.3%)` failed. Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0932, 16 GB RAM` Scene: forest-market, from a new save; 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); forest-market: 2 game starts a side, forest-standing 20 s after 10 s warm-up, forest-after-turn 20 s after 0 s warm-up, market-standing 20 s after 10 s warm-up, market-after-turn 20 s after 0 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ e4d035e | After: this PR @ ac385b8 | |---|---|---| | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame rate | 5.9 | 4.2 (−29%) | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · market-standing · frame rate | 1.2 | — | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-after-turn · frame rate | 7.2 | — | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-standing · frame time (p99) (ms) | 221.3 | 383.0 (+73%) | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · market-standing · frame time (p99) (ms) | 2,738 | — | | forest-market · `RX_VK_GPU_CLOCK=peak (PR only)` · forest-after-turn · frame time (p99) (ms) | 177.2 | — | ### 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_GPU_CLOCK` | switch the PR adds (set on the PR side only) | `peak` | not in main | the PR's default | forest-market, main without it → the PR with peak: 5.9 → 4.2 (−29%) | doesn't help | ``` </details> </details>
Author
Contributor

Thanks @HumanBean, and for starting the farm run. Where we stand on defaults:

  • Steam Deck, the =1 rule on by default: yes in principle, with two open points. It has not been measured on battery or over a long session, and it costs 4 to 5 W where the APU was not already at its limit, which on a handheld is battery life. And a player who sets Steam's manual GPU clock to 1600 MHz gets as much or more (@dukenheimer's run above); the hold leaves a manual level alone, so the two do not fight. We will run the battery and long-session measurement on our Deck and send the Deck default as a follow-up with those numbers.
  • Discrete AMD, peak by default: worth it only if the farm run shows profile_peak does not sit below what auto boosts to on RDNA cards (on the Deck, peak is 1300 MHz against a 1600 MHz maximum, so on some chips it could be a cap), and with a board power figure. Your three questions to the farm are the right ones; the kill test passed on the Deck (the level was auto 1 s after kill -9), since the kernel drops the state with the context.
  • Other integrated AMD: agreed, off until measured.

As with the other two, we would keep this PR as the measured opt-in and send each default as its own small PR.

Thanks @HumanBean, and for starting the farm run. Where we stand on defaults: - **Steam Deck, the `=1` rule on by default:** yes in principle, with two open points. It has not been measured on battery or over a long session, and it costs 4 to 5 W where the APU was not already at its limit, which on a handheld is battery life. And a player who sets Steam's manual GPU clock to 1600 MHz gets as much or more (@dukenheimer's run above); the hold leaves a manual level alone, so the two do not fight. We will run the battery and long-session measurement on our Deck and send the Deck default as a follow-up with those numbers. - **Discrete AMD, `peak` by default:** worth it only if the farm run shows `profile_peak` does not sit below what `auto` boosts to on RDNA cards (on the Deck, peak is 1300 MHz against a 1600 MHz maximum, so on some chips it could be a cap), and with a board power figure. Your three questions to the farm are the right ones; the kill test passed on the Deck (the level was `auto` 1 s after `kill -9`), since the kernel drops the state with the context. - **Other integrated AMD:** agreed, off until measured. As with the other two, we would keep this PR as the measured opt-in and send each default as its own small PR.
Owner

We're turning the =1 rule on by default for the Steam Deck in this PR. Elsewhere it stays as it is: peak and standard are opt-in on other AMD GPUs, and other APUs and laptops are off. I'll push it on top of a rebase, and the review follows.

Why the Deck now:

  • The gain is large and confirmed by three testers on both models: OLED +46% in Kokiri at handheld settings and +19% in Hyrule Field at native (yours), +27% in dukenheimer's play build, LCD +8% standing and +10 to 20% turning (omgitsgela).
  • It changes nothing about the picture or memory. It asks the kernel for a clock, which the kernel takes back at exit, kill -9 included.
  • A level the player chose stays theirs. A player who sets 1600 MHz by hand keeps it, and gets the most.
  • The cost is battery: about 4 W where the APU isn't already at its 15 W limit. At these frame rates we think Deck players would take the fps. RX_VK_GPU_CLOCK=0 is the way back.

The battery and long-session runs move from a gate to a follow-up. If they show something worse than about 4 W, for example throttling below automatic clocks, or much more drawn while paused because power gating is off, we revisit the default.

Why not peak on other AMD GPUs yet: it holds the GPU at amdgpu's fixed profiling clock, and on the Deck that is below the boost clock (1300 against 1600 MHz). A GPU-bound RDNA card that boosts normally could run slower. Your RX 580 gained, but that's the only card measured. Discrete AMD can follow once one valid RDNA run shows no cap.

The Test Farm run above doesn't count, either way. It measured 0.8 fps on an RX 7900 XTX and 5.9 fps on a Deck, with p99 frame times of 1 to 2.7 s. That is the game compiling shaders after a cold start, with main and the PR as separate builds each starting their own caches. Its "−24% / −29%" is not this switch. A rerun needs warm caches on both sides.

🤖 Generated with Claude Code

We're turning the `=1` rule on by default for the Steam Deck in this PR. Elsewhere it stays as it is: `peak` and `standard` are opt-in on other AMD GPUs, and other APUs and laptops are off. I'll push it on top of a rebase, and the review follows. **Why the Deck now:** - **The gain is large and confirmed by three testers on both models:** OLED +46% in Kokiri at handheld settings and +19% in Hyrule Field at native (yours), +27% in dukenheimer's play build, LCD +8% standing and +10 to 20% turning (omgitsgela). - **It changes nothing about the picture or memory.** It asks the kernel for a clock, which the kernel takes back at exit, `kill -9` included. - **A level the player chose stays theirs.** A player who sets 1600 MHz by hand keeps it, and gets the most. - **The cost is battery:** about 4 W where the APU isn't already at its 15 W limit. At these frame rates we think Deck players would take the fps. `RX_VK_GPU_CLOCK=0` is the way back. The battery and long-session runs move from a gate to a follow-up. If they show something worse than about 4 W, for example throttling below automatic clocks, or much more drawn while paused because power gating is off, we revisit the default. **Why not `peak` on other AMD GPUs yet:** it holds the GPU at amdgpu's fixed profiling clock, and on the Deck that is below the boost clock (1300 against 1600 MHz). A GPU-bound RDNA card that boosts normally could run slower. Your RX 580 gained, but that's the only card measured. Discrete AMD can follow once one valid RDNA run shows no cap. **The Test Farm run above doesn't count, either way.** It measured 0.8 fps on an RX 7900 XTX and 5.9 fps on a Deck, with p99 frame times of 1 to 2.7 s. That is the game compiling shaders after a cold start, with main and the PR as separate builds each starting their own caches. Its "−24% / −29%" is not this switch. A rerun needs warm caches on both sides. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HumanBean force-pushed gpu-peak-power-state from ac385b8e6f
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/linux+amd+dgpu+gpu-rx-6*_rx-7* 1/1 fail
beanstalk/linux+amd+igpu 1/1 fail
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
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to e91acea6a0
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 13s
Third-party parts / As their notes say (pull_request) Successful in 18s
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval changed since the request: ask again
2026-11-16 17:42:58 +00:00
Compare
Member

Beanstalk test farm

Commit e91acea · tier untrusted · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `e91acea` · tier **untrusted** · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/1053) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
HumanBean changed title from perf(vk): the Steam Deck's GPU held at amdgpu's peak power state while the game runs (RX_VK_GPU_CLOCK=1, off by default) to perf(vk): the Steam Deck's GPU held at amdgpu's peak power state while the game runs (RX_VK_GPU_CLOCK, on by default on the Deck) 2026-11-16 17:43:43 +00:00
HumanBean approved these changes 2026-11-16 17:45:46 +00:00
HumanBean left a comment

I read it as code only and ran nothing. Approved, with the Deck default pushed on top, as decided in #1053 (comment).

Pushed (head e91acea6):

  • Rebase: the six commits are rebased one by one onto main 26ce01b5, with no conflict. sheep's authorship is kept.
  • e91acea6, the default:
    • Unset now follows the =1 rule, but only on the Deck's own APU, matched by name (deck_apu: Custom GPU 0405 or 0932).
    • Another handheld with Steam's SteamDeck=1 still needs =1. The default would otherwise reach a ROG Ally or Legion Go under a SteamOS-like session, unmeasured, where the peak state may sit below the boost clock.
    • looked_at keeps the early return: off the Deck, unset, nothing is read or opened and nothing is logged.
    • =0, off and an empty value are still the driver's own clocks, and peak and standard are still asked for by name.
    • Tests: test_gpu_clock.cpp checks unset on the Deck (the peak, a chosen level left alone, a level that couldn't be read), on a SteamDeck=1 handheld and on another AMD GPU. test_gpu_clock.py checks the APU is known before the early return.
    • Docs: the doc row (it keeps the `RX_VK_GPU_CLOCK=1` text the check needs) and the playbook's paragraph about #716 are updated.
  • Description: the title and description say the default. The battery, long-session and manual-level checks are now follow-ups, not gates.

What I checked in sheep's code:

  • The ioctl matches the kernel's amdgpu_drm.h:
    • drm_amdgpu_ctx_in is op, flags, ctx_id, priority; the union is 16 bytes.
    • ALLOC_CTX is 1 and SET_STABLE_PSTATE is 6.
    • PEAK is 4 and STANDARD is 1.
    • The ioctl is _IOWR('d', 0x42, ...).
    • The test also checks it against the system header, old or new.
  • Each error path closes the render node's file. Once the state is held, the file stays open on purpose, so the kernel gives the level back when the process ends. The Deck's kill -9 run confirms it.
  • The level is read before the choice, so a level someone chose stays theirs. A write to power_dpm_force_performance_level during the game overrides the hold, as Risks says.
  • It runs once, after vkCreateDevice. It is Linux only and empty on Windows.

Not run:

  • The checks were not run on e91acea6; tests/test_gpu_clock.py is the one it changes.
  • The battery and long-session runs on a Deck are follow-ups.

On the Test Farm run above: its 0.8 fps on an RX 7900 XTX and 5.9 fps on a Deck are cold-start shader compiling, so its "fail" is not this switch.

🤖 Generated with Claude Code

I read it as code only and ran nothing. Approved, with the Deck default pushed on top, as decided in https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1053#issuecomment-37190. **Pushed (head `e91acea6`):** - **Rebase:** the six commits are rebased one by one onto `main` 26ce01b5, with no conflict. sheep's authorship is kept. - **`e91acea6`, the default:** - Unset now follows the `=1` rule, but only on the Deck's own APU, matched by name (`deck_apu`: Custom GPU 0405 or 0932). - Another handheld with Steam's `SteamDeck=1` still needs `=1`. The default would otherwise reach a ROG Ally or Legion Go under a SteamOS-like session, unmeasured, where the peak state may sit below the boost clock. - `looked_at` keeps the early return: off the Deck, unset, nothing is read or opened and nothing is logged. - `=0`, `off` and an empty value are still the driver's own clocks, and `peak` and `standard` are still asked for by name. - Tests: `test_gpu_clock.cpp` checks unset on the Deck (the peak, a chosen level left alone, a level that couldn't be read), on a `SteamDeck=1` handheld and on another AMD GPU. `test_gpu_clock.py` checks the APU is known before the early return. - Docs: the doc row (it keeps the `` `RX_VK_GPU_CLOCK=1` `` text the check needs) and the playbook's paragraph about #716 are updated. - **Description:** the title and description say the default. The battery, long-session and manual-level checks are now follow-ups, not gates. **What I checked in sheep's code:** - **The ioctl matches the kernel's `amdgpu_drm.h`:** - `drm_amdgpu_ctx_in` is op, flags, ctx_id, priority; the union is 16 bytes. - `ALLOC_CTX` is 1 and `SET_STABLE_PSTATE` is 6. - `PEAK` is 4 and `STANDARD` is 1. - The ioctl is `_IOWR('d', 0x42, ...)`. - The test also checks it against the system header, old or new. - **Each error path closes the render node's file. Once the state is held, the file stays open on purpose**, so the kernel gives the level back when the process ends. The Deck's `kill -9` run confirms it. - **The level is read before the choice, so a level someone chose stays theirs.** A write to `power_dpm_force_performance_level` during the game overrides the hold, as Risks says. - **It runs once, after `vkCreateDevice`.** It is Linux only and empty on Windows. **Not run:** - The checks were not run on `e91acea6`; `tests/test_gpu_clock.py` is the one it changes. - The battery and long-session runs on a Deck are follow-ups. On the Test Farm run above: its 0.8 fps on an RX 7900 XTX and 5.9 fps on a Deck are cold-start shader compiling, so its "fail" is not this switch. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
@ -0,0 +60,4 @@
if (e && !strcmp(e, "standard")) return {STANDARD, "RX_VK_GPU_CLOCK=standard"};
if (e && strcmp(e, "1")) return {NONE, "RX_VK_GPU_CLOCK is not 0, 1, peak or standard"};
if (!(e ? f.deck : f.deck_apu)) // (unset: the Deck's own APU only; another handheld with SteamDeck=1 was not measured)
return {NONE, "measured on the Steam Deck only (RX_VK_GPU_CLOCK=1 or peak asks for it here)"};
Owner

Unset uses deck_apu, not deck: Steam's SteamDeck=1 alone (another handheld) needs =1, as it wasn't measured.

Unset uses deck_apu, not deck: Steam's SteamDeck=1 alone (another handheld) needs =1, as it wasn't measured.
HumanBean deleted branch gpu-peak-power-state 2026-11-16 17:49:00 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 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!1053
No description provided.