Repository navigation
GPU: wait before overwriting an in-flight texture staging buffer under VICTORY_LATE_WAIT/RELAY - #141
adritoyalser wants to merge 1 commit into
Conversation
Test of
|
| Run | Build | Switches | ms/frame (min-max) | fps | draws | preparing / GPU / copying back (ms) | card busy | waiting for the card | mesh groups | walls | grille |
|---|---|---|---|---|---|---|---|---|---|---|---|
| A1 | 4e17478 |
none | 292 (286-320) | 3.4 | 4,800 | 76 / 170 / 40 | 58% | 170 ms | 24,847 | missing | drawn |
| A2 | 4e17478 |
none | 295 (289-332) | 3.4 | 4,812 | 77 / 172 / 40 | 58% | 173 ms | 26,120 | missing | drawn |
| B1 | 4e17478 |
VICTORY_RELAY=2 |
220 (215-554) | 4.5 | 4,798 | 92 / 118 / 190 | 78% | 118 ms | 13,706 | missing | missing |
| B2 | 4e17478 |
VICTORY_RELAY=2 |
253 (244-276) | 3.9 | 4,892 | 95 / 146 / 219 | 81% | 147 ms | 15,617 | drawn | missing |
| C1 | 4e17478 |
late-wait set¹ | 182 (176-260) | 5.5 | 4,651 | 57 / 88 / 25 | 77% | 93 ms | 20,820 | drawn | drawn |
| P-A1 | f909bf0 |
none | 298 (292-631) | 3.4 | 4,779 | 77 / 177 / 40 | 59% | 177 ms | 22,897 | drawn | drawn |
| P-B1 | f909bf0 |
VICTORY_RELAY=2 |
278 (271-286) | 3.6 | 4,761 | 78 / 195 / 63 | 61% | 195 ms | 25,049 | missing | missing |
| P-B2 | f909bf0 |
VICTORY_RELAY=2 |
290 (267-315) | 3.5 | 4,844 | 76 / 208 / 64 | 64% | 207 ms | 25,824 | missing | missing |
| P-C1 | f909bf0 |
late-wait set¹ | 234 (218-262) | 4.3 | 4,790 | 57 / 142 / 26 | 67% | 144 ms | 25,388 | missing | missing |
¹ VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024
None of them logged an ERROR line or lost the device. Every run refused the same pipelines once at startup with 0x80070057: compute 02384a60fda6f2d0, 2cc4c197ee29e291, 2da4beb386509b77 and 369cbe906ea72764, and mesh f5e50eb2108c425b with pixel ce3f0432a08f1d35. The 4e17478 runs also refused compute 6b82bc7d22016cb5.
1. The walls are not restored, and here they are lost in default runs too
- Within a run the walls are either there in every captured frame or missing in every one.
- Missing looks the same as in RTX 4090 (Windows, native D3D12): RELAY=2 and the late-wait set are about 40% faster on 4e17478, and both lose the first room's walls #168: sky and horizon on the left, the posters as dark rectangles hanging in front of sky on the right, and the window frame standing on its own.
- Drawn means a dark block wall on the left and a wall with a photo poster on the right.
- Main: lost the walls in both default runs and in B1, and drew them in B2 and C1.
- This PR: drew them with defaults (P-A1) and lost them in all three late-mode runs.
- Warm-up runs (not in the table): agree. The main build's default run from the save lost the walls, and this PR's default run drew them.
With one or two runs per arm and walls missing in default runs too, this can't show that the PR makes the walls worse. It does show it doesn't bring them back.
The grille follows the switches more closely than the walls. It is missing in all four RELAY=2 runs and in P-C1, and drawn in every default run and in C1. Skin is present in every run. No subtitles were on screen in any captured frame, so I couldn't check the overlapping subtitles from #89.
2. The wait serializes the late submissions
The new wait is counted as "title memory read" in the settle lines. Compared with the same mode on 4e17478:
4e17478 |
f909bf0 |
|
|---|---|---|
RELAY=2: settles per frame |
3 | about 15 |
RELAY=2: waiting under "title memory read" |
9.5 ms/frame | 196 ms/frame |
| Late-wait set: settles per frame | 3 | about 18 |
| Late-wait set: flights per settle | 10.2 | 2.3 |
All of the waiting in settles is now under that reason.
GPU time per frame goes up and the card is less busy. With the PR, RELAY=2 runs at 278 to 290 ms against 292 to 298 ms on defaults, so almost all of its speed-up is gone.
The mesh group count also comes back to the default level, about 25,000 against 13,700 to 15,600 on 4e17478 with RELAY=2. That fits #168's point that part of the relay's speed-up was geometry that wasn't drawn. Under the late-wait set it rises from 20,800 to 25,400.
Test report written with Claude Code (Claude Opus 5.5), from real runs on the hardware named above. No game data attached.
|
Thanks for the thorough RTX 4090 benchmark @tycosnh! The settle breakdown pinpointed the exact performance bug in
Pushed a fix that:
That should eliminate the +48–52 ms/frame overhead on static textures while keeping the data-hazard protection (and note that #272 is also exploring a similar per-upload fence approach). |
…fxceless#141) fxceless#141 marked every texture a submission samples as in flight with it, and made each later submission that samples one of them wait for that flight before preparing, changed or not: most textures are sampled every frame, so late/relay submissions waited for each other (confirmed by review). Now only a list that records a copy from a staging buffer notes it (staging_copies, from texture::upload's copy path), and only those are marked in flight at submission. With the relay exact the wait moves to Staging::detile, which runs only when the texture's memory changed: the last flight that copies from the buffer lands first (host::staging_wait, a relay_wait, safe under the submission lock). Without the relay exact the settle before preparing stays, now for staging buffers a flight actually copies from. Test: the first list that uses a texture records the copy and notes its staging buffer; a later list that only samples the unchanged texture notes nothing but keeps its check at submission. It fails without the note. (cherry picked from commit 3907f191ce587aebd86a312c1909e720bfce544f) (cherry picked from commit b1d3e1c)
|
Merging this PR on top of main c96b4f2 (plus #115) conflicts in |
|
Rebased cleanly onto current |
d586d36 to
0afbcb5
Compare
8b64afb to
58ecb51
Compare
…r VICTORY_LATE_WAIT/RELAY Under `VICTORY_LATE_WAIT` / `VICTORY_RELAY`, a late submission can still be executing `CopyTextureRegion` from a `Staging` upload buffer on the GPU when a subsequent submission refreshes the same texture and detiles new contents into that mapped upload buffer. Track `Staging::in_flight` (the highest late submission number that actually recorded a `CopyTextureRegion` reading that staging buffer, via `Step::Texture(staging, uploads)`), and wait for that flight right before `Staging::detile()` overwrites the buffer. Unchanged textures and skipped uploads incur zero waits or settles.
…xceless#768) - fxceless#822: scale staging/shadow cache idle timeouts with commit limit as well as physical RAM - fxceless#903: add opt-in VICTORY_PLACED_TEX=1 64 MiB heap suballocator for placed host textures (default off; README untouched) - fxceless#886: let DirectStorage admit fitting reads from other queues into spare staging space - fxceless#768: add opt-in VICTORY_WIDE_TEXTURES=1 parallel texture refresh in Batch::flush (default off, preserving fxceless#141 in_flight guard)
Problem
Each title-written texture uses a single mapped
UPLOADheap staging buffer (Staging::buffer). UnderVICTORY_LATE_WAIT/VICTORY_RELAY,Host::submitcheckedlate_blocked(whether an earlier flight's shaders might write the texture's title memory), but did not check whether an earlier unfinished flight was still reading thatStaging::bufferon the GPU viaCopyTextureRegion.When two overlapping flights touch the same CPU-updated texture (such as subtitles, glyph atlases, or dynamic UI/video textures — see e.g. overlapping subtitles under
VICTORY_RELAY=2in #89),Staging::refresh→detilecould overwriteStaging::bufferon the CPU while the earlier flight's GPU copy was still reading it.Fix
Stagingbuffer (Staging::in_flightincrates/victory-gpu/src/texture.rs).Host::submit(crates/victory-gpu/src/host.rs), whenlateis enabled:runs, if anyStep::Texture(staging)hasstaging.in_flight() > FINISHED, wait until it lands (relay_waitunderVICTORY_RELAY=2,self.settleotherwise).staging.mark_in_flight(this_submission)when sending a late submission containingStep::Texture(staging).VICTORY_LATE_WAIT/VICTORY_RELAYare off, or when flights touch different textures.staging_in_flight_tracks_submission_completioninhost::late_tests.Verification
cargo clippy -p victory-gpu --all-targets --locked -- -D warnings— cleancargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings— cleancargo test -p victory-gpu --locked— 111 passed, 0 failed, 1 ignored