Defer one draw's buffer refreshes under one lock #155
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!155
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-155"
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?
@Adika713 on GitHub · 2026-11-25 17:42 UTC · original
Adika713:perf/refresh-batch→main· +114 −11 · 3 files · 1 commits · openSTATUS: pending publication.
Defer the buffers of one draw under a single lock.
draw::State::prepare_forcalledShadow::refreshonce per vertex and indexbuffer. Each call took the host list's deferred-work mutex just to insert one
range. The ranges are now collected while building the views and deferred in
one call, preserving their order and deduplication.
What is in it
HostList::defer_refreshestakes one lock for a slice of ranges;defer_refreshdelegates to it.Shadow::refresh_paramsexposes the clamping already done byrefresh,so
prepare_forcan collect ranges without deferring them one by one.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.cargo test --release -p victory-gpu --lib defer_refresh_batching -- --ignored --nocapture --test-threads=1,3 runs, median of 5 samples, per range:
Correctness:
cargo check -p victory-gpu --lib --tests --locked: exit 0.cargo test -p victory-gpu --lib host:: -- --test-threads=1: 21 passed, 0 failed, 2 ignored, 94 filtered.cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 1 passed, 0 failed, 116 filtered.victory-gpulib, 20 serial runs with the pre-existing #102 flake skipped: 0 failed; each 111 passed, 0 failed, 5 ignored, 1 filtered.cargo test --workspace --no-fail-fast --locked: no new failures. Known xmem and policy failures remain; the two known shader failures did not recur in this run.victory-gpu112 passed, 0 failed, 5 ignored.Not tested
about frame rate.
draw.rs; if both land, thathunk needs rebasing. PR #139 adds a
keepcall before anothershadow.refreshsite; no overlapping line was changed here.AI use
AI-assisted: OpenCode, model Big Pickle. No game data.
@KernelSmoker on GitHub · 2026-11-25 17:50 UTC · original
Tested PR head
65c671aon Bazzite Linux 45, NVIDIA GeForce RTX 3090 (host driver 620.73.04), GE-Proton 10-34 / Wine 10.0 and vkd3d-proton 3.0.0.The correctness test
host::tests::defer_refreshes_matches_one_call_per_rangepassed under Proton (1 passed, 0 failed). I also ran the ignored release A/B benchmark under Proton, with the host GPU initialized, one run of five samples:The batching was about 36% lower in this Proton run. These timings are Proton-specific and should not be compared directly with the PR's native Windows measurements or treated as an in-game FPS result.
@adrianmjim on GitHub · 2026-11-25 18:57 UTC · original
Measured head
65c671aon an RX 7900 XT, Windows 11 build 26300, Rust 1.98.1, release build, separate target dir. I did not run the game.KernelSmoker's Proton run, and mine here, reproduce the direction of
defer_refresh_batching. Here it gives 25-36 ns per range one at a time against 17-29 ns batched. However, the benchmark does not measure whatprepare_fornow does:list.defer_refresh, is this PR's version. That version goes throughdefer_refreshes(&[(shadow.clone(), ..)])and clones theArcon every call. main clones only when a range is new to the list.rangesvector is built once, outside the timed loop. Inprepare_for, every draw now allocates aVecand clones and drops anArcfor each buffer.I added a local ignored test that times the whole per-draw path for ranges already deferred in the list, i.e. the same buffers drawn again. It is single-threaded, and each figure is the median of 7 samples. The ranges below come from 6 runs, on a machine with other jobs running:
Shadow::refresh, per bufferdefer_refreshesIn every run, the collected path was slower than main for each buffer count. So the gain in the description comes from how the benchmark is set up; on this path the PR costs more per draw. I did not measure ranges deferred for the first time in a list, or several recording threads at once.
If the lock itself is the cost, a possible variant: keep
defer_refreshas on main, and move theArcthatshadow::findreturns into a fixed-size array on the stack (32 vertex buffers plus the index buffer) once the view is built. That avoids both the allocation and the extra clones.Tests:
victory-gpulib gives 112 passed, 0 failed in parallel. Serial runs hit only the knownframe::waits_end_on_ticks_and_count_framesand #102 watch flakes.@MamaLeVrai on GitHub · 2026-11-26 05:11 UTC · original
Concurrency check on Windows/RDNA2 (RX 6950 XT, Windows 11 build 26300, Rust 1.98.1). I merged this PR (
65c671a) ontomain4f62c2aplus #210, which fixeslist::tests::lists_are_cut_at_waits_that_follow_work, a test that fails in every release run onmain. Then I ran the releasevictory-gpulib test binary 10 times, with the default thread count:watch::tests::written_pages_are_reported_to_every_asker(#102), and 1 run died without a result line.No new failure, deadlock or hang showed up in these runs. Ten runs are a small sample for races. Not run in the game.
harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300
AI-assisted (Claude Code); no game data.
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.