perf(vk): add O(1) generation-guarded dynamic state and vertex-stream bind skips (RX_VK_DRAW_DYN_LEAN) #3046
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
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3046
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/vk-draw-dyn-lean"
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 draw call on the Vulkan replay thread (
mkw_vk_replay) packed and memcmp'd ~250 bytes of dynamic graphics state (dyn_pack()+dyn_same()insidedynamic_state()) and assembled three 16-entry vertex stream arrays (vaddr,vsize,vstride_key) before callingvertex_set_same()and cross-TUgpu_bind_stamp(), even though 87.4% ofdynamic_state()calls reuse the exact same dynamic state and 33.2% of draws reuse the exact same vertex streams without an intervening state change. This PR eliminates that redundant per-draw CPU work behindRX_VK_DRAW_DYN_LEAN(default1,=0legacy,=checkparity,HOS_ABwired), delivering +0.86% FPS (+0.88%frame-avg, 95% CI +0.48% to +1.22%) while cuttingcmds_msby -5.37%,draw_msby -1.89%, and improving1% Low(+0.46 fps) and0.1% Low(+3.24 fps).What this changes:
gpu/vk/draw_dyn_lean.h,gpu/vk/vk_replay.cpp): Adds trivial-POD,constinittl_dyn_state_genandtl_vbuf_state_gencounters bumped on every relevantNvnStatemutation (NOP_VIEWPORTS,NOP_SCISSOR,NOP_DEPTH_RANGE,NOP_BIND_STATEkinds0..5,NOP_STENCIL,NOP_POLY_OFFSET,NOP_BLEND_COLOR,NOP_PRIMITIVE_RESTART,NOP_DEPTH_CLAMP,NOP_RASTER_DISCARD,NOP_BIND_VSTREAM,NOP_BIND_VBUF), cross-queue switches inuse_queue_state(), anddraw_begin_recording().gpu/vk/vk_draw.cpp):{dyn_gen, at_sig, wm_key, topo_key, mesh_key}onDynFast(withtargets_dyn_sig()hashing all 8color_formatslots,width,height,n,depth, anddepth_format, andwm_keycarrying the full 48-bitprogram_wm_sig()plussw()debug bits), allowingdynamic_state()to exit in O(1) when!dump_on()and all keys match. Like main's packed comparison, the skip also needs no pipeline hook by program and the hooks' generation the state was made under (DynFast::hooks_gen, #2822).vbuf_genalongsidestamponVertexSet, skipping vertex-array packing,gpu_bind_stamp(), andvertex_set_same()via inlineg_bind_stamp_fastwhen unchanged.vk_state.h,vk_internal.h,vk_shader.cpp,vk_bank.cpp,vk_api.h,eden/,sirit/,compat/, orthird_party/.gpu/vk/switches.def,tests/test_vk_draw_dyn_lean.py,tests/test_thinlto_tls.py):tests/test_vk_draw_dyn_lean.pycompiles the productiondynamic_state(), vertex-stream block andreplay()state cases and runs modes 0/1/check/HOS_AB against each other;tests/test_thinlto_tls.pycovers the header's thread_locals across translation units. AddsRX_VK_DRAW_DYN_LEAN=checkvalidatingsame_packed,vertex_set_same(), andg_bind_stamp_fast == gpu_bind_stamp()with periodic 100k summaries (0mismatches across13.9M+live checks).Key files to read first:
gpu/vk/draw_dyn_lean.h,gpu/vk/vk_draw.cpp,gpu/vk/vk_replay.cpp,gpu/vk/switches.def, andtests/test_vk_draw_dyn_lean.py.Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 (Vulkan 1.4):
RX_VK_DRAW_DYN_LEAN=check30 s parity run inmarket(2368frames,78.9 fps,1% low 55.7 fps,0crashes):13,900,000+live checks (dyn:7,014,044calls /6,127,828hits =87.4%;vbuf:6,885,956calls /2,284,907hits =33.2%),0mismatches.89paired periods) + 5×90 s (149paired periods,32,456frames) queued in-runHOS_AB=RX_VK_DRAW_DYN_LEAN=0,3,0benchmarks inmarket(1280x720, 50% internal res, V-Sync off, uncappedHOS_FPS_MAX=1000) viadev.py ab.origin/main @ 455b08373at1500288e9, compiled full renderer (longshot-builder dev compile --only renderer:270units /114compiled,0failed,longshot_vk.dll17 MB), and ran stricttests/run_all.py:python -I -X utf8 -B tests/run_all.py --stricttargeted 15-test Vulkan/draw suite withRX_CPMset (test_vk_draw_dyn_lean.py,test_same_dyn.py,test_draw_binds.py,test_push_state.py,test_same_draw.py,test_vertex_bind.py,test_vertex_bind_range.py,test_vk_cmd_fast.py,test_recorder_parts.py,test_inline_write_order.py,test_replay_write_order.py,test_desc_counts.py,test_hos_ab.py,test_tls_objects.py,test_vk_braces.py): 15 passed, 0 failed, 0 skipped.tests/run_all.py --strict --changed origin/main: 242 passed (beforeRX_CPMwas set; remaining failures were missingRX_CPMVulkan/SPIR-V headers, missing MSVClink.exe, or pre-existingorigin/mainfixture staleness unrelated toRX_VK_DRAW_DYN_LEAN, includingtest_switch_table.py[LONGSHOT_LAUNCHER_STARTUP],test_fallback_pipeline_state.py[kPushSize/push_stages/cmd_fast_onfrom#2949],test_flat_map.py,test_compute_warm_apart.py,test_ub_snapshot_gpu_writes.py).python -I -X utf8 tests/test_vk_draw_dyn_lean.py --cxx clang++and--cxx g++(both PASS,5,000-draw parity +14 MUST_FAILmutants caught on each).origin/main @ b4d56f526, head48ff07500): the PR's 19 checks run one by one (test_vk_draw_dyn_lean,test_thinlto_tls,test_tls_objects,test_fallback_pipeline_state,test_hos_ab,test_program_hooks,test_switch_table,test_same_dyn,test_same_draw,test_draw_binds,test_push_state,test_desc_counts,test_vertex_bind,test_vertex_bind_range,test_vk_cmd_fast,test_recorder_parts,test_inline_write_order,test_replay_write_order,test_vk_braces): 19 passed.test_vk_draw_dyn_lean.py: the production code with clang++ and g++, 2×12,000-draw traces identical in all modes, 30 production-text mutants caught. No renderer build and no game run after the rebase.Still to test:
mise run testand renderer build on the rebased head (@Beanstalkrunmise run test, expectingRX_VK_DRAW_DYN_LEANtests green and pre-existing baseline status unchanged).RX_VK_DRAW_DYN_LEAN=checkparity sweep inmarket(@BeanstalkrunRX_VK_DRAW_DYN_LEAN=check, expecting0 mismatchesand no regressions).Measurements
Verdict: faster: +0.86% FPS (
-0.107 msmean frame time, 95% CI+0.48%to+1.22%,149paired periods across 5×90 s in-runHOS_ABsessions;1% Low +0.46 fps,0.1% Low +3.24 fps,cmds_ms -5.37%,draw_ms -1.89%).Setup: Windows 11, NVIDIA GeForce RTX 4060 (Vulkan 1.4); Market, child (crowded) (window
804x581); quality preset Custom, resolution 50% (768x432), output res1280x720, frame generation Off, vsync Off; uncapped (HOS_FPS_MAX=1000); the frame trace (RX_VK_FRAME_TRACE=1), 90 s each after a warm-up until no frame waited for a pipeline, 5 runs,RX_VK_DRAW_DYN_LEANflipped every 3 s within each run (HOS_AB=RX_VK_DRAW_DYN_LEAN=0,3,0);dev.py ab.Baseline: both columns are one build,
v3.2.0-211-gfe3d8427d(measured onmain @ d53dbe94b, then cleanly rebased ontoorigin/main @ 455b08373at1500288e9where#2949is orthogonal todyn_pack/vertex_set_same):RX_VK_DRAW_DYN_LEAN=0(side 1) againstRX_VK_DRAW_DYN_LEANunset /1(side 0) on it.perf.py ab)cmds_msdraw_mswait_gpu_msmain_cpu_msRisks
NvnStatedynamic-state or vertex-stream fields must bumptl_dyn_state_genortl_vbuf_state_gen(validated continuously when runningRX_VK_DRAW_DYN_LEAN=check).RX_VK_DRAW_DYN_LEAN=0reverts to legacydyn_pack/dyn_sameandvertex_set_sameon every draw at runtime, or reverting the commit removes it cleanly.longshot_options.ini, and shader/pipeline caches (LONGSHOT_SHADER_STAMP) are untouched.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.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.Tested in game: Windows 11 RTX 4060: 30s live RX_VK_DRAW_DYN_LEAN=check (13.9M+ checks, 0 mismatches) and 5x90s HOS_AB in market (+0.86% fps, 95% CI +0.48%..+1.22%, cmds_ms -5.37%)
Possibly related, for context:
@review
Recommendation: Request changes. The new cross-translation-unit thread-local variables do not follow the repository’s COFF ThinLTO rule, and the main parity test exercises a copy of the fast-path decisions rather than the production decisions. The reported performance gain also needs confirmation against the base at player settings and on the other affected Tier 1 systems.
The change skips repeated dynamic-state packing and vertex-stream comparisons during Vulkan replay. It adds generation tracking and a diagnostic switch, trading a larger cache-invalidation surface and per-draw key work for a reported small CPU saving.
Blocking (1): must change before merging.
gpu/vk/draw_dyn_lean.h:13: The new namespace-scope inline thread-local variables omit the required constinit qualifier. (more on the line) Do: Mark all four new inline thread-local variables constinit and cover their cross-translation-unit identity in the ThinLTO TLS check.Should fix (2): not blocking, but worth doing before merging.
tests/test_vk_draw_dyn_lean.py:280: The parity harness models the fast-path decisions instead of executing the production decisions it claims to validate. (more on the line) Do: Extract and exercise the actual dynamic-state and vertex-binding decisions from vk_draw.cpp, including their invalidation paths, and demonstrate that undoing the production fast path fails the test.tests/test_vk_draw_dyn_lean.py:982: The baseline harness inherits the MUTANT environment variable. (more on the line) Do: Run the baseline with MUTANT removed from its environment, and set it explicitly only for each mutant run.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2 and L3.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven at player settings. The PR reports +0.86% FPS and -5.37% cmds_ms across 149 paired periods on Windows RTX 4060, but compares switch settings in a pre-rebase PR build at 50% internal resolution and an uncapped frame rate, rather than the merge base and head at the settings players use.
Other systems: The replay path affects Vulkan draws on Windows and Linux, NVIDIA and AMD, including Steam Deck, as well as fallback rendering paths. The supplied live parity and performance evidence covers Windows on one NVIDIA GPU; Linux RADV and other Tier 1 coverage remain outstanding.
Switches: RX_VK_DRAW_DYN_LEAN is added as a kill switch, default on; 0 selects the legacy comparison path and check or 2 enables parity checks. Its row and HOS_AB wiring are present, but the default’s performance has not been measured across affected platforms.
Reviewed:
1500288e9dagainst455b083738: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the commit and production diff, the new header, the changed dynamic-state and vertex-binding sections and replay mutations, and the new test’s harness and driver. Skimmed the remaining changed test sections and surrounding renderer references; did not read the entirety of the large vk_draw.cpp and vk_replay.cpp files. docs/review-checklist.md and ../Tooling/AGENTS.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests, scripts or game runs were executed. The supplied CI checks are still running.
Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -0,0 +10,4 @@// Bumped on every mutation of any NvnState field read by dyn_pack(), on queue state switch,// and at draw_begin_recording(). 0 is reserved as invalid in cached keys.inline thread_local uint64_t tl_dyn_state_gen = 1;L1 (blocking): The new namespace-scope inline thread-local variables omit the required constinit qualifier.
When: These counters and mode are used from both vk_draw.cpp and vk_replay.cpp in the Windows COFF ThinLTO build. The repository explicitly requires constinit on inline thread-local state to keep cross-translation-unit TLS linking safe.
Do: Mark all four new inline thread-local variables constinit and cover their cross-translation-unit identity in the ThinLTO TLS check.
@ -0,0 +277,4 @@}// Model dynamic_state using exact dyn_pack + dyn_same + draw_dyn_lean key logicvoid model_dynamic_state(const NvnState& s, const Targets& at, VkPrimitiveTopology topo, bool mesh, const Program& p) {L2 (should fix): The parity harness models the fast-path decisions instead of executing the production decisions it claims to validate.
When: For example, removing the fast-return body from dynamic_state() leaves the source-wiring needles present and leaves model_dynamic_state() unchanged, so the 5,000-draw and mutant checks can still pass without testing the production optimization.
Do: Extract and exercise the actual dynamic-state and vertex-binding decisions from vk_draw.cpp, including their invalidation paths, and demonstrate that undoing the production fast path fails the test.
@ -0,0 +979,4 @@str(cpp), "-o", str(exe),]subprocess.run(cmd, check=True)subprocess.run([str(exe)], check=True)L3 (should fix): The baseline harness inherits the MUTANT environment variable.
When: When a developer or CI environment already has MUTANT set to one of these names, the supposedly normal run activates that mutant and fails before the intended mutant checks.
Do: Run the baseline with MUTANT removed from its environment, and set it explicitly only for each mutant run.
1500288e9d48ff075008Rebased onto
origin/main @ b4d56f526and pushed48ff07500(the rebased PR commit8b028cd7b, then one commit for L1–L3). The branch merges cleanly into today'sorigin/main(9a1f19b46).Rebase. The conflicts came from #2822 (the mods' pipeline hooks in
dynamic_state()) and from theRX_VK_DMABUF_PIECE_MBrow that leftswitches.def. Both sides are kept. Main's hook conditions are now onereusableterm (gpu/vk/vk_draw.cpp:7389). It means no dump, no pipeline hook by program, and the hooks' generation the state was made under. The O(1) skip (can_skip_dyn, :7399) and the packed comparison (same_packed) both require it.hooks_gensits with the other keys inDynFast(:7147). A hook by shape depends on the target's n, depth, width and height, and all of those are inat_sig.L1 (blocking): done.
gpu/vk/draw_dyn_lean.hare nowconstinit(lines 14, 18, 24, 34).tests/test_thinlto_tls.pynow compiles that header into both of its translation units, natively and with-flto=thin -fuse-ld=lld. It checks:thread_localin that header has noconstinit.L2: done.
tests/test_vk_draw_dyn_lean.pyno longer models the decisions. It cuts the production text and compiles it:vk_draw.cpp:dynamic_state(),dyn_pack(), the switch's mode and check functions,CmdBound, anddraw()'s pipeline bind and vertex-stream block;vk_replay.cpp: the state cases ofreplay(),payload()anduse_queue_state();vk_state.h'sNvnState, anddraw_dyn_lean.hwhole.Only the Vulkan commands, the buffer lookup, the bind stamp and the host are stand-ins. Each Vulkan command is logged with its arguments.
color_format[5]/[7]pastnand a depth format without its texture;=checkfinds 5,591–6,123 dynamic-state hits and 3,857–5,046 vertex-stream hits, with 0 mismatches. Compared with mode 0,=1packs and reads the stamp exactly once less for each of those hits.undo_dyn_fast_pathturns off the O(1) return (your example). It fails over 70 checks, starting with "an identical draw packs no dynamic state".undo_vbuf_fast_pathfails a similar number.targets_dyn_sig), breakbump_dyn/bump_vbuf, or remove the bump from eachreplay()case and fromuse_queue_state(). All 30 are caught.replay()case it doesn't run starts writing a field thatdyn_pack()or the vertex block reads.L3: done. There is no
MUTANTvariable any more: each mutant is a source edit compiled separately. The compiled check runs with everyRX_variable removed from the caller's environment, because the cut code readsRX_VK_DRAW_DYN_LEANandRX_VK_FOOTPRINT*.L4: not done. I haven't measured base against head at player settings. The numbers in the description compare on and off in one older build, at 50% internal resolution with FPS uncapped. This round made no game runs and no renderer build (the PC's GPU is shared). This still needs interleaved base-vs-head runs at normal resolution and Auto quality, in the target area and a heavy one. I've added it to Still to test.
L5: not done. Only Windows on an RTX 4060 has run, both the live
=checkparity run and the A/B. Linux RADV, AMD on Windows and Steam Deck still needRX_VK_DRAW_DYN_LEAN=checkparity sweeps and performance comparisons, from the farm or someone with that hardware. Still to test now says so.Tested (this round, Windows 11, llvm-mingw clang++/g++): I ran the PR's 19 checks one by one through
dev.py queue, each aspython -I -B tests/<check>.pywith itsRUN_ALL_ARGS. All 19 passed:test_vk_draw_dyn_lean,test_thinlto_tls,test_tls_objects,test_fallback_pipeline_state,test_hos_ab,test_program_hooks,test_switch_table,test_same_dyn,test_same_draw,test_draw_binds,test_push_state,test_desc_counts,test_vertex_bind,test_vertex_bind_range,test_vk_cmd_fast,test_recorder_parts,test_inline_write_order,test_replay_write_order,test_vk_braces.tests/run_all.pyitself doesn't start on this PC: its shader step fails to link because MSVClink.exeis missing. That's why the checks ran one by one.@review
@beanstalk
Beanstalk test farm · an earlier run: commit
48ff075(the newer results are in a comment below)Commit
48ff075· approved by HumanBean (reviewed) · dashboard⚠️ Note: The 15% regression limits cannot confirm the claimed 0.86% gain; the farm does not measure the reported replay command and draw timings or run the requested unit-test suite.
⚠️ Note: Check mode reports mismatches but this plan does not require a periodic summary, so a run without a mismatch line alone does not prove that parity checks were exercised.
⚠️ Note: The fixed CPU-oriented settings do not reproduce player-selected Auto quality or the Deck's clock settings.
Done (started 06:39 UTC, last report 23:25 UTC). Comment
@Beanstalkto run it again.nvidiawindows+nvidiaamdwindows+amdlinux+radvintelsteamdeckCouldn'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.
nvidia, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'snvidia, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'swindows+nvidia, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'swindows+nvidia, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'samd, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'samd, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'swindows+amd, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'swindows+amd, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'sWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)The farm will compare main and the PR in Market and Kokiri Forest, with three 30-second samples per place and side at fixed, uncapped CPU-oriented settings. A separate check-mode sweep will look for dynamic-state and vertex-buffer parity mismatches; still-scene pictures will also be compared. Crashes, reported mismatches, excessive picture differences, or frame-time regressions over 15% fail the plan. The Steam Deck target will wait for an online tester. No tester online now matches steamdeck: that target waits for one.
check(PR only).market-entrance(settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0), then teleport to Market, take the picture market to compare with main, measure market for 30 s (after 10 s warm-up), teleport to Kokiri Forest, take the picture forest to compare with main, measure forest for 30 s (after 10 s warm-up); 3 runs on each side.market-entrance(settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0), then teleport to Market, teleport to Kokiri Forest; 1 run on each side.Measurements on `nvidia`, for the PR description
Verdict: could not be judged on nvidia (2 reports).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+window+dlss
NVIDIA GeForce RTX 5090, 621.47.0AMD Ryzen 9 9950X3D 16-Core Processor, 48 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpu+window+dlss+xessNVIDIA GeForce RTX 4090, 621.40.013th Gen Intel(R) Core(TM) i7-13700K, 32 GB RAMScene: replay-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); parity-sweep, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); replay-performance: 3 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; parity-sweep: 1 game start a side; 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)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DRAW_DYN_LEANcheckAs Markdown for the PR description:
Measurements on `windows+nvidia`, for the PR description
Verdict: could not be judged on windows+nvidia (2 reports).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+window
NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.1.0AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpu+window+dlssNVIDIA GeForce RTX 5090, 621.47.0AMD Ryzen 9 9950X3D 16-Core Processor, 48 GB RAMScene: replay-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); parity-sweep, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); replay-performance: 3 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; parity-sweep: 1 game start a side; 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)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DRAW_DYN_LEANcheckAs Markdown for the PR description:
Measurements on `amd`, for the PR description
Verdict: could not be judged on amd (2 reports).
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 9070 (RADV GFX1201), 26.3.1AMD Ryzen 5 7600X3D 6-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMScene: replay-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); parity-sweep, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); replay-performance: 3 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; parity-sweep: 1 game start a side; 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)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DRAW_DYN_LEANcheckAs Markdown for the PR description:
Measurements on `windows+amd`, for the PR description
Verdict: could not be judged on windows+amd (2 reports).
Hardware: 1: windows+amd+amd-proprietary+dgpu+window+fsr4
AMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 9 7950X 16-Core Processor, 128 GB RAM; 2: windows+amd+amd-proprietary+igpu+window+xessAMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAMScene: replay-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); parity-sweep, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); replay-performance: 3 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; parity-sweep: 1 game start a side; 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)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DRAW_DYN_LEANcheckAs Markdown for the PR description:
Measurements on `linux+radv`, for the PR description
Verdict: could not be judged on linux+radv (2 reports).
Hardware: 1: linux+amd+radv+igpu
AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 9070 (RADV GFX1201), 26.3.1AMD Ryzen 5 7600X3D 6-Core Processor, 32 GB RAMScene: replay-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); parity-sweep, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); replay-performance: 3 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; parity-sweep: 1 game start a side; 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)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DRAW_DYN_LEANcheckAs Markdown for the PR description:
Measurements on `intel`, for the PR description
Verdict: could not be judged on intel (2 reports).
Hardware: 1: windows+intel+intel-proprietary+igpu+window
Intel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM; 2: linux+intel+anv+igpuIntel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAMScene: replay-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); parity-sweep, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); replay-performance: 3 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; parity-sweep: 1 game start a side; 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)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DRAW_DYN_LEANcheckAs Markdown for the PR description:
Measurements on `steamdeck`, for the PR description
Verdict: could not be judged on steamdeck (2 reports).
Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAM; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMScene: replay-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); parity-sweep, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); replay-performance: 3 game starts a side, market 30 s after 10 s warm-up, forest 30 s after 10 s warm-up; parity-sweep: 1 game start a side; 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)Nothing was measured: no metric came back.
Flags and settings
RX_VK_DRAW_DYN_LEANcheckAs Markdown for the PR description:
The testers' hardware
nvidiaNVIDIA GeForce RTX 5090, 621.47.0AMD Ryzen 9 9950X3D 16-Core Processor, 48 GB RAMnvidiaNVIDIA GeForce RTX 4090, 621.40.013th Gen Intel(R) Core(TM) i7-13700K, 32 GB RAMwindows+nvidiaNVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.1.0AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAMwindows+nvidiaNVIDIA GeForce RTX 5090, 621.47.0AMD Ryzen 9 9950X3D 16-Core Processor, 48 GB RAMamdAMD Radeon RX 9070 (RADV GFX1201), 26.3.1AMD Ryzen 5 7600X3D 6-Core Processor, 32 GB RAMamdAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMwindows+amdAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 9 7950X 16-Core Processor, 128 GB RAMwindows+amdAMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAMlinux+radvAMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAMlinux+radvAMD Radeon RX 9070 (RADV GFX1201), 26.3.1AMD Ryzen 5 7600X3D 6-Core Processor, 32 GB RAMintelIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMintelIntel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMRecommendation: Approve. The code is ready: only testing is left. The code and test fixes address the first three ledger items, but the performance gain against the merge base and coverage on other affected Tier 1 systems remain unverified. CI is still running. Recommend approval; not approved on the forge.
The change skips redundant Vulkan dynamic-state and vertex-stream work on repeated draws. It adds generation tracking, cache keys and parity checks; its player-setting performance benefit remains unproven.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
1500288e9d)Resolved: L1 (The new namespace-scope inline thread-local variables omit the required constinit qualifie…); L2 (The parity harness models the fast-path decisions instead of executing the production deci…); L3 (The baseline harness inherits the MUTANT environment variable.)
Still open: L4 (The claimed gain has not been measured against the merge base at settings representative o…); L5 (The enabled-by-default replay change still needs coverage on the other affected Tier 1 sys…)
Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: the reported 0.86% FPS gain and 0.48%–1.22% confidence interval come from on/off measurements in one older build at 50% internal resolution, not merge base versus this head at representative player settings.
Other systems: The replay path affects Vulkan rendering across Windows and Linux, GPU vendors and Steam Deck. The reported live parity run covers Windows on an RTX 4060; Linux RADV, AMD Windows and Steam Deck runs remain outstanding.
Switches: RX_VK_DRAW_DYN_LEAN is added as a developer kill switch, default on; 0 selects the legacy comparisons and check validates fast-path parity. The default's performance benefit across player settings and affected systems remains unverified.
Reviewed:
48ff075008againstb4d56f5264: Read the repository rules, contribution guide, PR template, generation header, TLS test and relevant production diff; inspected the parity harness and related test and switch changes. The full large renderer files and parity harness were not read in full. The review checklist and neighboring Tooling AGENTS.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports 19 checks passing on the rebased head, but no renderer build or game run after the rebase; CI is still running. The maintainer's Test Farm request could not be carried out under the read-only and closed-network constraints.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
AMD Lab Market A/B: PR head
48ff07500851merged ontomainee9e1ed76, usingRX_VK_DRAW_DYN_LEAN=0(A) andRX_VK_DRAW_DYN_LEAN=1(B) on the same build.Within the run-to-run spread. Median average FPS changed by -0.89%.
0)1)Market (child), headless Linux 7.3.3-1-cachyos, Core i7-9700K, Radeon RX 580 with Mesa RADV 3:26.2.6-1, 1280x720 output at 33% render scale, uncapped with V-Sync and frame generation off. Three alternating pairs, 60 seconds per capture after warm-up, each a timing job of the queue.
No difference on this PC beyond run-to-run noise, in fps or in the CPU thread's time (median 9.39 ms off, 9.32 ms on). The RX 580 lab can't be made cleanly CPU-bound, so the CPU thread row is the one to read for this change.
48ff075008823a6107f1Beanstalk test farm
Commit
823a610· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Rebased onto current main: head
823a6107on base7bc53f84(was48ff0750onb4d56f52). Mergeable again.Rebase. The conflicts were with #3048 (
RX_VK_DRAW_OVERHEAD_LEAN), which landed in the same places:gpu/vk/switches.def,tests/test_hos_ab.py, the includes anddraw_begin_recording()ingpu/vk/vk_draw.cpp: both sides kept (both switches, both*_begin_recording()calls).draw()'s vertex-stream block: this PR's generation-guarded skip around main's slow path, with main'slean_bind_stamp()kept wherever main had it (thevstamp,vb_stamp,kept_vband final stamp reads), soRX_VK_DRAW_OVERHEAD_LEANstill decides how the slow path reads the stamp. One consequence: withRX_VK_DRAW_OVERHEAD_LEANon,lean_bind_stamp()returnsg_bind_stamp_fast, so this PR's check mode compares the fast stamp with itself there; the fast stamp againstgpu_bind_stamp()is then checked byRX_VK_DRAW_OVERHEAD_LEAN=check. With it at 0, this PR's check compares the two as before.tests/test_vk_draw_dyn_lean.py: the production-skips harness got alean_bind_stamp()stub (the=0form,gpu_bind_stamp()itself), the same astests/test_fallback_pipeline_state.pyhas on main. Folded into the second commit.Checks run (Windows 11, llvm-mingw clang++, through the PC's job queue):
python -I -B tests/run_all.py --exact tests/test_vk_draw_dyn_lean.py tests/test_fallback_pipeline_state.py tests/test_hos_ab.py tests/test_thinlto_tls.py tests/test_draw_binds.py tests/test_vk_draw_overhead_lean.py tests/test_switch_table.py tests/test_tls_objects.py tests/test_switches_removed.py: 8 passed;test_vk_draw_dyn_lean.pyfailed to compile its production harness (nolean_bind_stampin it), fixed as above.python -I -B tests/run_all.py --exact tests/test_vk_draw_dyn_lean.pyafter the fix: passed (the parity harness, its randomized trace and the must-fail mutants).HumanBean's AMD Lab A/B (RX 580, Linux RADV, Market,
48ff0750onee9e1ed7, switch 0 against 1 on one build): within the run-to-run spread. Median average fps -0.89% (60.64 → 60.10), 1% low 51.18 → 51.56, p99 frame time 19.54 → 19.40 ms. The renderer's CPU thread median 9.39 ms off → 9.32 ms on (each capture 9.34 / 9.62 / 9.39 against 9.32 / 9.41 / 9.32). No measurable difference on that PC; as you note it is GPU-limited (12.2 ms GPU time), so it can't show the CPU-side gain either way. Thank you for running it.L4 (base against head at player settings, average and 1% low) and L5 (game and check-mode parity sweeps on the other Tier 1 systems: Linux, RADV, Steam Deck): still open. I have only the one Windows RTX 4060 PC, so these need the farm or someone with that hardware. The AMD Lab run above is the only non-NVIDIA data so far, and it compares the switch on one build, not base against head.
Beanstalk: the 2026-12-04 run couldn't be judged on any target; every report stopped at main's
tools.lockSDL URLs before measuring, so it says nothing about this PR either way. A re-run on the rebased head needs a BigBeans member to start it.AMD lab A/B/A/B, GPU-bound:
main7bc53f841(A) against this PR's head823a6107merged onto it (B), two builds, the switch at its default. AMD lab PC: Linux 7.3.3-1-cachyos, Core i7-9700K, 15 GB RAM, Radeon RX 580 with Mesa RADV 3:26.2.6-1. Standing in the Market (child), 100 % render scale, headless, uncapped, V-Sync and frame generation off, 90 s per run after a 15 s warm-up, each a timing job in the queue.No measurable difference when the GPU is the limit.
3840x2160, GPU-bound (card 95-96 % busy, about 38 ms of GPU time in a 41 ms frame):
draw_ms, meancmds_ms, mean1920x1080, not fully GPU-bound (about 15.5 ms of GPU time in a 19.5 ms frame):
draw_ms, meancmds_ms, mean48ff0750, switch 0 against 1) showed -0.9 %. Too small to call a regression from these runs, and not a gain either.cmds_mswas lower on B in all four pairs, by 0.03-0.10 ms, in the direction the description measured. With the GPU or the frame's pacing as the limit it doesn't become fps.Not covered: heavier areas, a player's Auto settings, a CPU-bound case, check mode, Steam Deck. Two runs per side, one view.
Recommendation: Wait (on a base-against-head measurement of the current head at player settings, and one game run of this head). The code looks correct and I found nothing to change, but the gain is small and measured only as on/off inside an older build. The current head (two rebases later, including #2822's hooks in this same function) has had no renderer build and no game run.
For a player: less CPU work on the Vulkan replay thread for each draw. A draw whose dynamic state and vertex streams have not changed skips the packing and memcmp and the stream-array build. It records the same Vulkan commands, so nothing on screen should change. It makes the code a little more complex: every new writer of these
NvnStatefields must bump a generation.Does it help: Unproven against
main. The +0.86% fps (95% CI +0.48% to +1.22%, 149 periods,cmds_ms-5.37%) comparesRX_VK_DRAW_DYN_LEAN=0with=1in one build (fe3d8427d, before the #2822 merge), on one RTX 4060, at 50% internal and uncapped. Its=0side is notmain.dynamic_state()buildsat_sig(fivemix64rounds),wm_key,sw_sigand the key compares before it tests the mode (gpu/vk/vk_draw.cpp:7607-7617), and stores the keys after. So=0pays a per-draw costmaindoesn't, and the on/off delta overstates the gain overmain. With about 3,000dynamic_state()calls a frame, that cost could be a sizeable part of the CI's lower bound. The author's L4 (merge base against this head, interleaved, at player resolution and Auto quality, in Market and a heavy area) is still owed and decides this.Other systems: CPU-only. When the keys are right, the command stream is identical on every vendor, OS and driver, so correctness can't differ by GPU. Only the size of the gain can, probably larger on the Deck's CPU. The farm run at
48ff075couldn't be judged on any target (main'stools.lockSDL URLs, an infrastructure failure, not this PR). A=checksweep on another machine is still wanted but is not a blocker.Switches:
RX_VK_DRAW_DYN_LEAN, kill, default on (1),=0legacy,=checkparity, wired intoHOS_ABand read at each recording's start. On is the right default for a CPU-side skip that records identical commands. Remove it (GONE) once settled.Reviewed:
823a6107fagainst7bc53f841. Read in full where changed:gpu/vk/draw_dyn_lean.h, theswitches.defrow, everyvk_draw.cppandvk_replay.cpphunk. Also read the code they rely on:dyn_pack, the whole ofdynamic_state(no early return between the pack and the key store),CmdBound::reset*,draw_state_disturbed,lean_bind_stamp,program_wm_sig,use_queue_state,NOP_BIND_STATE, every caller ofdraw/dynamic_stateand everyNvnStatefield write ingpu/vk. Skimmed: the four test files. Nothing run.Fixed in this review: nothing.
Checked and fine:
dyn_pack()reads fromNvnStateis written only inreplay()cases that now bump (BIND_STATEkinds 0-5 cover blend, color, chmask, ms, poly and ds). The vertex block'svbuf/vstreamare bumped too. The otherNvnStatewrites ingpu/vk(vk_draw.cpp:3365-3375,vk_shader.cpp) are local states for pipeline builds that never reachdynamic_state(). The batchdraw(cmd, s, batch)reuses the sames.*cur_state) and a recording start bump both generations.reset_keeping_index,reset(pre-bloom, stand-ins,draw_state_disturbed) and the fallback-pipeline drop clear the keys.program_wm_siguses bits 0-47, sosw_sig << 48can't alias it.dump_on()and program hooks still block reuse throughreusable, and shape hooks stay covered byhooks_genplusat_sig.at_sigis a 64-bit hash compared only with the previous draw's: a collision is negligible.constinitand trivial, and the ThinLTO test covers them.Blocking
None in the code.
Suggestions
gpu/vk/vk_draw.cpp:11996: the vertex skip compares the stored stamp withg_bind_stamp_fastdirectly. WithRX_VK_DRAW_OVERHEAD_LEAN=0(that kill switch's "usegpu_bind_stamp()" mode,lean_bind_stamp, :5008), this PR quietly brings back the dependence on the cached stamp. That kill switch should still remove it. Adddraw_overhead_lean_mode != 0tocan_skip_vbuf, or takefast_stampfromlean_bind_stamp()in that mode.main, computeat_sig/wm_keyonly whentl_mode != 0. The base-against-head run settles the question either way.48ff075. Add a line for823a6107f(what ran on it), and a short=checkrun in game on this head, since #2822'sreusableterm is new since the measured build.Testing: in game on Windows 11 with an RTX 4060, at fe3d8427d only: a 30 s
=checkrun (13.9M checks, 0 mismatches) and the 5×90 s on/off A/B. At48ff075: the PR's 19 checks one by one (notrun_all.pyormise run test; CI not run). Missing: base against head at player settings (holds the merge), any build or run of823a6107f, and a judged farm run.Overlaps and merge order: #2958 (
RX_VK_DRAW_SELF_FAST), #2959 (RX_VK_PIPE_VB_FAST, sparse vertex binding), #2981 (RX_VK_REPLAY_FAST, replay dispatch) and #2954 are the same author's per-draw fast paths invk_draw.cpp'sdraw()/vertex block andreplay(), and #2959 and #2981 are not mergeable now. Merge this first (it is mergeable and the smallest), then rebase those onto it, each re-measured against the newmain. #3080 (neutral names, WIP) and #3116 (renderer split, WIP) will touch the same lines; they go after.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.