GPU: drop only marked pages for withheld marked ranges #3099
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3099
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3099"
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?
@fuzeofficlal on GitHub · 2026-11-26 08:01 UTC · original
fuzeofficlal:perf/gpu-withheld-drop-only-marked-pages-3089→main· +364 −22 · 2 files · 1 commits · openCloses #3089
Summary
When a submission withholds a declared
Step::GpuWriterange,Host::executepreviously calledcrate::memory::drop_withheld(address, len)over the entire range, forcing every 64 KiB page in that range to be re-copied from title memory on the next refresh even when shaders only touched a fraction of the pages.Where every step naming a withheld range marks its written pages (
marked == true) and the copy's mark bits are complete, only pages actually marked in the written-pages bitmaps contain withheld shader bytes:markedwith AND (crates/victory-gpu/src/host.rs): Trackmarkedper merged(copy, address, len)entry as the logical AND across allStep::GpuWritesteps naming that range. Any range with an unmarked writer (e.g., clears, unmarked root UAVs, untracked copies, or copies without mark bits) still drops whole.crates/victory-gpu/src/host.rs,crates/victory-gpu/src/shadow.rs): Skipdrop_withheld(address, len)for withheld ranges wheremarked && shadow.marks_complete().marks_complete()checks that all mark bits of the copy lie below the bitmap's last dword (which is cleared whole for the overflow sink bit onmainuntil #2269 lands), safely falling back to a whole-range drop for that dword without conflicting with #2269.keep_writesandnote_withheldstill run as before.crates/victory-gpu/src/shadow.rs): Pages from the title-memory bitmap (held) are already dropped page by page. Pages from the ordinary bitmap thatcopy_back_marksfilters out aswithheldare now collected, deduplicated, and dropped viadrop_withheld(page, PAGE)after all non-withheldcopy_back_markedcalls finish, preventing an immediatewatch::retakeon a shared page from marking another copy's page changed before its own copy-back runs.Tests
crates/victory-gpu/src/host.rs(withholding):withheld_marked_range_drops_only_marked_pageswithheld_overlapping_ordinary_marked_write_drops_only_marked_pageswithheld_range_mixing_marked_and_unmarked_steps_drops_whole_rangewithheld_marked_drop_runs_after_other_copy_marked_copy_backshadow::tests::marks_below_last_word_excludes_the_sink_dwordincrates/victory-gpu/src/shadow.rs.cargo test -p victory-gpu --locked -- withholding:: shadow::tests::marks_below_last_word shadow::tests::marked_pages_go_back shadow::tests::marks_of_shaders_using_title_memory shadow::tests::what_a_frame_withholds(9 passed on RTX 5090)VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked(251 passed, 0 failed)cargo clippy --workspace --all-targets --locked -- -D warningscargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test -p xtask --locked policy::tests::repository_passes_policy@Dukestar69 on GitHub · 2026-11-26 08:11 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 11/11 passed on RTX 5090 and WARP.cargo test -p victory-gpu --lib host::withholding -- --test-threads=1: 5/5 passed on RTX 5090 and WARP (all 4 new marked-page withholding tests pass, plus all remaininghost::tests).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly restricts withheld-marked-range drops to the actually marked pages while preserving the full-range drop when marked and unmarked steps are mixed.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Marvisak on GitHub · 2026-11-26 08:24 UTC · original
Automated triage for the maintainers.
Merge candidate. This implements #3089. For a withheld
Step::GpuWriterange whose steps are all marked,Host::execute(crates/victory-gpu/src/host.rs) now skips the whole-rangedrop_withheld.shadow::copy_back_marksinstead drops only the ordinary-bitmap pages it filters out as withheld, and only after the other copies' marked copy-backs have run. Pages from the title-memory bitmap were already dropped page by page.What I checked against main:
markedis ANDed across every step that names the same(copy, address, len), so a range with any unmarked writer is still dropped whole.Shadow::marks_completefalls back to a whole-range drop for any copy whose mark run reaches the bitmap's last dword.copy_back_marksclears that dword unread (bits[words - 1] = 0, #2269), which is the concern raised on #3089.Marks::takecan hand out bits there, so the fallback is needed and is in the right place.CI (
check) passes.A note for review: the saving depends on marks being complete for marked steps. A view write that loses its mark (other than the last-dword case handled here) would now leave withheld bytes in the copy, where before they were dropped. The measurements are on #3089 (another contributor's fork); the PR itself adds synthetic tests only.
Generated by Claude Code
@Machad3x on GitHub · 2026-11-26 10:07 UTC · original
Thank you for these tests; three of them are now in my fork (Ryzen 7 5700X, RTX 3080 Ti), under your authorship, and pass on top of an equivalent change.
One related ordering problem showed up while reviewing them. It is on
maintoo, not introduced here: incopy_back_marks, theheldpages (marks in the title-memory bitmap while memory is withheld) are dropped before the marked copy-backs. When the submission missed,drop_withheldretakes at once, which marks the page changed in every copy holding it, so another copy'srun_backskips the page and its ordinary write never reaches title memory.withheld_marked_drop_runs_after_other_copy_marked_copy_backreproduces it with one change: the outer copy's mark set in the title-memory bitmap (mark_page_for_test(p, true)) instead of the ordinary one.title(32)stays0x22where0xbbwas expected.What fixed it here: drop the held pages together with the others, after the copy-backs, and keep a held
(copy, page)out of that copy's own copy-back (a page both kinds of shader marked through one copy would otherwise go back with the held bytes in it). The earlyreturnonmarked.is_empty()has to go, or move below the drop.Tested with the crate's tests and one 5-minute run in the game.
AI-assisted.
@fuzeofficlal on GitHub · 2026-11-26 16:41 UTC · original
Thanks @Machad3x for adopting the tests and flagging that pre-existing
copy_back_marksordering edge case when a held page is shared with a non-marked copy — worth keeping this PR focused on #3089 and tracking that ordering interaction separately.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.