Repository navigation
Conversation
A table's constant buffer view whose title memory a flight in the air may write is filled into upload memory at submission, which makes the submission wait for the flight to land: in the world, one such buffer a frame (480-512 bytes) cost a wait of 52-80 ms. With VICTORY_FILL_ON_CARD (on by default; 0 fills as before) the list copies those bytes from the host copy on the card, behind the flight on the same queue, into a device-local buffer of its own, and binds that instead. The first fills that still wait are logged with their source. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
|
RTX 5080 (driver 621.24), Ryzen 7 5700X3D, Windows 11: no change here. The fill that waits is in a list recorded before the flight that writes its range is sent, so Setup
AI-assisted (Claude Code). |
|
Follow-up from the same RTX 5080, in case it helps with the "ranges flights wrote lately" follow-up. Fork main
AI-assisted (Claude Code). |
|
Tested on an RTX 2080 SUPER 8 GB (Turing) + i9-9900, Windows 11, Series X profile, first gameplay scene standing still, relay stage 2, 256 lists, card copies 1 MiB–1280 MB, and It removes the wait it targets. To see what a submission waits for, I log per 5 s the read that waited, the declaration in the way and the shader that declared it. Before this PR, every frame:
So it is the same single table CBV you found, behind a table UAV that covers the whole 182 MB buffer. With this PR that line is gone. On this machine the wait then moves to the next reader of the same buffer, so the frame time does not improve:
That is a title buffer-to-buffer copy ( So for this scene the fix would need to cover title buffer copies whose source is a card copy as well, for example by doing the copy on the card in queue order, like the fill here, instead of on the CPU after the flight lands. The root of it is the declaration: the UAV view spans the whole 182 MB, while the GPU really changes about 3–4 MB of that buffer per frame. Happy to test a follow-up on this card. Measured and written with AI assistance (Claude Code, Claude Opus 5.5). |
|
Data point from an RTX 3080 (10 GB, wave32) supporting this approach. I did not test this PR's code itself, but my own implementation of the same idea (aligned table CBVs bound on the card copy as in #144, unaligned ones copied on the card in the list's prelude), on fxceless main 8dd30ab with
Also, for 10 GB cards: with the new defaults (card copies up to 1 GB), VRAM is full (10.0/10 GB), card copies can't be allocated (1 copy, 174 MB) and the CPU compare doubles (725 MB/frame); (Measured and written with Claude Code, Claude Opus 5.5.) |
- fxceless#860 (a544813): fingerprint fill_ahead reads so title rewrites do not permanently trip global fill waits, hold back only affected 64 KiB pieces (up to 8), log depth UAVs once per view, and fix VICTORY_CARD_ROOM_FOR_BUFFERS doc - fxceless#462: add opt-in VICTORY_FILL_ON_CARD=1 (off by default) HostList::card_constants path in draw.rs/host.rs when aligned direct shadow bind (fxceless#144) does not apply
What's wrong
With the late wait (
VICTORY_RELAY=2), a submission that copies title memory into its upload memory (a constant buffer view of a descriptor table, filled at submission) must wait until every flight that may write that memory has landed: the copy is a CPU read of title memory, and the bytes are not there until the flight's copy-back.In the world this happens once a frame, for one table constant buffer of 480–512 bytes. On an RTX 4070 that one wait costs 52–80 ms a frame (median 67 ms), measured with the relay's wait counters and an in-process sampler. The submitting thread is the frame's critical path, so the whole wait shows in the frame time.
Fix
When a table's constant buffer view reads title memory that a flight in the air may write (
flights_write), the list no longer defers a fill of upload memory. At recording it:HostList::card_constants, 256-byte slots), with a UAV barrier before it and a transition toVERTEX_AND_CONSTANT_BUFFERafter it, and binds the view there.Because the list runs behind the flight on the same queue, the card copy reads what the flight's shaders wrote, with no CPU wait. Title writes to that memory reach the host copy first, through the refresh. Root constant buffers and buffer-to-texture sources keep the old path; in the world they did not wait.
VICTORY_FILL_ON_CARD=0restores the old path. The first fills that still wait are logged with their source range and host copy.Measurement (RTX 4070 12 GB, Windows 11, world, warm cache)
Paired within one run: the switch turned off (A) and on (B) by turns, 4 frame-rate lines (~20 s) per arm, from the moment the world is steady. The first line after each turn is left out. Same scene, cache and temperature for both arms. Base: our test branch (fork main + #38, #63, #71, #147, #154, #255, #270, #348), with
VICTORY_RELAY=2.Arm medians over the measured lines: A 271.7 ms, B 221.5 ms.
Image: four A→B turns, comparing the last PNG of A with the first PNG of B (7.1–7.6 s apart):
The difference is the camera and characters moving, not the switch. No missing or black geometry in B.
Card test:
fill_on_card_tests::constants_filled_on_the_card_read_what_the_card_wroteruns on the hardware adapter and on WARP (VICTORY_D3D12_WARP=1):Limits
VICTORY_RELAY/VICTORY_LATE_WAITnothing is in the air at recording and nothing changes.cargo clippy -p victory-gpu --all-targets -- -D warnings(with and withoutdiagnostics) is clean;cargo test -p victory-gpu --features diagnostics --libpasses 120/120 (1 ignored) on a803c87 + this commit.AI-assisted (Claude Code); measured on real hardware in the game's world.