GPU: overlap CPU preparation with GPU execution via per-submission fences #3219
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!3219
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@danielibabet on GitHub · 2026-11-26 13:33 UTC · original
danielibabet:pr/cpu-gpu-overlap→main· +277 −77 · 11 files · 2 commits · closed without mergingSummary
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: clean@danielibabet on GitHub · 2026-11-26 13:39 UTC · original
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