Batch per-draw shadow refresh deferral under one lock #33

Open
github-bot wants to merge 1 commit from github-bot/gh-33 into main AGit
Owner

@⁠Adika713 on GitHub · 2026-11-25 19:57 UTC · original
Adika713:perf/dexnom-refresh-batch → main · +132 −9 · 3 files · 1 commits · open

Batch per-draw shadow refresh deferral under one lock.

Every vertex and index buffer range a draw bound called Shadow::refresh,
which took the list's deferred-work mutex once per range. A draw now collects
its ranges and calls defer_refreshes() once. Repeated ranges are still
deduplicated, and the early return for a missing index buffer still defers the
vertex ranges already collected.

What is in it

  • Shadow::refresh_params() returns the clamped range refresh() would defer.
  • HostList::defer_refreshes() takes the deferred lock once for all ranges;
    defer_refresh() delegates to it.
  • draw.rs collects vertex and index ranges, skips the empty case, and keeps
    the existing order of deferred steps.
  • A regression test comparing batched steps with one call per range, and an
    ignored CPU-only A/B benchmark.

Tested

AMD Radeon RX 6950 XT (RDNA2), Ryzen 5 3600, 32 GB RAM, Windows 11,
rustc/cargo 1.98.1. No game data; the game was not run. Isolated
CARGO_TARGET_DIR. BCPack format tables were installed locally with
Initialize-FormatTables.ps1 and were not committed.

cargo test --release -p victory-gpu --lib defer_refresh_batching -- --ignored --nocapture --test-threads=1,
3 runs, median per range over 5 samples:

  • one call per range: 52.7 / 48.0 / 48.3 ns
  • batched: 31.4 / 30.6 / 30.3 ns

Correctness:

  • cargo check -p victory-gpu --lib --tests --locked: exit 0.
  • cargo test -p victory-gpu --lib host::tests::defer_refreshes_matches_one_call_per_range -- --test-threads=1:
    1 passed, 0 failed, 192 filtered.
  • draw::: 7 passed; shadow::: 22 passed; host::: 52 passed, 0 failed,
    2 ignored (serial).
  • Full victory-gpu lib, 20 serial runs: 0 failed; each 189 passed,
    0 failed, 4 ignored, 0 filtered.
  • cargo test --workspace --no-fail-fast --locked: one first run hit the
    timing-sensitive frame::tests::waits_end_on_ticks_and_count_frames failure;
    that test then passed 5/5 serial runs and the workspace rerun had 0 failed
    suites.

Not tested

  • In-game FPS. No game files or paths were supplied, so this makes no claim
    about frame rate.
  • NVIDIA hardware.
  • Concurrent recording and submission of the same list; the deferred work
    keeps the existing list-lifetime rule.

AI use

AI-assisted: OpenCode, model Big Pickle. No game data.

**@⁠Adika713** on GitHub · 2026-11-25 19:57 UTC · [original](https://github.com/DexNom/VIctory/pull/33) `Adika713:perf/dexnom-refresh-batch` → `main` · +132 −9 · 3 files · 1 commits · open Batch per-draw shadow refresh deferral under one lock. Every vertex and index buffer range a draw bound called `Shadow::refresh`, which took the list's deferred-work mutex once per range. A draw now collects its ranges and calls `defer_refreshes()` once. Repeated ranges are still deduplicated, and the early return for a missing index buffer still defers the vertex ranges already collected. **What is in it** - `Shadow::refresh_params()` returns the clamped range `refresh()` would defer. - `HostList::defer_refreshes()` takes the deferred lock once for all ranges; `defer_refresh()` delegates to it. - `draw.rs` collects vertex and index ranges, skips the empty case, and keeps the existing order of deferred steps. - A regression test comparing batched steps with one call per range, and an ignored CPU-only A/B benchmark. **Tested** AMD Radeon RX 6950 XT (RDNA2), Ryzen 5 3600, 32 GB RAM, Windows 11, rustc/cargo 1.98.1. No game data; the game was not run. Isolated `CARGO_TARGET_DIR`. BCPack format tables were installed locally with `Initialize-FormatTables.ps1` and were not committed. `cargo test --release -p victory-gpu --lib defer_refresh_batching -- --ignored --nocapture --test-threads=1`, 3 runs, median per range over 5 samples: - one call per range: **52.7 / 48.0 / 48.3 ns** - batched: **31.4 / 30.6 / 30.3 ns** Correctness: - `cargo check -p victory-gpu --lib --tests --locked`: exit 0. - `cargo test -p victory-gpu --lib host::tests::defer_refreshes_matches_one_call_per_range -- --test-threads=1`: 1 passed, 0 failed, 192 filtered. - `draw::`: 7 passed; `shadow::`: 22 passed; `host::`: 52 passed, 0 failed, 2 ignored (serial). - Full `victory-gpu` lib, 20 serial runs: 0 failed; each 189 passed, 0 failed, 4 ignored, 0 filtered. - `cargo test --workspace --no-fail-fast --locked`: one first run hit the timing-sensitive `frame::tests::waits_end_on_ticks_and_count_frames` failure; that test then passed 5/5 serial runs and the workspace rerun had 0 failed suites. **Not tested** - In-game FPS. No game files or paths were supplied, so this makes no claim about frame rate. - NVIDIA hardware. - Concurrent recording and submission of the same list; the deferred work keeps the existing list-lifetime rule. **AI use** AI-assisted: OpenCode, model Big Pickle. No game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:32:14 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/33/head:github-bot/gh-33'
git switch 'github-bot/gh-33'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-33'
git switch 'github-bot/gh-33'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-33'
git switch 'github-bot/gh-33'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-33'
git switch 'main'
git merge --squash 'github-bot/gh-33'
git switch 'main'
git merge --ff-only 'github-bot/gh-33'
git switch 'main'
git merge 'github-bot/gh-33'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.