GPU: the title's submissions return before the host GPU has run them #3120

Open
github-bot wants to merge 3 commits from github-bot/gh-3120 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 08:51 UTC · original
0xkn0wh3r3:gpu/submission-overlap → main · +911 −141 · 8 files · 3 commits · open

ExecuteCommandLists no longer waits for the host GPU. The title's lists go to the host queue with a Signal of the host fence, and the call returns. The submission completes later: what shaders wrote goes back to title memory, then the lists' work after them and their bottom-of-pipe writes, then the title fences its queue signalled behind it. A completion thread completes each submission once the GPU has run it, so a title's fence moves, and its waits end, without any call from the title, as on the console. A title that keeps frames in flight now gets them: it records the next frame while the GPU runs the last.

This is phase 2 of docs/submission-overlap.md (on the demo branch), widened to more than one submission in flight wherever nothing needs the earlier ones done first.

What still waits

A submission completes the ones it needs before it is prepared. The wait is for the host fence, with the submission lock released, so the completion thread and other submitting threads go on.

  • Completion writes title memory or takes write marks: declared shader writes (copy-backs), title memory through page tables, missed-read checks, work after the lists, bottom-of-pipe writes, or marks together with heap indexing. Such a submission completes before the next is prepared, because the next one's refreshes and copies read title memory and its shaders mark in the same bitmaps.
  • Title copies and work that write title memory on the CPU (for the GPU's timeline) wait for everything before them.
  • The upload list waits for its own last run, and a host list waits for its own previous run.

So only submissions without such writes overlap for now. Snapshots and bitmaps per submission (the plan's phase 3) would lift that. Read marks are taken by any completion that bound them; taken early, they only make views early.

Other changes

  • A queue's Signal behind work in flight is owed by that queue's last submission and set when it completes, in order, under the submission lock.
  • A blocking fence wait (SetEventOnCompletion with no event) now blocks until the value is reached instead of returning E_NOTIMPL.
  • Present copies into the swap chain from a ring of three lists and does not wait for the frame. The swap chain has three buffers: with two, the queue stalled until the shown buffer was let go. A resize, multi-plane composition and diagnostics read-backs still wait for what they need.
  • Host textures given up by eviction, and resources retired while work is in flight, are released once the next submission has completed.
  • The once-a-frame eviction pass first takes the read marks of submissions still in flight, as their completion would, before it clears every mark.
  • A title list reset while its host list is still in flight keeps what it owned until that host list is reset, rather than as work run after the list.
  • VICTORY_GPU_OVERLAP=0 waits for each submission as before. Per-list timing (VICTORY_GPU_TIMING) and capture-listed frames wait too.

Measured

cargo demo (the conformance title's window, 2560x1440), RTX 5070 Ti, Windows 11, on the user's demo branch with this merged. The comparison is the same build with VICTORY_GPU_OVERLAP=0, steady 5 s windows:

overlap off overlap on
scale 4 (207 draws, 4 submissions a frame): frame rate 31.0 fps (32.3 ms) 60.0 fps (16.7 ms, held to the title's 60 Hz frame tick)
scale 4: ExecuteCommandLists a frame 29.6 ms 0.36 ms
scale 4: VIctory a frame 32.3 ms 2.1 ms
scale 4: waiting for the frame tick 0 ms 14.6 ms
scale 32 (1,999 draws, 32 submissions a frame): frame rate 13.5 fps 58.4 fps
scale 32: ExecuteCommandLists a frame 66.2 ms 3.1 ms

With overlap off, each scale-4 submission spent 5.9 ms waiting for the GPU. Before the swap chain went to three buffers, the overlapped build ran at about 31 fps: ExecuteCommandLists took 0.9 ms a frame, and the wait had moved into "waiting for a frame in flight" (13–16 ms) and present.

Tests

  • New: a submission held at a GPU gate returns from ExecuteCommandLists, and both its fence and its copy into a title buffer move only once it has completed. A blocking fence wait then ends.
  • Tests that read results straight after ExecuteCommandLists now wait for a fence as a title does. Tests that submit through title queues hold a shared lock, so a test holding the GPU finds no other test's work in flight.
  • cargo test -p victory-gpu --lib, in parallel and single-threaded: everything passes except dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, which fail the same way on main here (the host's view heap is smaller than HEAP_VIEWS). frame::tests::waits_end_on_ticks_and_count_frames is timing-flaky on main too.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --features victory-gpu/diagnostics.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 08:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/3120) `0xkn0wh3r3:gpu/submission-overlap` → `main` · +911 −141 · 8 files · 3 commits · open ExecuteCommandLists no longer waits for the host GPU. The title's lists go to the host queue with a Signal of the host fence, and the call returns. The submission completes later: what shaders wrote goes back to title memory, then the lists' work after them and their bottom-of-pipe writes, then the title fences its queue signalled behind it. A completion thread completes each submission once the GPU has run it, so a title's fence moves, and its waits end, without any call from the title, as on the console. A title that keeps frames in flight now gets them: it records the next frame while the GPU runs the last. This is phase 2 of `docs/submission-overlap.md` (on the `demo` branch), widened to more than one submission in flight wherever nothing needs the earlier ones done first. ## What still waits A submission completes the ones it needs before it is prepared. The wait is for the host fence, with the submission lock released, so the completion thread and other submitting threads go on. - **Completion writes title memory or takes write marks:** declared shader writes (copy-backs), title memory through page tables, missed-read checks, work after the lists, bottom-of-pipe writes, or marks together with heap indexing. Such a submission completes before the next is prepared, because the next one's refreshes and copies read title memory and its shaders mark in the same bitmaps. - **Title copies and work that write title memory on the CPU** (for the GPU's timeline) wait for everything before them. - **The upload list** waits for its own last run, and a host list waits for its own previous run. So only submissions without such writes overlap for now. Snapshots and bitmaps per submission (the plan's phase 3) would lift that. Read marks are taken by any completion that bound them; taken early, they only make views early. ## Other changes - A queue's Signal behind work in flight is owed by that queue's last submission and set when it completes, in order, under the submission lock. - A blocking fence wait (SetEventOnCompletion with no event) now blocks until the value is reached instead of returning E_NOTIMPL. - Present copies into the swap chain from a ring of three lists and does not wait for the frame. The swap chain has three buffers: with two, the queue stalled until the shown buffer was let go. A resize, multi-plane composition and diagnostics read-backs still wait for what they need. - Host textures given up by eviction, and resources retired while work is in flight, are released once the next submission has completed. - The once-a-frame eviction pass first takes the read marks of submissions still in flight, as their completion would, before it clears every mark. - A title list reset while its host list is still in flight keeps what it owned until that host list is reset, rather than as work run after the list. - `VICTORY_GPU_OVERLAP=0` waits for each submission as before. Per-list timing (`VICTORY_GPU_TIMING`) and capture-listed frames wait too. ## Measured `cargo demo` (the conformance title's window, 2560x1440), RTX 5070 Ti, Windows 11, on the user's `demo` branch with this merged. The comparison is the same build with `VICTORY_GPU_OVERLAP=0`, steady 5 s windows: | | overlap off | overlap on | |---|---|---| | scale 4 (207 draws, 4 submissions a frame): frame rate | 31.0 fps (32.3 ms) | 60.0 fps (16.7 ms, held to the title's 60 Hz frame tick) | | scale 4: ExecuteCommandLists a frame | 29.6 ms | 0.36 ms | | scale 4: VIctory a frame | 32.3 ms | 2.1 ms | | scale 4: waiting for the frame tick | 0 ms | 14.6 ms | | scale 32 (1,999 draws, 32 submissions a frame): frame rate | 13.5 fps | 58.4 fps | | scale 32: ExecuteCommandLists a frame | 66.2 ms | 3.1 ms | With overlap off, each scale-4 submission spent 5.9 ms waiting for the GPU. Before the swap chain went to three buffers, the overlapped build ran at about 31 fps: ExecuteCommandLists took 0.9 ms a frame, and the wait had moved into "waiting for a frame in flight" (13–16 ms) and present. ## Tests - New: a submission held at a GPU gate returns from ExecuteCommandLists, and both its fence and its copy into a title buffer move only once it has completed. A blocking fence wait then ends. - Tests that read results straight after ExecuteCommandLists now wait for a fence as a title does. Tests that submit through title queues hold a shared lock, so a test holding the GPU finds no other test's work in flight. - `cargo test -p victory-gpu --lib`, in parallel and single-threaded: everything passes except `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`, which fail the same way on `main` here (the host's view heap is smaller than `HEAP_VIEWS`). `frame::tests::waits_end_on_ticks_and_count_frames` is timing-flaky on `main` too. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--features victory-gpu/diagnostics`.
ExecuteCommandLists no longer waits for the host GPU. A submission's
lists go to the host queue with a Signal of the host fence, and the
title's call returns; the submission completes later (what shaders
wrote goes back to title memory, then the lists' work after them and
bottom-of-pipe writes, then the title fences its queue signalled behind
it). A completion thread completes each submission once the GPU has run
it, so a title's fence moves and its waits end with no call of its own,
as on the console. A title that keeps frames in flight now gets them:
it records the next frame while the GPU runs the last.

What still needs a submission done first completes it first, waiting
without the submission lock:
- a submission whose completion writes title memory or reads the marks
  bitmaps (copy-backs, write and read marks, title memory through page
  tables, work after its lists, bottom-of-pipe writes) completes before
  the next is prepared, whose refreshes read title memory;
- title copies and work that write title memory on the CPU for the GPU's
  timeline wait for everything before them;
- the upload list waits for its last run, and a host list for its own.
So only submissions without such writes overlap for now
(docs/submission-overlap.md, phase 3, would lift that with
per-submission snapshots and bitmaps).

- A queue's Signal behind work in flight is owed by the queue's last
  submission and set when it completes, in order.
- A blocking fence wait (SetEventOnCompletion with no event) now blocks
  until the value is reached instead of failing.
- Present copies into the swap chain with a ring of three lists and does
  not wait for the frame; a resize, multi-plane composition and
  diagnostics read-backs still wait for what they need.
- Host textures given up and resources retired while work is in flight
  are released after the next submission completes.
- A list reset while a queue still runs it keeps what it owned until its
  host list is reset, not as work after the list.
- VICTORY_GPU_OVERLAP=0 waits for each submission as before; per-list
  timing and listed capture frames do too.

Tests: a submission held at a GPU gate returns, and its fence and its
copy into a title buffer move only once it has completed; tests that read
results after ExecuteCommandLists now wait for a fence as a title does.
Every list the conformance title's frame records binds the views'
bitmaps (its shaders mark the views they read), so each submission was
completed before the next was prepared and the title's ExecuteCommandLists
still waited for the GPU (23 of 25 ms a frame).

Only write marks need that: taken by an earlier submission's completion
while a later one still writes, they would go back early and be lost to
it. Writes through tables and root views are declared per list, so a list
marks writes only through the heap's views. A list counts as heavy for
marks only with heap indexing; write marks are taken only at the
completion of a heavy (or waited-for) submission. Read marks are taken by
any completion that bound them: taken early, they only make views early.

A present no longer waits for its frame, and with two swap chain buffers
the queue stalled until the shown one was let go (the frame rate stayed
at about 31). Three let the next frame be drawn meanwhile.

Waits for submissions in flight count in the frame-rate line's GPU wait.
The once-a-frame eviction pass clears every read mark of the views'
bitmaps (`shadow::reads_since`), which it ran after the previous
submission's completion had taken them (`shadow::take_reads`). With that
submission still in flight, its marks were cleared before it completed:
a null view only it reads would never be made. The pass now takes them
first, as the completion would, and makes their views.

The bitmaps' safety notes say which marks are taken while a submission
may still set more (read marks: a later call takes them) and which only
with none in flight (write marks, page read marks).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:52:06 +00:00
This pull request can be merged automatically.
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/3120/head:github-bot/gh-3120'
git switch 'github-bot/gh-3120'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3120'
git switch 'github-bot/gh-3120'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3120'
git switch 'github-bot/gh-3120'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3120'
git switch 'main'
git merge --squash 'github-bot/gh-3120'
git switch 'main'
git merge --ff-only 'github-bot/gh-3120'
git switch 'main'
git merge 'github-bot/gh-3120'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3120
No description provided.