WIP: perf(vk): the game's fragments-only barriers wait in the fragment stages (RX_VK_GAME_BARRIER) #2290
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2290
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:perf/game-barrier-flags"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Every
nvnCommandBufferBarrierof the game's ended the render pass and recorded a full barrier (all commands to allcommands), whatever its NVN bits said; the bits were only counted. 56-66 of them a frame in Kokiri Forest, Hyrule Field and
the Market carry only
ORDER_FRAGMENTSandINVALIDATE_TEXTURE(0x12, 67-77 a frame; 0x2, 0x4, 0x6, 0x10, 0x14 and 0x16are treated the same way): on the console, later fragment work waits for earlier fragment work, and later geometry work
does not wait.
Such a barrier still ends the pass, and now records the barrier a draw pass after draw passes already starts with
(
pass_start_barrier): every earlier write, from every stage, made visible to the fragment-side stages; the next pass startthen records no second one. It stays the full barrier when the bits hold anything else (
ORDER_PRIMITIVES,ORDER_INDIRECT_DATA,INVALIDATE_SHADER,INVALIDATE_TEXTURE_DESCRIPTOR,INVALIDATE_ZCULL, an unknown bit or no bit),when anything but draw passes was recorded since the last full barrier (a dispatch, a copy, a fill, a barrier on another
command buffer), and when indirect mesh draws after it are converted there (
RX_VK_MESH_CONV=2: their copies follow a fullbarrier as before). A dispatch after it keeps its own full barrier.
RX_VK_GAME_BARRIER=0gives every barrier of the game'sthe full barrier again; it is read at each recording's start, so
HOS_ABcan alternate it.Result: about 50-60 fewer full barriers a frame (RTX: 328.9 to 278.6 recorded in Kokiri Forest, 400.5 to 346.6 in Hyrule
Field, 382.0 to 319.9 in the Market), 0.1-0.75 ms less GPU time a frame, +1.9 % fps in Hyrule Field on an RTX 4070 Ti and
gains within the spread elsewhere (Measurements).
Read first:
gpu/vk/game_barrier.h(the bits' rule and where each bit's meaning comes from),game_fragment_barrierandpass_start_barrieringpu/vk/vk_texture.cpp,NOP_BARRIERandmesh_conv_at_barrieringpu/vk/vk_replay.cpp.What the bits mean, and what this relied on: the names in
gpu/render/nvn_api.h(NVNbarrierBits); the Maxwell methodsthey become, named in suyu's
gpu/third_party/suyu/video_core/maxwell_3d_regs.h(wait_for_idle0x110,fragment_barrier0xDE0,
tiled_cache_barrier0xF7C,invalidate_texture_data_cache0xF74, the shader cache invalidation); and thebit-to-method mapping of the open-source deko3d driver (
maxwell/gpu_base.cpp), whose method numbers are those registers'(0x44, 0x378, 0x3DF, 0x3DD, in words).
Whether anything the game does needs more than that was counted in the game rather than assumed:
RX_VK_GAME_BARRIER_CENSUS=1(diag, off) follows each command buffer from its last full barrier and checks every draw's non-fragment stages (textures,
storage images, uniform and storage buffers by guest address, global memory), its vertex, index and indirect fetches, and
non-fragment stores against what was written before a fragments-only barrier of the game's. Every replay op that records
other GPU work (copies, clears, buffer fills, event signals, dispatches, the mesh conversion and the mesh fallback's records)
already starts with a full barrier, which is never left out after this one; so draws were the only exposure.
Prior work: none narrows the game's barriers by their bits (searched: nvnCommandBufferBarrier, ORDER_FRAGMENTS,
INVALIDATE_TEXTURE, RX_VK_GAME_BARRIER, "game's barrier", "fragment stage"). Related: #2072 (dispatch after dispatch,
RX_VK_DISPATCH_BARRIER) works alongside it: after any dispatch this barrier is full, which also pays #2072's owedbarrier; expect plain text conflicts in
vk_texture.cppandvk_replay.cpp. Hookshot'shttps://git.notrexed.dev/Hookshot/Hookshot/pulls/2559 (closed) went the other way: it kept the game's barriers full and
dropped our own between passes and dispatches. The pass start's barrier after non-draw work is claimed in the team room
(2026-11-21): same function, another case.
Testing
Tested: Linux 7.0, RTX 4070 Ti (NVIDIA 595.99.02) at 2560x1440, and the AMD Ryzen 7 9800X3D's iGPU (RADV, Mesa
26.0.8) at 1280x720 (
RX_VK_DEVICE=1 HOS_OUTPUT_RES=1280x720 RX_VK_AUTO_TUNE=0), in Kokiri Forest, Hyrule Field and theMarket:
storage-buffer memory, fetches, global memory, non-fragment stores). 84-89 such barriers per 120 presents do follow a draw
that stored to memory, but nothing reads it before the next full barrier;
RX_VK_VALIDATION=1,VK_KHRONOS_VALIDATION_VALIDATE_SYNC=true, core validation off, theshader-accesses heuristic on, 30 s), Kokiri Forest and the Market, RTX, on
mainand here: the same four kinds ofmessages on both sides, all
main's own (a depth attachment's store against sampling in its pass, vertex sampling aftervkCmdClearAttachmentswith only pass starts between, sampling after a colour write in one pass); no new kind;logdiffof the problem lines againstmain: nothing new or gone on either GPU; scene shots of the same spots match;tests/test_game_barrier.py(new): the bits' rule for every combination, and the barriers recorded (fragments-onlyafter draw passes, after a dispatch, a copy or another command buffer's barrier, two in a row, before a dispatch, before
indirect mesh draws to convert, the switch and the A/B both ways), its ten broken copies failing, one of them
main's(every barrier full);
test_pass_barrier.py,test_mesh_conv.pyandtest_hos_ab.pyupdated for the moved text;tests/run_all.py, through tools'suite.py compareagainstmain@a2dc5385): 906 passed, 22failed, 26 skipped against 904/22/26; no check fails here only. The 22 fail on
maintoo: nx2/test_import_windows,test_close_waits_for_save, test_compile_zero_byte, test_damaged_rom_files, test_dev_packs, test_draw_stream_visibility,
test_fs_save_commit, test_fsr_uniform_ownership, test_guest_copies, test_hold_toggle, test_lower_atomg_cas,
test_menu_i18n, test_menu_keys, test_menu_slider_ends, test_pads_after_menu, test_recording_admission,
test_sim_turf_pools, test_sim_turf_settings, test_switch_table, test_thinlto_tls, test_tls_objects, test_vibration_menu.
Still to test:
RX_VK_GAME_BARRIER_CENSUS=1, expectingevery "after a fragments-only barrier" count at 0, and no flicker (@Beanstalk)
67ba729d(this branch's base now), or a note that nothing between changes the barriers (by hand)Measurements
Verdict: a small gain. RTX 4070 Ti: +1.9 % fps in Hyrule Field (every After run above every Before run), +0.4 % in
Kokiri Forest and +0.7 % in the Market (within the spread); GPU time 0.10-0.20 ms a frame lower in every one of the 9 run
pairs. AMD iGPU: +0.4 % / +1.7 % / +0.5 % fps (within the spread), GPU time lower in 8 of 9 pairs (median -0.10 to -0.75 ms).
The switch ships on.
Setup: Linux 7.0; RTX 4070 Ti (NVIDIA 595.99.02), 2560x1440, the runtime's options (Quality preset 6, Render resolution
row 1), V-Sync off, uncapped (
HOS_FPS_MAX=1000); AMD Ryzen 7 9800X3D iGPU (RADV, Mesa 26.0.8), 1280x720, auto-tune off.Each run: tools'
gamerun.py --mode timing(the queue's timed mode, alone on the GPU: checked for every run from thequeue's history), the repository's kokiri-start save, the Debug tab's teleport, 60 s standing; the frame trace's last 55 s
(less 2 s); 3 runs a side, interleaved (main first in odd rounds), the median. The RTX's first Kokiri Forest pair ran beside
CPU test suites (Before: 105.7 fps, p99 48 ms) and was replaced by a fourth pair; every other run had the GPU and the CPU to
itself. The After runs set
RX_VK_OCC_EMPTY=0, sothey differ from
mainonly by this change and the census code (off). GPU time: the log'sGPU timeline, median of thelast four.
a2dc5385With
RX_VK_PASS_TIMING=1(one run a side; each timestamp waits for the work before it, so spans show a barrier's own cost,not the overlap it allows): the game's full-barrier spans a frame on the RTX fall from 105.5 / 108.5 / 119.8 (0.272 /
0.285 / 0.312 ms) to 50.5 / 51.5 / 54.7 (0.120 / 0.131 / 0.132 ms); all barrier spans 0.464 / 0.583 / 0.560 ms to
0.349 / 0.485 / 0.424 ms. On the AMD iGPU full barriers fall from 480 / 489 to 427 / 427 a frame (Forest / Market).
The RTX frame is not GPU-bound here (6 ms of GPU work in a 7-8 ms frame), so its fps gain is the GPU's shorter waits showing
through the frame wait; the iGPU is GPU-bound throughout.
Log lines (branch, Hyrule Field, RTX):
Risks
A vertex, task or mesh stage, or a vertex/index/indirect fetch, that reads what a pass wrote before such a barrier with no
full barrier between would read it unordered. The console's own driver waits for idle before a texture invalidate, so the
game could rely on more than the bits say; the census found no such read in the six scene and GPU pairs measured, and the
validation layer no new hazard in two scenes, but other areas (dungeons, cutscenes) are unmeasured.
RX_VK_GAME_BARRIER=0restores the full barrier at once; nothing changes on disk.
Found on the way, not changed here:
mainalready lets a vertex stage sample a target written since the last fullbarrier with only relaxed pass starts between (the census's "pass starts alone" class, 360 per 120 presents: programs
f8c237d19f90b5fb, ddd080229f785e4d, 37837d2e5833bc1c reading R32F targets #207/#208/#211 after a
vkCmdClearAttachments;the validation layer's 600-1,150 vertex-read-after-clear messages per 30 s). That is
pass_start_barrier's rule, aseparate question.
The method comes from reading Rekarina's notes (another PC port of this game), re-implemented here; no code was taken.
Checklist
Ready for review
main; the title is a Conventional Commit. (one topic; rebased by the coordinator onto67ba729d)mise run testpasses (any failure that also fails onmainis named). (tests/run_all.pythroughsuite.py: 22 failures, all onmaintoo, named)main, or Measurements says why there is nothing to measure. (measured againsta2dc5385; not again on67ba729d)third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Linux 7.0, RTX 4070 Ti (NVIDIA 595.99.02) and AMD Raphael iGPU (RADV, Mesa 26.0.8) at 1280x720: Kokiri Forest, Hyrule Field and the Market. Census (RX_VK_GAME_BARRIER_CENSUS=1) 0 reads/fetches/stores after a fragments-only barrier in all 3 scenes on both GPUs; sync validation in Kokiri Forest and the Market: no new hazard kind; logdiff 0 new problem lines. Timing rounds still running. Runs made on the original branch at main
a2dc5385; this head is the same commits cherry-picked onto current main, compiled, its checks pass, not yet run in the game.@review
@beanstalk
Beanstalk test farm · ❌ failed on windows+nvidia, windows+amd+dgpu, windows+intel and 4 more
Commit
959870a· approved by HumanBean (reviewed) · dashboard⚠️ Note: The census adds PR-only diagnostic overhead, so its frame-time and GPU-time comparisons are not clean performance measurements; use the separate performance scenario for that judgment.
⚠️ Note: Census report availability is unjudged in the performance scenario, where the diagnostic is intentionally off; the census checks reported hazard details but cannot prove all possible synchronization hazards absent.
⚠️ Note: Stationary screenshots can catch picture differences but cannot reliably detect intermittent flicker; the small claimed gains may be indistinguishable from farm noise.
Done (started 2026-11-23 00:02 UTC, last report 2026-11-24 19:33 UTC). Comment
@Beanstalkto run it again.windows+nvidiawindows+amd+dgpuwindows+intellinux+nvidialinux+radvlinux+inteligpuWhy it failed
windows+nvidia:performancescreenshot.max_diff:0.0 → 0.9; limit 0.2windows+nvidia:census · RX_VK_GAME_BARRIER_CENSUS=1 (PR only)market.frametime_1pct_low_ms.max_delta_pct:24.8 → 29.1 (+17.5%); limit 15.0windows+amd+dgpu:performancecrash:2 PR runs crashedwindows+amd+dgpu:census · RX_VK_GAME_BARRIER_CENSUS=1 (PR only)crash:2 PR runs crashedwindows+intel:performancecrash:2 PR runs crashedwindows+intel:census · RX_VK_GAME_BARRIER_CENSUS=1 (PR only)crash:2 PR runs crashedlinux+nvidia:performanceforest.frametime_p99_ms.max_delta_pct:15.8 → 18.6 (+17.8%); limit 15.0linux+nvidia:performanceforest.frametime_1pct_low_ms.max_delta_pct:16.7 → 20.6 (+23.0%); limit 15.0Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
windows+nvidia, report 2:Insufficient frame-time evidence for 1 required comparison(s). See rule results.windows+amd+dgpu, report 2:Insufficient frame-time evidence for 1 required comparison(s). See rule results.windows+intel, report 2:the main base failed (exit 1): Windows doesn't let programs look inside C:\, a folder above the builder's own compiler, so it can't start. Move Longshot's folder out of it (for example to C:\Longshot) and start Longshot from there.linux+nvidia, report 1:Insufficient frame-time evidence for 1 required comparison(s). See rule results.linux+radv, report 1:Insufficient frame-time evidence for 1 required comparison(s). See rule results.What was tested
What will be tested · AI plan (
gpt-6.1-terra)On Windows NVIDIA, AMD discrete and Intel GPUs, and on Linux NVIDIA, RADV, Intel and integrated GPUs, compare the PR with main in Kokiri Forest, Hyrule Field and the Market. Two starts per side measure 30 seconds per scene for performance, and two further starts run the PR's barrier census for 20 seconds per scene. The plan checks frame times, GPU time, stationary pictures, census hazard messages and crashes; a significant regression, picture mismatch, reported hazard or crash fails the PR. The census run enables its diagnostic switch only on the PR, while the performance run uses normal defaults.
1(PR only).kokiri-start(settings frame_rate_cap=6), then teleport to Kokiri Forest, take the picture forest to compare with main, measure forest for 30 s (after 5 s warm-up), teleport to Hyrule Field, take the picture field to compare with main, measure field for 30 s (after 5 s warm-up), teleport to Market, take the picture market to compare with main, measure market for 30 s (after 5 s warm-up); 2 runs on each side.kokiri-start, then teleport to Kokiri Forest, measure forest for 20 s (after 5 s warm-up), teleport to Hyrule Field, measure field for 20 s (after 5 s warm-up), teleport to Market, measure market for 20 s (after 5 s warm-up); 2 runs on each side.Measurements on `windows+nvidia`, for the PR description
Verdict: fail on windows+nvidia (2 reports):
performance screenshot.max_diff;census market.frametime_1pct_low_ms.max_delta_pct (+17.5%)failed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMScene: performance, from the repository's save kokiri-start (frame_rate_cap=6); census, from the repository's save kokiri-start; 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); performance: 2 game starts a side, forest 30 s after 5 s warm-up, field 30 s after 5 s warm-up, market 30 s after 5 s warm-up; census: 2 game starts a side, forest 20 s after 5 s warm-up, field 20 s after 5 s warm-up, market 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67ba729959870aRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forbidden log linesRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· expected log lines missingRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_GAME_BARRIER_CENSUS1As Markdown for the PR description:
Measurements on `windows+amd+dgpu`, for the PR description
Verdict: fail on windows+amd+dgpu (2 reports):
performance crash;census crashfailed.Hardware: 1: windows+amd+amd-proprietary+dgpu
AMD Radeon RX 6600 XT, 2.0.353AMD Ryzen 5 3600 6-Core Processor, 16 GB RAM; 2: windows+amd+amd-proprietary+dgpuAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMScene: performance, from the repository's save kokiri-start (frame_rate_cap=6); census, from the repository's save kokiri-start; 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); performance: 2 game starts a side, forest 30 s after 5 s warm-up, field 30 s after 5 s warm-up, market 30 s after 5 s warm-up; census: 2 game starts a side, forest 20 s after 5 s warm-up, field 20 s after 5 s warm-up, market 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67ba729959870aRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forbidden log linesRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· expected log lines missingRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_GAME_BARRIER_CENSUS1As Markdown for the PR description:
Measurements on `windows+intel`, for the PR description
Verdict: fail on windows+intel (2 reports):
performance crash;census crashfailed.Hardware: 1: windows+intel+intel-proprietary+dgpu
Intel(R) Arc(TM) B580 Graphics, 0.406.98312th Gen Intel(R) Core(TM) i9-12900K, 32 GB RAM; 2: windows+intel+intel-proprietary+dgpuIntel(R) Arc(TM) B580 Graphics, 0.406.983AMD Ryzen 5 9600X 6-Core Processor, 16 GB RAMScene: performance, from the repository's save kokiri-start (frame_rate_cap=6); census, from the repository's save kokiri-start; 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); performance: 2 game starts a side, forest 30 s after 5 s warm-up, field 30 s after 5 s warm-up, market 30 s after 5 s warm-up; census: 2 game starts a side, forest 20 s after 5 s warm-up, field 20 s after 5 s warm-up, market 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67ba729959870aRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forbidden log linesRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· expected log lines missingFlags and settings
RX_VK_GAME_BARRIER_CENSUS1As Markdown for the PR description:
Measurements on `linux+nvidia`, for the PR description
Verdict: fail on linux+nvidia (2 reports):
performance forest.frametime_p99_ms.max_delta_pct (+17.8%);performance forest.frametime_1pct_low_ms.max_delta_pct (+23.0%);census field.frametime_p99_ms.max_delta_pct (+16.7%)failed.Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 5070, 620.73.4AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 3080 Ti, 620.73.4AMD Ryzen 5 5600X 6-Core Processor, 32 GB RAMScene: performance, from the repository's save kokiri-start (frame_rate_cap=6); census, from the repository's save kokiri-start; 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); performance: 2 game starts a side, forest 30 s after 5 s warm-up, field 30 s after 5 s warm-up, market 30 s after 5 s warm-up; census: 2 game starts a side, forest 20 s after 5 s warm-up, field 20 s after 5 s warm-up, market 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67ba729959870aRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forbidden log linesRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· expected log lines missingRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_GAME_BARRIER_CENSUS1As Markdown for the PR description:
Measurements on `linux+radv`, for the PR description
Verdict: fail on linux+radv (2 reports):
performance market.gpu_total_ms.max_delta_pct (+23.9%)failed.Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAMScene: performance, from the repository's save kokiri-start (frame_rate_cap=6); census, from the repository's save kokiri-start; 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); performance: 2 game starts a side, forest 30 s after 5 s warm-up, field 30 s after 5 s warm-up, market 30 s after 5 s warm-up; census: 2 game starts a side, forest 20 s after 5 s warm-up, field 20 s after 5 s warm-up, market 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67ba729959870aRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forbidden log linesRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· expected log lines missingRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_GAME_BARRIER_CENSUS1As Markdown for the PR description:
Measurements on `linux+intel`, for the PR description
Verdict: fail on linux+intel (2 reports):
performance crash;census forest.frametime_1pct_low_ms.max_delta_pct (+17.1%)failed.Hardware: 1: linux+intel+anv+dgpu
Intel(R) Arc(tm) A770 Graphics (DG2), 26.2.713th Gen Intel(R) Core(TM) i5-13600K, 32 GB RAM; 2: linux+intel+anv+dgpuIntel(R) Arc(tm) B580 Graphics (BMG G21), 26.2.4AMD Ryzen 7 9700X 8-Core Processor, 32 GB RAMScene: performance, from the repository's save kokiri-start (frame_rate_cap=6); census, from the repository's save kokiri-start; 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); performance: 2 game starts a side, forest 30 s after 5 s warm-up, field 30 s after 5 s warm-up, market 30 s after 5 s warm-up; census: 2 game starts a side, forest 20 s after 5 s warm-up, field 20 s after 5 s warm-up, market 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67ba729959870aRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forbidden log linesRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· expected log lines missingRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_GAME_BARRIER_CENSUS1As Markdown for the PR description:
Measurements on `igpu`, for the PR description
Verdict: fail on igpu (2 reports):
census market.frametime_p99_ms.max_delta_pct (+29.9%);census market.frametime_1pct_low_ms.max_delta_pct (+53.7%);performance screenshot.max_difffailed.Hardware: 1: linux+amd+radv+igpu
AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99AMD Ryzen Z2 Extreme, 32 GB RAM; 2: linux+amd+radv+igpuAMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAMScene: performance, from the repository's save kokiri-start (frame_rate_cap=6); census, from the repository's save kokiri-start; 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); performance: 2 game starts a side, forest 30 s after 5 s warm-up, field 30 s after 5 s warm-up, market 30 s after 5 s warm-up; census: 2 game starts a side, forest 20 s after 5 s warm-up, field 20 s after 5 s warm-up, market 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)67ba729959870aRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · GPU time a frame (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (p99) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forbidden log linesRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· expected log lines missingRX_VK_GAME_BARRIER_CENSUS=1 (PR only)· field · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· forest · frame time (worst 1%) (ms)RX_VK_GAME_BARRIER_CENSUS=1 (PR only)· market · frame time (worst 1%) (ms)Flags and settings
RX_VK_GAME_BARRIER_CENSUS1As Markdown for the PR description:
The testers' hardware
windows+nvidiaNVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAMwindows+nvidiaNVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMwindows+amd+dgpuAMD Radeon RX 6600 XT, 2.0.353AMD Ryzen 5 3600 6-Core Processor, 16 GB RAMwindows+amd+dgpuAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMwindows+intelIntel(R) Arc(TM) B580 Graphics, 0.406.98312th Gen Intel(R) Core(TM) i9-12900K, 32 GB RAMwindows+intelIntel(R) Arc(TM) B580 Graphics, 0.406.983AMD Ryzen 5 9600X 6-Core Processor, 16 GB RAMlinux+nvidiaNVIDIA GeForce RTX 5070, 620.73.4AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMlinux+nvidiaNVIDIA GeForce RTX 3080 Ti, 620.73.4AMD Ryzen 5 5600X 6-Core Processor, 32 GB RAMlinux+radvAMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAMlinux+radvAMD Radeon RX 580 Series (RADV POLARIS10), 26.2.7AMD Ryzen 5 5500F 6-Core Processor, 32 GB RAMlinux+intelIntel(R) Arc(tm) A770 Graphics (DG2), 26.2.713th Gen Intel(R) Core(TM) i5-13600K, 32 GB RAMlinux+intelIntel(R) Arc(tm) B580 Graphics (BMG G21), 26.2.4AMD Ryzen 7 9700X 8-Core Processor, 32 GB RAMigpuAMD Radeon 890M Graphics (RADV STRIX1), 26.1.99AMD Ryzen Z2 Extreme, 32 GB RAMigpuAMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAMRun by hand on PCs that don't match their target (not counted)
NVIDIA GeForce RTX 5070, 620.73.4)Recommendation: Request changes. The census can report zero while missing dependencies that the new barrier leaves unordered, so its results cannot yet support enabling the change across the game. The claimed performance gain also needs measurement on the current base and head.
The change replaces some full game barriers with fragment-stage barriers to let geometry run sooner, and adds a diagnostic census. Earlier measurements show a small gain in one scene, but the diagnostic has false-negative cases and the current head has not been measured in game.
Blocking (2): must change before merging.
gpu/vk/vk_texture.cpp:3262: The census replaces a texture's earlier write when the same texture becomes a target again, before checking the draw's reads. (more on the line) Do: Retain writes from both sides of the game barrier until a full barrier, and check the draw's reads against the earlier writes before recording its target writes.gpu/vk/vk_texture.cpp:3316: The census does not compare unknown-range global reads with known storage-buffer writes, or known buffer reads with unknown-range global writes. (more on the line) Do: Conservatively count unknown-range reads against prior known writes and unknown-range writes against all later known buffer reads, until a full barrier.Should fix (1): not blocking, but worth doing before merging.
tests/test_game_barrier.py:382: The fixture inherits the barrier-deduplication switch from the environment even though its expected command sequences assume deduplication is enabled. (more on the line) Do: Remove RX_VK_BARRIER_DEDUPE_OFF from the child environment along with the other switches controlled by the fixture.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
67ba729don the current head, including average and 1% low fps and median and p99 frame times in the measured scenes.@fixdoes its part first: Keep the affected barriers full until the corrected census and game runs establish where narrowing is safe.)@fixcan do L1, L2, L3 and L5.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven on this head. Earlier Linux RTX 4070 Ti runs reported 126.7 to 129.1 fps in Hyrule Field and 0.10–0.20 ms lower GPU time across three scenes; the other fps changes were within the reported spread. Those runs compared
a2dc5385with ce5266d2, not this PR's base and head.Other systems: The barrier changes draw synchronization on all Vulkan GPUs and both operating systems, including mesh and fallback paths. The supplied game runs cover Linux NVIDIA and an AMD iGPU in three outdoor scenes; Windows, discrete AMD, Steam Deck, Intel and other game areas remain untested. Dispatches, copies and mesh conversions retain full barriers in the reviewed paths.
Switches: RX_VK_GAME_BARRIER is a default-on kill switch; its default needs the corrected census and broader validation. RX_VK_GAME_BARRIER_CENSUS is a default-off diagnostic switch. Both have switch-table rows.
Reviewed:
959870ac26against67ba729d21: Read the repository's AGENTS.md, CONTRIBUTING.md, PR template and standards, the complete diff and commit messages, and the changed barrier and census paths with their immediate draw callers. Skimmed the test fixture and thread documentation; the large changed renderer files and existing test files were not read in full. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no tests, builds or project scripts were run. The supplied CI checks are still running.
Overlaps and merge order: #2072 is reported to touch the same dispatch and pass-barrier paths; its merge order and conflict resolution need checking. The reported pass-start work also overlaps vk_texture.cpp.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -3148,0 +3259,4 @@}/// The written range [lo, hi) overlaps, if any (the latest such write)const CensusRange* census_overlap(uint64_t lo, uint64_t hi) {const CensusRange* found = nullptr;L1 (blocking): The census replaces a texture's earlier write when the same texture becomes a target again, before checking the draw's reads.
When: A pass writes a texture, a fragments-only game barrier follows, and a later pass binds that texture as a target while a non-fragment stage reads it. begin_pass records the new target write before game_barrier_census_draw checks the read, so the earlier serial is lost and the hazard is counted as a pass-only read instead of a game-barrier read.
Do: Retain writes from both sides of the game barrier until a full barrier, and check the draw's reads against the earlier writes before recording its target writes.
@ -3148,0 +3313,4 @@game ? "a vertex, index or indirect fetch of memory a storage buffer wrote before a fragments-only barrier": "a vertex, index or indirect fetch of memory a storage buffer wrote since the last full barrier",d.prog, nullptr, r->prog, d.fetch[i], d.fetch[i + 1]);}L2 (blocking): The census does not compare unknown-range global reads with known storage-buffer writes, or known buffer reads with unknown-range global writes.
When: If a draw writes a storage buffer before a fragments-only barrier and a later vertex shader reads the same address through global memory, geometry_global_read is true but census_global is false, so the game-barrier count remains zero. The reverse direction is also missed for a later uniform or storage-buffer read.
Do: Conservatively count unknown-range reads against prior known writes and unknown-range writes against all later known buffer reads, until a full barrier.
@ -0,0 +379,4 @@def run(exe, env_extra, mode):env = {k: v for k, v in os.environ.items() if k not in ("RX_VK_GAME_BARRIER", "RX_VK_PASS_BARRIER")}env.update(env_extra)return subprocess.run([str(exe), mode], capture_output=True, text=True, timeout=60, env=env)L3 (should fix): The fixture inherits the barrier-deduplication switch from the environment even though its expected command sequences assume deduplication is enabled.
When: With RX_VK_BARRIER_DEDUPE_OFF=1 in the developer's environment, the extracted full_barrier records extra barriers and the fixture fails despite unchanged correct code.
Do: Remove RX_VK_BARRIER_DEDUPE_OFF from the child environment along with the other switches controlled by the fixture.
Intel Arc B580 on Bazzite: https://beanstalk.magicbean.dev/reports/rp_66c47ed0bd765f53
Closing: the Test Farm failed this on all seven targets (higher 99th-percentile frame times on Linux NVIDIA and RADV, crashes on Windows AMD and Intel, screenshot mismatches), and the gain it claimed did not show. Not worth carrying as it stands. Thanks to everyone who ran it.
Pull request closed