perf(gpu): split UAVs out of State::scan cache and reuse descriptor::view_of #510
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!510
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-510"
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?
@Not4Eric on GitHub · 2026-12-04 20:24 UTC · original
Not4Eric:perf/draw-split-uav-scan-cache→main· +64 −33 · 1 files · 1 commits · merged 2026-12-05 17:28 UTCWhat this does
Precomputes each
TableGroup's UAV descriptor indices inTablePlan, allowingdraw::State::scanto cache descriptor tables that contain UAVs (whenpicked.is_empty()andlist.epoch()did not advance during the scan) and re-scan only the UAV slots on subsequent cache hits instead of re-scanning the entire descriptor table. Also replaces redundantdescriptor::view(at)lookups withdescriptor::view_of(words[1], words[2])using the already-read record words and reuses the looked-upViewinstead of queryingVIEWStwice.Checks
TableGroup/TablePlanandState::scanincrates/victory-gpu/src/draw.rs.draw::unit tests pass; no prior behavioural bug existed for a failing-before unit test.perf/records-skip-touch-batch-stats.cargo xtask policypassed (359 files ok); no fork-only files, configs, or build outputs.Verified
cargo xtask policy—359 files okPKG=victory-gpu ./build.sh test --lib -- draw:: --test-threads=1(Proton Wine on Linux, RX 9070 XT) —7 passed; 0 failed; 1 ignored, 0 warningsCost
One small
Vec<u32>(uavs) perTableGroupinTablePlan; 0 new warnings.AI-assisted: yes
@Kal0s-design on GitHub · 2026-12-04 21:53 UTC · original
Checked
62df21fon native Windows (one NVIDIA desktop card plus WARP, didn't run the game), against current main.Tests come out the same on both sides.
draw::is 7 passed, 1 ignored. The full victory-gpu lib has the same failures on main and on the PR (the two indirect host_list tests and the two pipeline library tests that fail natively, plus the flaky watch test). The device subset with diagnostics matches too, under WARP and on the NVIDIA card with the debug layer. Clippy with and without diagnostics adds nothing in draw.rs. Keep in mind that no test in the tree reachesState::scan, so the passingdraw::tests don't cover this change.To see the cache itself I wrote a throwaway test (not pushed). It scans one table of two fake buffer records (SRV + UAV) five times with a different
directeach call. The records point at no view, so this only checks the caching, not barriers or tracking. On main that table is never cached and each call returns thedirectit was given. On the PR the second call hits and returns the first call's offset (7 instead of 9). Afterchanged_something()it misses and caches again. When I rewrote the UAV record in place without an epoch bump, the rescan read the new record but the call still returned the old offset and skipped the SRV slot.On invalidation, the hit is as safe as SRV-only tables already are on main, no more. The epoch moves on state changes (host.rs:5229 for transitions, 5340 for twins, defer_copy and friends), never on descriptor writes, and the key is just table address + group + STORES + tested depth. So on a hit the SRV slots of a UAV table now skip
c.touchand thefreshre-mirror check (draw.rs:2841, 2843/2848), which main still did for them on every draw. Depth twin UAVs bump the epoch every time (|| colourat host.rs:5340), so those tables never get cached. Texture UAVs get cached whenever the scan doesn't need a transition, and buffer UAVs don't bump at all, so that's where the saving is.The one case I'd look at is when the offset is a copy. On the aside path (draw.rs:2703 and 2723)
scangets a fresh copy of the table asdirecton every draw, andbesidesnapshots the table bytes at call time. The same goes for the copy made for uncovered buffers. On main a UAV table always used the fresh copy. With the PR a hit returns the copy from the first scan of the epoch, while the UAV-only rescan reads the live table. If the title rewrites a UAV descriptor in place within the epoch, the barriers and write tracking follow the new view but the shader writes through the old copy. SRV-only tables already work like this on main, but for UAVs it's the write side that drifts. A cheap guard would be to take the UAV hit only when the cached offset is the plain direct one.Smaller things
has_uav(draw.rs:38, 79) is now only written, never read.uavsis built after the first-declaration dedup (draw.rs:89), so a descriptor declared SRV first and UAV second no longer marks the table as having UAVs. Main's scan used the SRV kind there anyway, so the output doesn't change, it just gets cached now.counts[0](SCANNED) is still incremented on UAV-only hits (draw.rs:2788), so that stat won't show the saving.view_of(words[1], words[2])matchesview(at)once the VIEW_TAG check has passed, and one snapshot of the record is better than two reads.Nothing blocking from me apart from the copy question.
AI-assisted: yes
62df21fa44to0952e48a89@Not4Eric on GitHub · 2026-12-05 00:00 UTC · original
Thank you so much for helping, I'm not the best at this and I'm heavily relying on AI to even do this
Pushed updates addressing your review:
is_directintoState::scanso UAV tables are only read/stored inself.scannedwhen using the live direct table (neitheraside/besidenoruncoveredcopies), preventing stale copied UAV tables from drifting on in-place descriptor updates.has_uavfield fromTableGroup.self.counts[0] += 1with!uav_onlyso UAV-only re-scans aren't counted as full scans.@Kal0s-design on GitHub · 2026-12-05 00:48 UTC · original
Re-checked
0952e48on native Windows (didn't run the game).The copy issue is fixed.
is_directis false on both copy paths (draw.rs:2703, 2727) and true only for the plain direct table (2741), UAV tables only hit with it set (2780) and are only stored from a direct scan with nothing uncovered (2921). So a cached UAV offset is always the current direct one. My throwaway probe agrees, copies never cache or hit for a UAV table, a direct hit returns the direct offset, and a UAV record rewritten in place is no longer stale.has_uavis gone and UAV-only hits no longer bumpcounts[0](2794).Full victory-gpu lib is 352 passed / 5 failed, the same known native failures as before, and clippy with and without diagnostics shows nothing new.
Looks good to me.
AI-assisted: yes
github-bot referenced this pull request2026-12-05 02:15:02 +00:00