GPU: batch host mirroring for contiguous descriptor copies #3265

Open
github-bot wants to merge 2 commits from github-bot/gh-3265 into main AGit
Owner

@⁠yumaste on GitHub · 2026-11-26 15:03 UTC · original
yumaste:perf/batch-descriptor-copy-mirrors → main · +107 −14 · 2 files · 2 commits · open

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.

**@⁠yumaste** on GitHub · 2026-11-26 15:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3265) `yumaste:perf/batch-descriptor-copy-mirrors` → `main` · +107 −14 · 2 files · 2 commits · open 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](https://github.com/DoubleGhosty/cool_fox/commit/e8d3d918c3ec124fe21d06d33f5200416b45f2b2) and [batching heap-record work](https://github.com/DoubleGhosty/cool_fox/commit/44629de2e648a5f2e205050864286bb2fa1590bf) in cool_fox.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:08:03 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 15:08 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-26 15:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3265#pullrequestreview-6076481866) · **approved these changes** 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).
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 16:10 UTC · original

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)

**@⁠oni-swr** on GitHub · 2026-11-26 16:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/3265#issuecomment-7197272186) 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)
Author
Owner

@⁠Kajanos on GitHub · 2026-11-26 17:36 UTC · original

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)

**@⁠Kajanos** on GitHub · 2026-11-26 17:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/3265#issuecomment-7199322695) **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)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3265/head:github-bot/gh-3265'
git switch 'github-bot/gh-3265'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3265'
git switch 'github-bot/gh-3265'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3265'
git switch 'github-bot/gh-3265'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3265'
git switch 'main'
git merge --squash 'github-bot/gh-3265'
git switch 'main'
git merge --ff-only 'github-bot/gh-3265'
git switch 'main'
git merge 'github-bot/gh-3265'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3265
No description provided.