GPU: list calls can translate on worker threads (VICTORY_DEFER_LISTS, opt-in) #3184
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3184
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3184"
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?
@AurumCarlos on GitHub · 2026-11-26 11:27 UTC · original
AurumCarlos:perf/defer-list-translation→main· +719 −14 · 6 files · 3 commits · openFirst step for #2586: record list calls on the title's threads and translate them on worker threads. Off by default;
VICTORY_DEFER_LISTS=<workers>turns it on.What it does
A list made while the variable is set gets method tables whose entries log the call instead of translating it (
crates/victory-gpu/src/list/later.rs). The title's thread copies the arguments, including what they point to (barriers, viewports, scissors, constants, copy locations, rectangles, clear values, heaps, vertex views, render target handles, barrier group headers), and goes on. Workers take the log in batches of 32 and run the existing methods, unchanged, in the order the title made the calls. Each list is translated by one worker at a time, and different lists in parallel.Lists made without the variable keep today's tables, so the default path does not change. Every entry still calls the same functions.
What stays on the title's thread:
QueryInterface, upload memory (0x4a0), driver hints;Reset,ResetXand the lastRelease, which first wait for the list's logged calls. They free what those calls read: upload memory, the draw state and the host lists;ExecuteCommandListswaits for its lists before it takes the held-work lock, so other queues are not held up meanwhile.crate::external::{host_texture, record}(host libraries recording into a title list) wait too.Translation now reads title memory (descriptors, buffers, textures) after the call instead of during it, but still before the submission. On the console the GPU reads it even later, when the list runs, so a title cannot depend on the earlier read.
The 5-second report gets one line when the variable is set: calls translated by workers per frame, and how long title threads waited for them.
Tests
list::later::tests::each_log_runs_its_calls_in_order_on_workers: four logs filled at once. Each runs its calls in order, none on the logging thread, all of them by the time it settles.resource::tests::deferred_lists_waiting_for_another_queues_write_read_what_it_wrote: the existing two-queue test (wait, write, copies) with deferred lists. It calls through the tables as a title does. After the copy call it clears the copy location it passed, so the test fails if an argument is read later instead of copied (checked: it fails with the copy removed).every_inline_command_falls_back_to_the_tablenow resets through the table, as a title does. It calledresetdirectly whileClosewent through the table, so with deferred lists the reset ran before the logged Close.Run on an RX 9070 XT, Wine 11.22 (staging) with vkd3d-proton 3.1, cross-built for
x86_64-pc-windows-gnu:cargo test -p victory-gpu --lib: 201 passed. The same 30 tests fail onmain(63bcca4) in this environment and pass or fail identically on this branch.VICTORY_DEFER_LISTS=4, so every list in every test is deferred: 200 passed, same 30 failures. Three tests are left out:pipeline::depth_bounds_test: records on the host list directly between table calls and submits it itself, which a deferred list cannot support. The title cannot do this.frame::waits_end_on_ticks_and_count_frames: timing-sensitive. Passes alone with and without deferral.queue::aliased_present_planes_preserve_the_host_texture_state: hangs under Wine onmaintoo.cargo clippy -p victory-gpu --lib --tests -D warnings(Windows target, with and withoutdiagnostics),cargo xtask policy.Numbers
The benchmark from #2820 (
list_calls: 5 threads, about 8,300 calls each per frame, release), on this branch. I added a timer around its submit-and-wait locally (not part of this PR). Same machine as above. Median of 5 runs, ms per frame:What it shows:
DrawIndexedInstancedon the title's thread goes from about 3.8 µs to about 0.1 µs. Title-thread CPU time drops by 50-65%.main, the wall time does not follow. The descriptor writes that stay on the title's thread (CreateConstantBufferView, a device method) now wait for the workers on the locks #2820 found: 1.0 µs to 4.3 µs per call. With #2821, which removes those waits, title-thread time drops 45% at every worker count.During measurements, one benchmark run through
cargo testhung until its timeout, before the submission fix above. It did not happen again in 50 later runs (2, 4, 6 and 8 workers), and I have no explanation for it.Not done here
No game data. AI-assisted (Claude Code).
🤖 Generated with Claude Code
@Dukestar69 on GitHub · 2026-11-26 12:09 UTC · original · approved these changes
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib list:: -- --test-threads=1: 5/5 passed (includinglist::later::tests::each_log_runs_its_calls_in_order_on_workers).cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Clean opt-in
VICTORY_DEFER_LISTSworker-thread translation for command list calls.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@steven-seagull27 on GitHub · 2026-11-26 12:14 UTC · original
I ran the two-queue fixture on native Windows at
768dcfa0, using an RTX 5080 and Windows' built-in WARP with the D3D12 debug layer. I expanded the pre-wait copy into 261 overlapping 8-byte writes through the title's command-list table. This crosses eight 32-call batch boundaries and leaves five writes in the final partial batch.VICTORY_DEFER_LISTS014Each setting gave the same result in two fresh processes per adapter. The pre-wait check observes VIctory's submission-time host-buffer copies. The separate texture check observes the graphics queue's write after the wait. Before the graphics submission, all 1,024 destination bytes still held the sentinel and the flag was 0. After submission, the flag was 1 and all four 16-byte rows matched. Omitting only the last five copies in a local control produced exactly 40 wrong pre-wait bytes on each adapter.
The existing
aliased_present_planes_preserve_the_host_texture_statetest also completed on both native Windows adapters with four workers selected. I haven't measured game frame times.Test-only commit on this PR head. To rerun it in PowerShell, choose
0,1, or4for the worker count and0(hardware) or1(WARP) for the adapter, then run:@AurumCarlos on GitHub · 2026-11-26 12:30 UTC · original
The check failure on
3b148e1is not from this change. The one failing test isframe::tests::waits_end_on_ticks_and_count_framesin victory-gpu (frame.rs:231): with 2 ms ticks, a zero-timeout poll right after a wait gotS_OKinstead ofTIMEOUTbecause the next tick had already passed on the runner. This PR doesn't touchframe.rs, the new commit only adds tests inresource.rs, and the previous head (768dcfa) passed. A re-run should clear it.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.