GPU: overlap CPU preparation with GPU execution via per-submission fences #3217
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3219"
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?
Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-26T13:33:50Z.
Summary
Overlap CPU preparation with GPU execution by splitting
Host::executeinto a non-blocking submit and a deferredcopy_back. This addresses theshortcutnoted inhost.rs: "every submission is waited for, so CPU and GPU never overlap".Problem
Host::executecalledExecuteCommandLists, then immediately signalled the fence and blocked withWaitForSingleObject(INFINITE)before returning. At ~1.5 fps with ~500 ms of GPU work per frame, the CPU spent essentially the entire frame idle waiting for the GPU.Solution
Two-phase submit:
Host::execute— submits the command lists, signals the fence, returns immediately with aSubmissionDatatoken (fence value + batch data). CPU continues preparing the next submission.Host::copy_back— waits for the fence, then performs all shadow/BOP writes back to title memory. Called at the start of the next submission, so the GPU runs frame N while the CPU prepares frame N+1.A new
COPY_BACK_WAIT_USatomic exposes the residual fence wait time as awaiting GPUfield in the fps log line.The texture
recycle()call was moved frombindless::uploads()(before execute) intocopy_back()(after fence wait), so staging chunk memory is released strictly post-GPU and hash comparison always sees the final post-GPU state of title memory — preventing spurious full-texture invalidations.Measured results (i9-14900KF + RTX 4070, GTA VI world)
The
waiting GPUfield replaceson the GPUas the measure of GPU execution time. The overlap benefit is currently limited by the GPU execution time (~450 ms) dominating CPU preparation (~90 ms); the CPU finishes preparing before the GPU finishes executing, so the overlap window is not fully exploited. Further gains require reducing GPU execution time (more pipelines compiled, indirect dispatch fixes).Tests
cargo test --workspace: 233 passed, 2 pre-existing failures onmainunrelated to this changecargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warningscargo run -p xtask -- policy: 192 files OKcargo build --release -p victory --locked: cleanImported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-26T13:39:41Z.
Closing after review: \pump()\ still calls \copy_back()\ (and blocks on \wait_for()) before the next \xecute(), so CPU preparation does not overlap with GPU execution yet, and #3120 already covers submission overlap. Keeping #3218 open as a focused change.
Pull request closed