WIP: perf(vk): a recording's uniform copies shared, their reads made once a draw: Castle Town's market from 54.9 to 59.5 fps on a B580 with the uniform snapshot #952
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!952
Loading…
Reference in a new issue
No description provided.
Delete branch "nyannoying/Longshot:perf/vk-ub-reads-once"
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?
Type: perf · Risk: medium · Tested on: Windows 11, Arc B580 (the snapshot on, as #446 has it) · Needs: an Intel iGPU, any OS (the snapshot is on there by default); a Linux build
Why
On Intel GPUs the renderer copies every uniform buffer a draw binds into its own stream instead of binding the game's
memory: the uniform snapshot (
RX_VK_UB_SNAPSHOT). Without it Intel's iGPUs drew objects with other objects' matricesand painted sky over Kokiri Forest's ground; #446 turns it on for the Arc cards too. Each copy was read from the game's
memory on its own, most of them under a lock. In Castle Town's market an Arc B580 made about 10,400 copies a frame, 19 MB, of only
4,200 distinct ranges, 2.4 MB, and building the draws' descriptors took 6.1 ms of every frame on the render
thread, in a place that already waits on the CPU. With this PR a recording copies each range once and a draw reads its
copies together: the descriptors take 2.6 ms, and the market runs at 59.5 fps instead of 54.9.
What changed
A draw that binds a uniform range (address and size) an earlier draw of the same recording copied, with the same
captures in view, is given that copy instead of making its own. The copies a draw still makes are read from the game's
memory together once its descriptors are built, the memory lock taken once instead of once a copy. Within a recording
a range's contents were the same in every copy of it:
RX_VK_UB_SNAP_DEDUP=2, which makes every copy all the same andcompares it with the shared one, compared 40 million in the market, Kokiri Forest and Hyrule Field and found none
different. Only the snapshot's copies change: without the snapshot none of this runs.
gpu/vk/vk_draw.cpp:uniform_range(): the sharing.ub_snapsis a thread's table of its recording's copies by address and size (4,096slots, 16 probes,
ub_snap_slot());RecordingRes::ub_snap_epoch, a recording's number set indraw_begin_recording(), keeps another recording's copies from being given out, andmemory_capture_view()a copymade with other captures in view.
ub_snap_dedup_mode()isRX_VK_UB_SNAP_DEDUP;ub_snap_check()andub_snap_count()are its check and its log line.build_descriptors(): the batched reads.uniform_range()queues a copy's read (ub_reads_pending) andUbReadsScopemakes them all when the build is over, however it ends (ub_reads_flush()).ub_read_batch_mode()isRX_VK_UB_READ_BATCH.bind_descriptors(): with the copies shared, every uniform buffer write is pushed each draw, as every one wasbefore (each draw had copies of its own, so each had changed); textures and storage buffers are still pushed only
when changed. Left out as unchanged, the B580 drew objects with other objects' matrices: a push that carries some of a
draw's uniform buffer writes and leaves others out reads wrong data there, as with the snapshot off (measured: adding
the ones left out to such a push puts it right, adding them to other pushes does not; comment of 16 November).
ub_snapshot_wanted(), whichbind_descriptors()asks too; this PR has no default ofits own.
gpu/vk/vk_memory.cpp,gpu/vk/vk_internal.h:memory_read_as_submitted_many()(SubmittedRead): many reads asmemory_read_as_submitted()makes one,pools_mutaken once for those that need the captures. The one read issplit into the part without the lock and the part with it (
submitted_read_unlocked(),submitted_read_locked()),which both use. #977's late pages' hook (
late_defer_cpu_read(),RX_VK_LATE_DEFER, where the pools have no mirror)is in
submitted_read_locked(), so the reads made together take a late page's copy again before reading it, as oneread does.
tests/test_submitted_page.py: the split read: both reads ask the per-page cache before the pool lock, withouttaking it, and copy the captures' pages under it; the answer is kept only for a page in no capture, as before.
tests/sampler_admission_test.cpp: the two helpersbind_descriptors()now asks (no snapshot there).tests/test_late_defer.py: its text check finds #977's hook insubmitted_read_locked(), and both reads goingthrough it.
docs/development.md: the two switches, with the numbers and the read check's cost;docs/tested/: the 6 runs, and the 7 of the A/B with #446 (16 November).Measurements
Verdict: faster on the Arc B580 with the snapshot on, in the market: 54.9 → 59.5 fps average (+8.4%), 1% low 37.1 → 39.8 fps, median frame time 17.45 → 16.48 ms; the replay's descriptors 6.12 → 2.64 ms a frame, the GPU time the same (12.1 ms). The picture is the same: no flash either way, and the check modes found no copy different.
Baseline:
RX_VK_UB_SNAP_DEDUP=0 RX_VK_UB_READ_BATCH=0on the same build: every binding gets a copy of its own andeach copy is read on its own, exactly as on
main(none of the sharing or the batching runs, and every uniform writeis pushed when changed, as before). Both columns are one build: 690d8446, this PC's game folder (
mainat2b1d38c6with my open #443, #446, #459 and #500 merged), with #761's change (now on
main) and this PR's diff applied:main'srenderer (
MKWVK_API_VERSION23) doesn't load in that folder's host (22), and a new folder formainmeans preparingthe 38,809 shaders again. #446 is what turns the snapshot on for the B580 there; on
mainthe B580 needsRX_VK_UB_SNAPSHOT=1for this PR to do anything. The runs' build had the recordings' counter (ub_snap_epochs) as aglobal; this PR's head has it inside
draw_begin_recording(), the same counter, for the checks that compile thatfunction.
Hardware: Windows 11 Pro Insider 10.0.29704, Intel Arc B580 12 GB (driver 32.0.101.9154), Core i5-13600K, 64 GB
Scene: Castle Town's market as child Link by day, standing at the entrance (the control bridge's
teleport Market_Child); 1280x720 window, render 75% upscaled with Intel XeSS 2.0.2 (Ultra Quality: 960x540 → 1280x720, #459), frame generation off, V-Sync Auto,HOS_FPS_MAX=240(notcapped)
Method: 3 interleaved pairs, each from a fresh start (on, off, off, on, on, off): 40 s after the teleport, then 40 s
measured. fps and frame times from
RX_VK_FRAME_LOG(every present of the 40 s; the 1% low is the rate of the slowest1% of frames); the render thread's time and the replay's descriptors from
HOS_PROFILE=5; GPU time from the log'sGPU timeline. Each cell is the median of the arm's 3 runs, the runs in brackets.How to reproduce:
python -I scripts/longshot_ctl.py launch <game folder> --env RX_VK_UB_SNAPSHOT=1 --env HOS_PROFILE=5 --env RX_VK_FRAME_LOG=frames.csv [--env RX_VK_UB_SNAP_DEDUP=0 --env RX_VK_UB_READ_BATCH=0], thenlongshot_ctl.py teleport Market_Child, 40 s, and 40 s measured.RX_VK_UB_SNAP_DEDUP=0 RX_VK_UB_READ_BATCH=0(every copy made and read on its own, as onmain): this PR @8db390d88db390d8The 3.5 ms the render thread no longer spends on the descriptors gives about 1 ms of frame time: it now idles 4.1 ms a
frame (2.5 before), the frame held by the GPU's 12 ms and the game's own threads. One run without the change (UA-3) had
a stretch of slow frames (11 over 40 ms, the longest 70 ms) that pulls its 1% low to 22.4; the medians don't lean on it.
With #446's guard: Kokiri Forest and the Market (16 November)
Verdict: faster on #446's guard too, where the B580 runs it: Kokiri Forest 86.85 → 93.15 fps (+7.3%) and the Market 54.35 → 59.45 fps (+9.4%) standing, 4 and 4 interleaved sessions (the medians); the replay 6.34 → 4.85 ms a frame in Kokiri Forest and 15.43 → 11.93 ms in the Market, the GPU time the same. No dark or bright patch and no whole picture dark standing, either way.
Baseline: #446's guard on the folder's source, as in #446's The guard (its "After" column): 690d8446 + #761, #838,
64ed6a2f, #1083's commits, a local region test and #446's renderer diff of 32ab00b5..c10f1e32 as a local commit. After: that build with this PR's renderer diff as rebased onto #446 (1076e816) as a second local commit, which also carries a local switch turning the uniform re-push off (unset here). The branch's perf commit now (335c890e, onmain0cab3548, #446's merge) has the same code lines as 1076e816 but for #977's late pages' hook, which moved with the page loop intosubmitted_read_locked(): that hook is not in the measured builds' source, and it is off where the pools have mirrors, as on the B580; only comments changed otherwise. Both at their defaults.Method: each session a new start of the game: Kokiri Forest, then the Market by the debug teleport, 40 s to settle and 30 s measured in each; fps from the log's 5 s
vi:windows, dark and bright patches from the region test on every presented frame of the measured windows (2 or more of 16x9 regions more than 10 levels darker, or brighter, than in both neighbouring frames), the frame log on with its pictures dropped on both sides alike; 1280x720 window, the scene rendered at 960x540 and upscaled with Intel XeSS 2.0.2 (Ultra Quality),HOS_FPS_MAX=240; each session a timed job of the queue. The orders interleaved a third setup, #446 with the snapshot off and every descriptor pushed (on #446): XR XA XP, XP XA XR, XA XP XR, XR XP XA. Walking: Kakariko Village, then the Market, 40 s each, the stick held forward 150 frames, right 20, forward 90, left 45, over and over.Flags and settings
Two new switches, both on by default where the snapshot is on (they change nothing without it).
RX_VK_UB_SNAP_DEDUPRX_VK_UB_SNAPSHOT=1). Untested: Intel iGPUs, where the snapshot is on by default; LinuxRX_VK_UB_READ_BATCHTesting
Tested:
python -I -B tests/run_all.pywith the toolchain's llvm-mingw (binand its runtime folderfirst on
PATH) and Vulkan headers (RX_CPM), on this PR's head3d43b0ee(the same files as this head,e68d8859: #446's merge,0cab3548, has thetree of #446's commits that were under it) and on
main60bf15bd, the commit under #446's merge, on the same PC: 622 passed, 26 failed, 44 skipped here; 621, 25 and 44 onmain. The same 25 fail onboth (e.g.
test_tested_configurations' CLI pipe on Windows line ends, andtest_fsr_uniform_ownershipandtest_parallel_init_order, whose fixtures don't knowFpsRtWait). The 26th,test_coverage_run, fails on this PCwhenever no game is running (
scripts/coverage/cover.pyreadstasklist's German "no tasks" line as cp1252), onmaintoo: run alone after the suite, it failed on both. The 44 skipped run on Linux or need tools this PC lacks(spirv-val, glslang). The renderer builds at
3d43b0ee(RX_VK_ONLY, llvm-mingw, 0 warnings).tests/test_submitted_page.pyandtests/test_sampler_admission.pyfailed on this change before their updateshere, and pass now.
tests/test_late_defer.py(#977's) finds its hook insubmitted_read_locked()now and passeshere and on
main; its text check fails with the hook taken out, with the hook after the copy, and with either readnot calling
submitted_read_locked().change and 3 without (above), no device lost. The picture, walking through the market with the flash detector
(
RX_VK_FLASH=1, every frame checked for frames that go white, black or flash against the ones around them):no flash, no region flash, no white or black frame, with the change and without, and none in the 6
standing runs. The checks:
RX_VK_UB_SNAP_DEDUP=2compared 40 million copies with the recording's shared one(the market, Kokiri Forest and Hyrule Field), none different;
RX_VK_UB_READ_BATCH=2, walking through the market,made 1.2 million reads again at their draw's end, none different (that check reads the stream's memory back: 1.7 fps).
Not tested: Intel iGPUs, where the snapshot is on by default (no iGPU run here: a new device means preparing the
shaders again); Linux; AMD and NVIDIA with
RX_VK_UB_SNAPSHOT=1. Without the snapshot (onmainevery GPU but Intel's,since #446 turned it on for the Arc cards too) the change runs nothing.
Must be tested:
Town's market by day, a minute each, with the defaults and again with
RX_VK_UB_SNAP_DEDUP=0 RX_VK_UB_READ_BATCH=0,expecting the same picture both ways (no white blocks, no object drawn in another's place, no sky over the forest's
ground), the log's
uniform copies (RX_VK_UB_SNAP_DEDUP=1)line with the defaults, and no lower fps (by hand: atester with an Intel iGPU, asked in #test-requests).
longshot_vk.so) from this branch and play the market by day for a minute withRX_VK_UB_SNAPSHOT=1, expecting it to build, the same picture as withRX_VK_UB_SNAP_DEDUP=0, and the log'suniform copies (RX_VK_UB_SNAP_DEDUP=1)line (Test Farm: @Beanstalk linux, build and the market withRX_VK_UB_SNAPSHOT=1)
Risks
What could break: a draw given a copy whose contents its own copy would not have had would draw with stale
uniforms: objects in the wrong place, the wrong colour or flickering. A copy is shared only within one recording, for
the same address and size, with the same captures in view (a capture published or a page stamped since makes a new
copy), and the check found no copy different in the market, Kokiri Forest and Hyrule Field. The uniform writes are pushed every draw again: a push that leaves some of a
draw's uniform buffer writes out is what the B580 draws wrong, and with all of them pushed that can't happen.
A read made at the build's end instead of where it was asked sees the same submission's captures (the check compares
both).
Turning it off:
RX_VK_UB_SNAP_DEDUP=0andRX_VK_UB_READ_BATCH=0.Compatibility: Nothing changes: no option, cache or save format, and the renderer's interface is the same
(
MKWVK_API_VERSIONunchanged).Issues
See #446
Checklist
Everyone
type(scope): description) of the status line's type.main(0cab3548, #446's merge: this PR's three commits alone now; on60bf15bdbefore it, #977's hook moved with the page loop).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).tests/that reads changed source updated in this PR, not weakened.built here (no Linux toolchain on this PC); the change uses no platform API. Asked of the Test Farm (Must be tested).
🤖 Generated with Claude Code
Tested in game: Windows 11, Intel Arc B580, driver 32.0.101.9154, i5-13600K, with the uniform snapshot on (as #446 sets it), render 75% with Intel XeSS: Castle Town's market as child by day, 3 runs with the change and 3 without, 54.9 to 59.5 fps and the descriptors 6.1 to 2.6 ms a frame, no device lost; walking through the market with the flash detector, the change on and off: no flash, no white or black frame; the check modes RX_VK_UB_SNAP_DEDUP=2 (40 million copies in the market, Kokiri Forest and Hyrule Field) and RX_VK_UB_READ_BATCH=2 (1.2 million reads) found no copy different.
@Beanstalk two runs for this PR, please (it still merges cleanly onto main
0691f81c):longshot_vk.so) from this branch, then child Link in Castle Town's market by day, 60 s after 40 s to settle, withRX_VK_UB_SNAPSHOT=1(the uniform snapshot this PR speeds up; off by default there), once as it is and once withRX_VK_UB_SNAP_DEDUP=0 RX_VK_UB_READ_BATCH=0(this PR's sharing and batched reads off). Expected: it builds; the log lineuniform copies (RX_VK_UB_SNAP_DEDUP=1)in the first run; the same picture both ways (no object drawn with another's matrices, no white blocks), no device lost, and no lower fps in the first run.RX_VK_UB_SNAP_DEDUP=0 RX_VK_UB_READ_BATCH=0. Expected: the same picture both ways (no sky over the forest's ground, no white blocks), theuniform copiesline with the defaults, and no lower fps with them.@nyannoying only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it.This request was for7a5e590, and the PR has changed since (fb2f963), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.Nice, contained change. The sharing is keyed tightly (address, size, the recording's epoch, the capture view), the batched read reuses the same unlocked/locked halves as the single read, and with both switches at 0 the path is main's. I also checked two things that could have gone wrong, and both hold: a queued read's pointer into a stream the recording has moved off stays valid until the slot's next recording, and
uniform_rangeis only reached frombuild_descriptors, so every queued read is flushed before the bind.bind_descriptorschange is a workaround with no known cause. Unchanged uniform-buffer writes are already skipped today on the same GPU: the bank cache and c1 give the same buffer and offset draw after draw. AndRX_VK_UB_SNAP_DEDUP=2can't exercise the skip, because every copy there has its own offset. So "the driver drops unchanged writes" isn't shown yet. Could you tryRX_VK_PUSH_ALL=1with the sharing on andagainremoved, andRX_VK_UB_SNAPSHOT=0 RX_VK_PUSH_ALL=1on the B580? If the second also fixes the wrong matrices, part of what #446's snapshot fixes on Arc is the delta push, and that changes what both PRs should do. Also,againre-pushes the banks and c1 at every draw, not only the shared copies.vk_memory.cpp(git merge-treeshows it). #977 addslate_defer_cpu_readto the per-page loop that this PR moves intosubmitted_read_locked, andtests/test_late_defer.pylooks for that hook inmemory_read_as_submitted's text. Whichever PR lands second should put the hook insubmitted_read_locked. Otherwise the batched reads skip it on Intel iGPUs, where both are on (no mirrors).This is a code read only: nothing was built or run.
🤖 Generated with Claude Code
@ -4329,0 +4461,4 @@// drew objects with other objects' matrices (Castle Town's market). Before the sharing each draw had copies of its own, so// every one of its uniform buffer writes had changed and was pushed: they still all are, the textures and storage buffers// only when changed, as beforestatic const bool ub_every = ub_snapshot_on() && ub_snap_dedup_mode() == 1;Identical uniform-buffer writes are already left out of the push here on the B580: the bank cache returns
{c.buf, c.at, n}and c1 returns{it->second.first, it->second.second, n}draw after draw. So this probably isn't the driver dropping every unchanged write. An A/B withRX_VK_PUSH_ALL=1(sharing on,againremoved) and one withRX_VK_UB_SNAPSHOT=0 RX_VK_PUSH_ALL=1would show whether the delta push or the shared copy is behind the wrong matrices. Also,againmatches everyVK_DESCRIPTOR_TYPE_UNIFORM_BUFFERwrite, so banks and c1 are now pushed at every draw too.@ -1337,0 +1340,4 @@return 2;}/// (pools_mu held) the pages of that read a capture holds, copied over what guest memory gave: how manyint64_t submitted_read_locked(uint64_t guest, void* dst, uint64_t n) {Heads-up: #977 adds
if (late_defer_any()) late_defer_cpu_read(...)inside this per-page loop (on the oldmemory_read_as_submitted), and the two branches conflict here. Whichever lands second should put it in this function, somemory_read_as_submitted_manygets it too, and pointtests/test_late_defer.py's text check here.@dyst both runs are done on the B580: it is the delta push, and, as you suspected, not every unchanged uniform-buffer write.
Windows 11, Arc B580, driver 32.0.101.9154, render 75% with Intel XeSS (Ultra Quality); Kokiri Forest and Castle Town's market as child by day, standing, 40 s to settle and 8 s measured; two sessions of each setup, the second round in reverse order. The builds: #446's head, and this PR rebased onto it with
againbehind a local switch, both on the renderer my game folder runs. The picture is checked as numbers: each frame's brightness in 16x9 blocks, averaged over the window and compared with this PR's own (its two sessions differ by 0.7-0.8 on 0-255), and the region-flash count.RX_VK_UB_SNAPSHOT=0RX_VK_UB_SNAPSHOT=0 RX_VK_PUSH_ALL=1againremovedagainremoved,RX_VK_PUSH_ALL=1Medians of the two sessions; the flashes and dark pictures summed over both (the flash lines stop at 400 a session, so the broken setups' counts are floors). ¹ In the market, #446 alone differs only in the middle of the picture (12 of 144 blocks more than 10 off, none near the edges, no flash); not looked into further. ² This PR's two sessions against each other.
(The fps of the two broken setups isn't comparable: their scene isn't the same one.)
RX_VK_UB_SNAPSHOT=0 RX_VK_PUSH_ALL=1alone fixes the wrong matrices (0.9 and 0.6 off this PR's picture, no region flash). So what #446's snapshot fixes on the B580 is the delta push, not uniforms rewritten under a range bound in place: with each draw's own copies, every uniform-buffer write is new, so every one is pushed.againremoved, the picture breaks as with the snapshot off (sky over the forest's ground, white blocks: 45 and 80 off), andRX_VK_PUSH_ALL=1puts it right (1.2 and 0.5 off). The shared copies hold the right bytes; leaving their writes out of the push, as unchanged, is what goes wrong.bind_descriptorswill say which ones, once that is known. What it trips on is still open. A local build now runs with the snapshot off, adding the uniform-buffer writes to one kind of push at a time: a push that carries other writes but no uniform buffer, a draw that would push nothing, or a push that already carries one. It also counts how often each kind happens. That should say what it is, and whetheragainneeds the banks and c1. I'll add the result here.Walking with this PR's build (Kakariko Village, then the market, 40 s each on the same path; one session each), the frames with two or more regions darker / brighter than both neighbours: this PR 0 / 0 and 6 / 6; without
again1,194 / 309 and 1,516 / 327; withoutagain, withRX_VK_PUSH_ALL=1, 0 / 1 and 3 / 2 (out of 2,400 to 3,000 frames an area; the flash lines stop at 400 a session, so these are the region test's own totals).On #977: noted. Whichever lands second puts
late_defer_cpu_readinsubmitted_read_locked, somemory_read_as_submitted_manygets it too, and pointstests/test_late_defer.py's text check there. If that's this PR, it goes into its rebase.What this means for #446 and for this PR is on #446 (#446): with the snapshot off and every descriptor pushed, the B580 draws this PR's picture at this PR's fps, with no copies at all.
🤖 Generated with Claude Code
@dyst the result of the local build from point 3: the snapshot off (main's delta push), and the uniform-buffer writes the delta left out added back to one kind of push at a time. Standing as before, one session each; the build also counted the delta pushes (about 7.3 million a session).
(The flash lines stop at 400 a session, so the broken rows' counts are floors.)
So what the B580 gets wrong is a push that carries some of a draw's uniform-buffer writes and leaves others out as unchanged: the draw then reads wrong data. Pushing the ones left out along with it puts the picture right; adding them anywhere else doesn't.
againpushes every uniform-buffer write in every push, so it covers that case (it is 99.8% of the pushes anyway).The banks and c1 still fit: with #446 alone they are left out unchanged from pushes whose other uniform-buffer writes are all new copies, and the picture is right. So it isn't every uniform buffer left out; what tells the bad ones apart is still open. I haven't tried
againwithout the banks and c1, so I can't say it may skip them. The rebase's comment inbind_descriptorswill say what is known: a push that carries one of a draw's uniform-buffer writes carries them all.🤖 Generated with Claude Code
7a5e59083efb2f963a47Pushed
fb2f963a: three commits on #446's heada1c51ef2(main71b1edd8):020a91efperf(vk): rebased onto #446's guard. The snapshot's decision is #446'sub_snapshot_wanted()(this PR's ownub_snapshot_on()is gone); a range the guard binds in place is bound before the sharing is asked; and the comment inbind_descriptorsgives the B580's cause as measured (my comment above: a push that carries some of a draw's uniform buffer writes and leaves others out as unchanged). TheRX_VK_UB_SNAP_DEDUProw says the snapshot is on by default on Intel GPUs (#446). Its code lines are those of 1076e816, the build #446's A/B ran; only comments changed since.0b5fc0dcdocs: the same, with anAssisted-by:trailer.fb2f963adocs(tested): one file for each run of this PR's arm in #446's A/B (4 standing sessions, 3 walks).The description: Measurements has the A/B with #446's guard (Kokiri Forest 86.85 → 93.15 fps, the Market 54.35 → 59.45, standing, 4 and 4 sessions), and Testing the new head's checks.
Checked at
fb2f963aon this PC: the renderer builds (RX_VK_ONLY, llvm-mingw, 0 warnings); run_all: 611 passed, 25 failed, 43 skipped; main71b1edd8609, 25 and 43, the same 25 failing.🤖 Generated with Claude Code
fb2f963a473d43b0ee34Rebased onto
main60bf15bd: head3d43b0ee.main, put its late pages' hook (late_defer_cpu_read()) in the page loop this PR moves intosubmitted_read_locked(). The hook moved with the loop, so the reads made together (memory_read_as_submitted_many()) take a late page's copy again before reading it, as a read on its own does.tests/test_late_defer.pylooks for the hook there now, and checks that both reads go throughsubmitted_read_locked(). Its text check fails with the hook taken out, with the hook after the copy, and with either read not callingsubmitted_read_locked()(four edits, each run).a1c51ef2, merges without a rebase, so it isn't pushed again.ub_snapshot_on()line was stale since the 15:40 push: the default is #446'sub_snapshot_wanted(). It says that now.Checked at
3d43b0ee:RX_VK_ONLY, llvm-mingw), 0 warnings.tests/test_late_defer.pypasses here and onmain60bf15bd.python -I -B tests/run_all.py(llvm-mingw and the toolchain's Vulkan headers): 622 passed, 26 failed, 44 skipped here;main60bf15bd621, 25 and 44. The 26th istest_coverage_run, which fails on this PC whenever no game is running, onmaintoo (run alone after the suite, it failed on both).Why the numbers still hold, not measured again: the in-game A/B is this PR's renderer diff on and off on one build of the game folder's source (the Baseline line), and that diff changed only where #977's hook sits. The hook isn't in the measured builds' source, and on the B580 it is off (
late_defer_on(): off where the pools have mirrors). Main's other changes since71b1edd8are in neither column.🤖 Generated with Claude Code
3d43b0ee34e68d88597e#446 is merged (
0cab3548), so this branch is now just this PR's three commits on it: heade68d8859. #446's seven commits are no longer in the diff.The files are the same as 3d43b0ee's: #446's merge has the same tree as the #446 commits that were under this PR (
git diffof the two is empty), andgit diff 3d43b0ee e68d8859is empty too. So the build and the checks in my last comment hold for this head.The description no longer has the "Stacked on #446" note. Its Not tested line now says the snapshot is on for every Intel GPU on
main.🤖 Generated with Claude Code
Reviewed current head
e68d88597e8c3ffacac74afe85e034e57c06dd4c, code and posted evidence only. Request changes for the snapshot-off fallback path noted inline; not ready for merge. Nothing built, tested or launched in this review, and no source changes pushed.The earlier review's two concerns have substantive answers in this head:
submitted_read_locked(), before copying the capture's bytes. Both the single and batched readers call it underpools_mu. The updated late-defer wiring check covers both callers; the author reports mutation checks removing/moving the hook and disconnecting either caller. I am not repeating the old conflict with #977, which is already merged.The address/size/capture-view/recording-epoch key prevents reuse across recordings or capture views. Stream growth retains the old buffers/mappings, so queued destinations and memoized buffer offsets survive a move to the next stream.
UbReadsScopeflushes before descriptor binding on the normal descriptor-build exits. The shared locked reader retains both late-fix and late-defer handling. No renderer ABI, vendored code or generated shader changes are involved.One scope/correctness gap remains:
uniform_range()reaches the new dedup and batch code whengpu_buffer_bind()fails or returns an unaligned range even ifub_snapshot_wanted()is false. Thus this is not confined to the snapshot-on path described by the PR. The inline comment asks to preserve the old fallback path when snapshotting is off, or explicitly make the broader path safe and validate it; the existing sampler fixture stubs snapshotting off and therefore does not exercise the new sharing/re-push combination.Evidence acknowledged, not independently rerun: Windows B580 interleaved A/Bs report +7.3% in Kokiri Forest and +9.4% in the Market with the merged snapshot guard. The author reports a warning-free Windows renderer build and baseline-compared full suites on the tree reported identical to this head, including the separately reproduced baseline
test_coverage_runfailure. The timing builds contain other explicitly disclosed changes and the description explains why the rebase's late-defer-hook move does not affect those B580 numbers. Standing region tests reported zero detections; the later walking runs have nonzero dark/bright region detections, so they should not be summarized as zero walking flashes or as proof of no visual regression.Remaining readiness evidence: an Intel iGPU run with defaults versus both optimizations disabled, and a Linux renderer build plus snapshot-on Market run. These are still explicitly required in Testing. The old farm request targets
7a5e590, not this head, and is marked stale; it does not satisfy current-head coverage. Keep WIP until the outstanding coverage and applicable checklist are settled.Overlap: #446 and #977 are already in the base. Open #1158 touches recording-stream ownership, #794 touches descriptor reuse, and #759 and #326 touch capture/memory code. They are related work, not identified duplicates; whichever lands later needs its affected lifetime/read paths checked against the merged version.
@ -3494,12 +3603,26 @@ VkDescriptorBufferInfo uniform_range(const NvnState& s, const Stage& st, uint32_static std::atomic<int64_t> after_gpu[2][2];if (gpu_written) after_gpu[gpu_written - 1][b && b.offset % align == 0 ? 0 : 1].fetch_add(1, std::memory_order_relaxed);if (b && b.offset % align == 0) return {b.buffer, b.offset, n};static const int dedup = ub_snap_dedup_mode(); // (the recording's earlier copy of the range: ub_snap_slot)[P2] Preserve the fallback path when the uniform snapshot is off. The early return immediately above only handles a successful aligned gpu_buffer_bind(). If snapshot is false and that bind fails or is unaligned, dedup still defaults to 1 here and batching defaults to 1 below: repeated fallback ranges now reuse a stream copy and their reads move to descriptor-build exit. This changes the default AMD/NVIDIA fallback path and explicit RX_VK_UB_SNAPSHOT=0 runs despite the stated snapshot-only scope. It also creates shared fallback UB writes while bind_descriptors disables its re-push safeguard via ub_snapshot_wanted() && ub_snap_dedup_mode() == 1; on the documented B580 partial-push failure path those shared writes can again be omitted. Gate both new optimizations on snapshot here, leaving the immediate per-binding read when it is false, or intentionally support the broader fallback path with matching push handling, documentation and evidence. Add a behavioral fixture for snapshot off with an unaligned/out-of-pool binding repeated across draws; the updated sampler fixture only tests the non-snapshot descriptor path without exercising these copies. This is a code-path finding, not a claimed new in-game reproduction.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.