Skip to content

GPU: batch host mirroring for contiguous descriptor copies - #3265

Open
yumaste wants to merge 2 commits into
Marvisak:mainfrom
yumaste:perf/batch-descriptor-copy-mirrors
Open

yumaste wants to merge 2 commits into
Marvisak:mainfrom
yumaste:perf/batch-descriptor-copy-mirrors

Conversation

@yumaste

@yumaste yumaste commented Nov 26, 2026 •

Copy link
Copy Markdown

CopyDescriptorsSimple currently looks up the shader-visible destination heap and locks its pending queue separately for every descriptor. A contiguous, aligned copy into one heap now looks it up once. Pending indices are appended together. Initialized heaps use the existing sync_slots path in bounded batches to skip host slots whose record is already current. Ranges crossing heap boundaries or using a different stride retain the existing per-slot lookup.

An exact self-copy skips the guest byte write and still mirrors the destination, so records written directly into the heap can still become visible. Overlapping ranges with different starts still use memmove semantics. The change is shared across D3D12 adapters and adds no driver-specific defaults.

A synthetic 304-descriptor copy goes from 304 registry lookups to one on this path. The regression covers lazy heap initialization and verifies that a self-copy mirrors a new slot, clears a stale slot, and retains an occupied slot beyond the first batch. The full WARP GPU suite passed twice (247 passed, one ignored); strict Clippy passed. Scoped the existing test-only preparation hook to its own test thread after observing an unrelated test consume the hook during a parallel run. The new regression also passed on a physical NVIDIA RTX 5080 Laptop GPU with both PRs applied. AMD hardware validation remains open. No title files were used.

Inspired by reducing descriptor-store work and batching heap-record work in cool_fox.

@Dukestar69 Dukestar69 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.

Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):

  • Batching contiguous descriptor copies in mirror_copy under one SHADER_HEAPS lookup (with 256-slot sync_slots chunks and a clean fallback for cross-heap/mismatched-stride ranges) and making the test hook WHILE_PREPARING thread-local are clean and sound.
  • cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released (RTX 5090): 22 passed, 0 failed (including descriptor_copies_mirror_batched_slots_before_and_after_host_creation).
  • VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation -- --test-threads=1 (WARP): 1 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

vanya890 added a commit to vanya890/VIctory that referenced this pull request Nov 26, 2026
Port upstream Marvisak#3265: batch contiguous shader-visible descriptor mirroring with a single heap lookup, bounded sync batches, and the original per-handle fallback for cross-heap or incompatible ranges. Preserve overlapping-copy and self-copy semantics. Isolate the descriptor preparation test hook per thread.
@oni-swr

oni-swr commented Nov 26, 2026 •

Copy link
Copy Markdown

WARP verification report (test report only, no code changes)

  • PR head: 6c8fc754
  • main: 63bcca43 (control); WARP software adapter forced with VICTORY_WARP=1 VICTORY_D3D12_WARP=1, --features diagnostics, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, via VICTORY_DXIL).
  • Each new/changed test run in its own process (--exact), -j 4, synthetic tests only, no game data. Command: cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>.
  • New test descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation: passes on the PR (1 passed). The changed tests descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record and descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait also pass (1 passed each).
  • Control on main: the new test only uses existing APIs, so I ran it on main with only the test added. It also passes on main. It guards behaviour the change keeps (contiguous copies still mirror the same slots, and raw writes are picked up), not a bug on main, so it does not distinguish the two.
  • victory-gpu lib suite: PR 247 passed, 0 failed, 1 ignored (1 run); main 246 passed, 0 failed, 1 ignored. No failures.
  • Not tested: physical GPU. Not measured: the lock and lookup cost the change removes.

AI-assisted: verification by Claude Code (Claude Sonnet 5.5)

@Kajanos

Kajanos commented Nov 26, 2026

Copy link
Copy Markdown

This PR and #3055 merge cleanly but don't compile together. On main 63bcca4 + #3147 + #3047 + #3048 + #3258 #3274 #3061 #3248 #3246 + #3265 + #3055 + #3068:

error[E0599]: no method named `sync_slots` found for reference `&HostHeap` in the current scope
   --> crates\victory-gpu\src\descriptor.rs:201:34
201 |                             host.sync_slots(from, to, start, step);

#3055 replaces the runtime use of HostHeap::sync_slots with sync_ranges and leaves sync_slots under #[cfg(test)], while this PR adds a runtime call to it in descriptor.rs. Whichever lands second needs a rebase onto the other. Both batch heap syncs, so they may also overlap in intent. In that stack I kept #3055 and left this one out.

AI-assisted (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants