perf(vk): a draw rebuilds only the descriptors whose sources changed (RX_VK_DESC_SPLIT) #1851
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1851
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:perf/draw-cost"
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
The render thread spends most of each frame translating the game's state into Vulkan, draw by draw. In Castle Town Market (~2,500 draws a frame) that is ~11 ms a frame on an RX 7900 XTX, and building and pushing each draw's descriptors is ~3.4 ms of it. This PR takes the first, safe step, on every GPU:
RX_VK_PROF_FINE=1only): new counters split the builds by cause. In the Market on an RX 580: another program or command buffer 0.53 a draw, a stage's textures moved 0.26, only the uniform buffers changed 0.14, storage buffers moved 0.02.RX_VK_DESC_SPLIT, on;=0the old way;=2builds both ways and counts differences). With the same program and command buffer and only the uniform buffers changed, the uniform buffer writes are rebuilt in place and only they are pushed; textures and storage buffers are kept under strict conditions (handles from c2/c1 only, no tables, no texel buffers, no written images, unchanged generations and stamps). Intel Arc's push-every-uniform-buffer rule is kept.Bindless textures, which take on the 0.53 + 0.26 builds a draw that switch programs or textures, follow in their own pull request. Builds on dyst's #794 (kept descriptors per stage); see also #1763.
Read first:
desc_split_keeps,build_uniform_buffersand the split indraw()(gpu/vk/vk_draw.cpp).Testing
Tested: Linux, RX 580 (RADV), i7-9700K, 1080p: Kokiri Forest and Castle Town Market, standing and turning, with the split on and off; one Market session with
RX_VK_DESC_SPLIT=2: hundreds of thousands of draws' kept textures and storage buffers compared with a whole build, 0 differed; no Vulkan errors. Renderer builds on Linux; Windows syntax check of the changed files with llvm-mingw.Still to test:
mise run test, the newtest_desc_split.pyand the fixtures it touched, expecting them to pass (by hand: CI on this pull request)Measurements
Verdict: correct (0 differences in the check) and even to slightly better on a GPU-bound RX 580, within noise; its gain is limited by design: 0.14 of ~0.95 builds a draw in the Market are uniform-buffer-only, an estimated 0.3-0.4 ms a frame where building descriptors is ~2.8 ms (RX 7900 XTX).
RX_VK_DESC_SPLITships on: it is never slower here and its check found no difference. The diagnostics the diff names (RX_VK_TRACE_TEX,RX_VK_LOG_IMG,RX_VK_WATCH_PROG,RX_VK_DRAW_STATS,RX_VK_PEEK_PROG,RX_VK_LOG_TABLE,RX_VK_SLOW_DESC,RX_VK_ASYNC_IMPORT) are existing switches, unchanged and off by default; the split only turns itself off under them.Baseline: this PR's own build with
RX_VK_DESC_SPLIT=0, which builds every descriptor as main does, so the two runs differ only by the split; the Test Farm compares against main itself.Setup: Linux, RX 580 (RADV), i7-9700K, 1080p; two interleaved runs each, this PR's build with
RX_VK_DESC_SPLIT=0(as main) against its default.de65a6b4withRX_VK_DESC_SPLIT=0de65a6b4Risks
A kept descriptor that should have been rebuilt would show a wrong texture or buffer: the keep rules are strict and
RX_VK_DESC_SPLIT=2checks them;RX_VK_DESC_SPLIT=0turns it off. Kept storage buffers skip the bind's pool heat count, which may slightly change which pools get mirrors. Nothing changes for the player's files.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.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e3aEPBsd7QfUkaatjP
Tested in game: Linux, RX 580 (RADV 25.x), i7-9700K, 1080p: Kokiri Forest and Castle Town Market standing and turning, split on and off, two runs each; one Market session with RX_VK_DESC_SPLIT=2 compared kept descriptors with whole builds over 100,000+ draws, 0 differed; no Vulkan errors.
c10a1c2a6ade65a6b467WIP: perf(vk): cheaper draws: descriptors rebuilt only where their sources changed, then bindless texturesto WIP: perf(vk): a draw rebuilds only the descriptors whose sources changed (RX_VK_DESC_SPLIT)@Beanstalk Please test this PR against main on every platform: windows+amd, windows+nvidia, windows+intel, linux+amd, linux+nvidia, linux+intel, the steamdeck, amd+igpu. Settings vsync=2 (Off) and frame_rate_cap=6 (Uncapped), Threaded rendering Auto. From the
kokiri-startsave: Kokiri Forest, Hyrule Field and Castle Town Market, in each 20 s standing then 15 s turning the camera, two game starts a side; make sure each side has reached the area before measuring it. Measure fps, p99 frame time, stutters and crashes, and compare pictures with main (the change must draw exactly as main does; Intel Arc especially, which has a rule about pushing uniform buffers this change keeps).Beanstalk test farm · an earlier run: commit
de65a6b(the newer results are in a comment below)Commit
de65a6b· tier reviewed · approved by HumanBean · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)Against main, two starts per side visit Kokiri Forest, Hyrule Field and Market from the Kokiri save, with V-Sync off and the frame rate uncapped. Each area has a 20-second standing measurement, a frame-counted camera turn and a picture comparison; turning frames contribute to run-wide hitch counts rather than a separate FPS measurement. Crashes, any picture difference, or regressions beyond the FPS, p99, stutter and hitch limits fail the plan. Each tester run takes roughly 25 minutes; the Windows and Linux Intel targets will wait for matching testers. Threaded rendering remains at its default because the farm exposes no setting for it. No tester online now matches windows+intel, linux+intel: those targets wait for one.
kokiri-start(settings vsync=2, frame_rate_cap=6), then teleport to Kokiri Forest, measure kokiri-standing for 20 s (after 5 s warm-up), take the picture kokiri to compare with main, move the stick, teleport to Hyrule Field, measure field-standing for 20 s (after 5 s warm-up), take the picture field to compare with main, teleport to Market, measure market-standing for 20 s (after 5 s warm-up), take the picture market to compare with main; 2 runs on each side.Started at 07:19 UTC.
âš No tester has a PC for
linux+intel(none seen in 14 days): it waits until one signs in.AMD Radeon RX 9060 XT, 2.0.416; 2: windows+amd+amd-proprietary+dgpuAMD Radeon RX 9070 XT, 2.0.416NVIDIA GeForce RTX 3080 Ti, 621.24.0; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0AMD Radeon 780M Graphics (RADV PHOENIX), 26.1.99; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99NVIDIA GeForce GTX 1070, 580.196.7; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 5070, 620.70.6AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Radeon 780M Graphics (RADV PHOENIX), 26.1.99; 2: linux+amd+radv+igpuAMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8Measurements · windows+amd
Verdict: fail on windows+amd (2/1 report):
three-areas field-standing.fps_mean.min_delta_pct (-32.6%);three-areas screenshot.max_diff;three-areas kokiri-standing.stutter_count.max_delta_pct (+300.0%)failed.Hardware: 1: windows+amd+amd-proprietary+dgpu
AMD Radeon RX 9060 XT, 2.0.416AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM; 2: windows+amd+amd-proprietary+dgpuAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMScene: three-areas, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6); 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); three-areas: 2 game starts a side, kokiri-standing 20 s after 5 s warm-up, field-standing 20 s after 5 s warm-up, market-standing 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)a3565acde65a6bFlags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
Measurements · windows+nvidia
Verdict: fail on windows+nvidia (2/1 report):
three-areas market-standing.stutter_count.max_delta_pctfailed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 3080 Ti, 621.24.0AMD Ryzen 9 5900X 12-Core Processor, 64 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAMScene: three-areas, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6); 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); three-areas: 2 game starts a side, kokiri-standing 20 s after 5 s warm-up, field-standing 20 s after 5 s warm-up, market-standing 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)a3565acde65a6bFlags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
Measurements · linux+amd
Verdict: fail on linux+amd (2/1 report):
three-areas screenshot.max_difffailed.Hardware: 1: linux+amd+radv+igpu
AMD Radeon 780M Graphics (RADV PHOENIX), 26.1.99AMD Ryzen 7 7840HS w/ Radeon 780M Graphics, 24 GB RAM; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMScene: three-areas, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6); 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); three-areas: 2 game starts a side, kokiri-standing 20 s after 5 s warm-up, field-standing 20 s after 5 s warm-up, market-standing 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)a3565acde65a6bFlags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
Measurements · linux+nvidia
Verdict: fail on linux+nvidia (2/1 report):
three-areas screenshot.max_diff;three-areas kokiri-standing.stutter_count.max_delta_pct (+100.0%);three-areas kokiri-standing.fps_mean.min_delta_pct (-32.7%)failed.Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce GTX 1070, 580.196.7Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, 32 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 5070, 620.70.6AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMScene: three-areas, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6); 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); three-areas: 2 game starts a side, kokiri-standing 20 s after 5 s warm-up, field-standing 20 s after 5 s warm-up, market-standing 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)a3565acde65a6bFlags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
Measurements · steamdeck
Verdict: fail on steamdeck (2/1 report):
three-areas screenshot.max_diff;three-areas market-standing.stutter_count.max_delta_pct (+200.0%);three-areas market-standing.frametime_p99_ms.max_delta_pct (+30.9%)failed.Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAM; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMScene: three-areas, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6); 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); three-areas: 2 game starts a side, kokiri-standing 20 s after 5 s warm-up, field-standing 20 s after 5 s warm-up, market-standing 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)a3565acde65a6bFlags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
Measurements · amd+igpu
Verdict: fail on amd+igpu (2/1 report):
three-areas screenshot.max_difffailed.Hardware: 1: linux+amd+radv+igpu
AMD Radeon 780M Graphics (RADV PHOENIX), 26.1.99AMD Ryzen 7 7840HS w/ Radeon 780M Graphics, 24 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: three-areas, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6); 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); three-areas: 2 game starts a side, kokiri-standing 20 s after 5 s warm-up, field-standing 20 s after 5 s warm-up, market-standing 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)a3565acde65a6bFlags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
WIP: perf(vk): a draw rebuilds only the descriptors whose sources changed (RX_VK_DESC_SPLIT)to perf(vk): a draw rebuilds only the descriptors whose sources changed (RX_VK_DESC_SPLIT)de65a6b46715b16be2a9Beanstalk test farm
Commit
15b16be· tier untrusted · approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Closing: the split is correct (
RX_VK_DESC_SPLIT=2compared kept textures and storage buffers with whole builds over 2.74 million draws on an RX 580 with 0 differences), but it gains nothing measurable. The Test Farm was even on 8 GPUs (within about 2%; the two large Hyrule Field drops compared runs that hadn't reached the same place), and on an RTX 3090 the frame's critical path in the Market is no longer the render thread, so cheaper descriptor builds don't move fps. Not worth a second descriptor path and a switch to maintain. Its counters (why a draw rebuilt its descriptors) were the useful part: they showed bindless textures and a texture memo wouldn't pay either. The branch stays on HumanBean/Longshot as perf/draw-cost.Closing: correct but no measurable gain; reasons in the comment above.
Pull request closed