Skip to content

GPU: marked UAV refreshes cover whole 64 KiB pages - #2172

Merged
Marvisak merged 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-marked-uav-subpage-copyback
Nov 25, 2026
Merged

Marvisak merged 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-marked-uav-subpage-copyback

Conversation

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Problem

A marked UAV view that is shorter than 64 KiB, or not page-aligned, inside a tracked buffer copy refreshed only its own byte range, and Shadow::update split tracked refreshes at the ranges earlier lists' shaders write. Either way Tracked::take saw only part of the enclosing 64 KiB page, so the page was neither guarded nor taken. It stayed changed, and after the submission Shadow::copy_back_marked hit saved.is_none() && t.changed(page) and kept the title's bytes, dropping every GPU write to that page.

Changes

  • Shadow::page_range widens a range to the 64 KiB pages it touches, cut to the copy.
  • Marked UAV refreshes use it: table views (readable), root UAVs (State::root_view) and heap hulls (bindless::refresh). The range declared as written (gpu_writes) stays exact.
  • Tracked copies take the whole refreshed range in one Tracked::take, still updating the snapshots under ranges shaders write. Only pages the title changed are copied, and no shader of the submission has run yet at that point, so the wider refresh overwrites no GPU writes. Untracked copies are unchanged.
  • Tests: sub-page and unaligned marked UAVs, a CPU copy to the same page before and during the write (three-way merge), copies smaller than or straddling a 64 KiB page, an unaligned root UAV, and bindless hull widening.

Verification

  • cargo test -p victory-gpu --locked on hardware and with VICTORY_D3D12_WARP=1: all pass except dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, which fail the same way on main (HEAP_VIEWS limit).
  • The new tests pass with VICTORY_D3D12_DEBUG=1 and no debug-layer messages. All 5 new tests fail without the page widening.
  • cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings and cargo xtask policy pass.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib marked_subpage_uav_writes_copy_back_and_keep_neighbor_bytes — passed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean whole-64 KiB-page coverage for marked UAV refreshes preserving neighbor bytes on subpage writes. Looks good.

AI-assisted (Gemini 4 Neon).

RecompLive pushed a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
From Marvisak/VIctory#2172 (GPL-3.0-or-later, fuzeofficial), adapted to
our tree (kept ensure_buffer_state on the refreshed range):

- Marked UAV refreshes (table views, root UAVs, heap hulls) widen to the
  64 KiB pages they touch, cut to the copy (Shadow::page_range); the
  range declared as written stays exact. Tracked copies take the
  refreshed range in one call, still updating the snapshots under ranges
  shaders write.
- Shadow::update no longer splits tracked refreshes at the ranges earlier
  lists' shaders write, so Tracked::take sees the whole enclosing page:
  the page is guarded and taken, and copy_back_marked keeps GPU writes.
- Tests: 5 marked-UAV page tests (sub-64 KiB, unaligned/cross-page, CPU
  disjoint three-way merge, after a copy, root+bindless hulls).

(cherry picked from commit a78c1e93edcdecf65b96d4325ee9d4ac268462dd)

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Marked UAV refreshes cover whole 64 KiB pages — refresh-granularity coarsening; relates to #1986/#1998/#2004's withheld-range cluster (#1976).

@MamaLeVrai

Copy link
Copy Markdown

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head a78c1e93 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 706 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

@Xvania7 Xvania7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardware verification on real hardware: NVIDIA GeForce RTX 5060, Windows 10 x64, Rust 1.98.1.

Tested a78c1e9 checked out into an isolated tree:

  • cargo clippy -p victory-gpu --target-dir ... -- -D warnings: 0 warnings, clean.
  • cargo run -p xtask -- policy: clean (asset policy: 182 files ok).
  • shadow::tests: 4/4 passed:
    • mark_runs_are_reused_and_joined: ok
    • title_writes_under_a_busy_range_are_copied: ok
    • snapshots_cover_the_declared_ranges_and_writes_go_back_once: ok
    • marked_pages_go_back_by_the_bytes_the_gpu_changed: ok
  • draw::tests marked subpage UAV test suite: 5/5 passed:
    • marked_subpage_uav_and_cpu_disjoint_write_three_way_merge: ok
    • marked_subpage_uavs_after_copy_in_same_list: ok
    • marked_subpage_uav_writes_copy_back_and_keep_neighbor_bytes: ok
    • marked_subpage_uav_unaligned_and_cross_page_shadow_bounds: ok
    • marked_unaligned_root_uav_and_bindless_subpage_refresh: ok

Ensuring marked UAV refreshes align to full 64 KiB page boundaries cleanly prevents partial unaligned copy-backs across subpage chunks while preserving adjacent bytes. LGTM.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Recommended for a maintainer's look (re-reviewed after the rebase). Marked UAV refreshes (readable and State::root_view in draw.rs, bindless::refresh) now widen to whole 64 KiB pages via Shadow::page_range, and Shadow::update takes a tracked range in one Tracked::take (update_tracked) instead of splitting it at busy ranges, so copy_back_marked no longer finds a partly taken page still changed and keeps the title's bytes over the shader's. I checked page_range against the copy's bounds, that the declared written range (gpu_writes) stays exact, and that the before snapshot is still synced for bytes copied under ranges earlier lists write. One behaviour change to be aware of: under such busy ranges the untracked and unmapped parts of a tracked copy are now refreshed as well (before, only taken runs were), with the snapshot synced; by my reading that is consistent with the existing reasoning that no shader of the submission has run yet.

CI: check passing on this head.


Generated by Claude Code

A marked UAV view shorter than 64 KiB, or not page-aligned, refreshed only
its own range, and Shadow::update split tracked refreshes at the ranges
earlier lists' shaders write. Either way Tracked::take saw only part of
the enclosing 64 KiB page, so the page was neither guarded nor taken: it
stayed changed, and copy_back_marked kept the title's bytes, dropping
every GPU write to the page.

Marked UAV refreshes (table views, root UAVs, heap hulls) now widen to
the 64 KiB pages they touch, cut to the copy (Shadow::page_range); the
range declared as written stays exact. Tracked copies take the refreshed
range in one call, still updating the snapshots under ranges shaders
write. Only pages the title changed are copied, and no shader of the
submission has run yet, so the wider refresh overwrites no GPU writes.
@fuzeofficlal
fuzeofficlal force-pushed the fix/gpu-marked-uav-subpage-copyback branch from a78c1e9 to d813e33 Compare November 25, 2026 16:08
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
@Marvisak
Marvisak merged commit 5319366 into Marvisak:main Nov 25, 2026
1 check passed
Airamek added a commit to Airamek/VIctory that referenced this pull request Nov 26, 2026
Upstream model everywhere, our additive diagnostics kept. 15 files
conflicted, all resolved file-by-file:

- README: our fuzz_tests/ship-profile/VICTORY_DIFF_ONLY/VICTORY_NAME_SHADERS
  notes beside upstream's status/blake3-paths/translate-jobs wording.
- descriptor/host.rs: upstream Marvisak#2462 (no typed UAV in a format the host
  cannot store to) lands untouched through the merge; keeps its
  device-removal fix, no behavior change on capable hosts.
- descriptor.rs: our monotonic heap-id guard + upstream Marvisak#2234
  (released view heap takes its page table with it).
- pipeline/library.rs: upstream Marvisak#2179 (lock-free loads via Shared) +
  our best-effort periodic save (try_lock on state).
- capture.rs: our Marvisak#2607 signed-32 decode + test beside upstream's
  r32_integer_to_rgba.
- draw.rs: our buffer_state tracking + root-signature test beside
  upstream's marked page-range refresh (Marvisak#2172) + sampler-heap test.
- pipeline/host.rs: upstream vertex/depth-bounds/integer-blend model
  (stream_pipeline, host_blend, depth_with_bounds) + our padding-zeroing
  clean_* and Stream zeroing; both test batches kept.
- pipeline/make.rs: keep lost/screen fields + upstream skipped_shader.
- pipeline.rs: keep bytes()/pipelines_waiting() beside for_test.
- host.rs: multi-plane present (Marvisak#1997, Compositor) + our previous-frame
  wait, presented/probed frame tracking, keep-textures, drain-before-save;
  both test modules (submissions + present_plane_tests).
- queue.rs: upstream blinks (Option<bool>) supersedes ours.
- shadow.rs: upstream update_tracked/update + merge_writeback (Marvisak#2054) +
  our stale/submission_done/Part snapshots/buffer_states; update_free and
  update_busy retired as subsumed (no callers left).
- xmem.rs: upstream shared system_commit() supersedes our inline version.
- emit/host.rs: our fence-event wait() + upstream SharedDevice/Marvisak#244
  (shared/serialized WARP device).
- emit/lower.rs: upstream i64 dword ordering (Marvisak#1599) + our f/t lane path
  and RDNA2 opcode names; tests moved verbatim to lower_tests.rs via
  #[path] (lower.rs exceeded the 512 KiB asset-policy limit after the
  merge; module path unchanged, content byte-identical).
- emit/valu_tests.rs: our s_load_dwordx4_at + upstream sopk helper.
- gfx10/opcodes.rs: upstream pub(crate) + our RDNA2 names.
- fuzz_tests.rs: Host::from_device() for upstream's new warp field.

Test adaptations (same execution-model class as the 13f91ca merge):
8 upstream tests written for synchronous execute() drain explicitly on
our async-completion queue (marked-UAV/placed-view/rebind tests);
Host::from_device() port; words() accessor for privatized field.

Gates: cargo test --workspace --locked green, clippy --workspace
--all-targets --all-features -D warnings clean, xtask policy 197 ok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants