Descriptors: every slot of a table a draw binds counts as a table's slot (VICTORY_TABLED_ALL=1, off by default): 84-96 -> 55-59 ms a frame in the prologue's cell #1414
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1414
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1414"
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?
@KyleS98 on GitHub · 2026-11-26 23:58 UTC · original
KyleS98:perf/tabled-table-slots→main· +557 −15 · 3 files · 6 commits · openSummary
One opt-in switch,
VICTORY_TABLED_ALL=1(off by default): the pass over records the title copied into its heap as bytes leaves every slot of a table a draw binds to its draws, whatever the slot holds, and not only the slots that hold texture views.VICTORY_TABLED_ALL_FRAMES(1 to 240, default 60) says for how many frames after a draw last bound the table. Nothing changes without the switch.In the prologue's cell on
mainit took the frame from 80–91 ms to 56–62 ms on an RTX 3090 Ti (54–59 ms in the first version, which had a longer window and no retry). It is not a gain everywhere: on an RTX 5060 Laptop 8 GB under Proton, Filip722 measured one pair that was slower with it (5.84 → 5.14 fps, below).Revised after review (akimfomin, Filip722): the switch has stamps of its own, the window can be set and is 60 frames, a record left to its draws is looked at again when its window ends even if nothing writes its page again (Filip722's test and fix, picked with them as author), and there are tests of where the window ends.
Why
The title writes its per-draw tables into its heap as bytes, every frame. A table that holds a constant buffer is made afresh for its draw in slots of our own, so the title's own slots of it are read by nothing unless a shader picks them by index.
The pass over records copied in as bytes (
sync_heaps) cannot know that. It already leaves a table's texture slots to the draws that read them (tabled_lately), but takes every other changed record there for one a shader may pick by index:State::heap_buffers) then makes each of them and asks for its memory to be brought up to date.I found it with a counter of what
HostHeap::mirrordoes by kind (on another tree, not in this PR): of about 19,500 records the pass took a frame, 11,400 were buffer views left for later, 3,700 were slots made null, 3,100 were no view over a slot that showed nothing, and 1,300 were texture views it made.What changes
HostHeap::table_slot(index)stamps a title slot as one of a table a draw bound, in stamps of the switch's own (table_any, allocated only with the switch). The texture queue's stamps are not touched. (The first version of this PR wrote the texture queue's stamp; that also changed how the queue treats a slot that had held a table's buffer view.)State::table_entry(tables read in place) calls it for an entry that is no texture view, and for an entry that is no view at all. The loop that makes a table afresh calls it for each of the title's own slots of the table.mirror_copied,mirror_copied_page) asksleft_to_draws: a table's texture slot lately, as before, or with the switch any stamped slot withinVICTORY_TABLED_ALL_FRAMES.d4e76edthe test and82d837bthe fix): a changed record the pass leaves is not noted as seen, so before this it was taken only the next time something wrote its 64 KiB page. A slot that left its table and was then picked by index, on a page nothing wrote again, stayed unseen for good. Now each heap keeps one deadline per page that has such a record (TableRetries), and the pass reads the page again in the first frame the record is no longer left. Only with the switch, and only for records the switch's own stamp left (c59bc53): what the texture queue's rule leaves is taken when its page is next written, as onmain. Here it costs the pass about 0.7 ms a frame (4.3 → 4.9–5.1 ms; 174 → 180–192 pages read).Measurements
main4c60466with #798 on top (the Series S profile needs it to show the world) and two commits that do not touch this code (which card to render on in a two-card PC; the skip list looked up in a set). RTX 3090 Ti 24 GB, Ryzen 9 9950X3D, 64 GB, Windows 11 26200. Series S profile, diagnostics build, warm shader cache, the prologue's cell, hands-off, 5.5 minutes each, one run per row. Frame: the last four readings of the frame line.Switches in every run:
INDIRECT_WINDOW JOIN_PARTS BACK_OWN_VIEW INDIRECT_GATHER CARD_REHASH_RUNS LEVELS_ON_DEMAND ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT COPY_PLAIN FILLS_PLAIN ABSENT_ONCEat 1,ABSENT_MS=told MERGE_GAP=64 MERGE_RUNS=4096 STAGING_POOL=0 CARD_BUFFERS_MIN_KB=64 CARD_BUFFERS_MB=1280, and the ray-tracing resolve and traced-shadow shaders of #1268's list inVICTORY_SKIP_PIPELINES.sync_heaps)Why the window matters at all: the title makes its per-draw tables in a ring of its heap's slots, so a slot is written again some frames after a draw last bound its table, and the stamp has to outlast that. 60 frames has nearly all of the gain for a quarter of the time a slot can go unseen. Two more runs with the switch off on this base read 84–96 and 84–90 ms, and a second run at 60 frames 56–59 ms.
Picture: in the cell the same in all of these (four frames of each run side by side). The cutscene before the cell has
main's known faults in every run here (black first screens, a broken face); its frames fall at different moments in each run, so I did not compare them one to one.One run outside the table was different, and it shaped the last commit. The retry as first picked also read a page again when the texture queue's 240 frames ended for a record on it. In one of two runs of that form the cell's window frame drew flat yellow in all nine screenshots of the cell (three minutes). None of the nine runs without a retry did, and neither of the two with the retry narrowed to the switch's own stamps (
c59bc53, the row in bold). One run in two does not prove the wider retry did it, but the narrower rule does not need the proof: the texture rule ismain's, and with the switch on it now behaves exactly as without it.What it costs, and where it was slower
With the switch on, the submitting thread has more to do, and I have not found why yet. On the frame line here:
It is not simply work moved from one thread to another: the buffer pass defers its refreshes to the submission too. On this PC the frame is shorter all the same, because without the switch recording was the limit; with it the submitting thread is (at work 46 of a 56 ms frame).
On a machine where the submitting side or the card behind it is already the limit, the same extra can make the frame longer. Filip722's pair on an RTX 5060 Laptop 8 GB (Bazzite, GE-Proton, Series S at 50 % scale, the first version of this PR, 240 frames): the descriptor work fell as here (records mirrored 11,292 → 191, the pass 30.5 → 5.3 ms, the buffer pass 77.8 → 22.4 ms, 560 MiB more video memory free) and the frame rate fell too, 5.84 → 5.14 fps, with their GPU phase at 22.5 → 60.8 ms and copy-back at 64.7 → 81.4 ms. One pair, but it points the same way as the table above, so read this switch as "measure on your machine", not as a default.
Risk, and why it is off by default
VICTORY_TABLED_ALL_FRAMESframes after the last draw bound its table (60 by default). With the retry it is seen then, whether or not its page is written again. Before the retry it could stay unseen for good; that hole is what Filip722's test shows.tabled_lately,main's) is unchanged, with the switch or without.How this relates to open PRs
Verification
cargo clippy -p victory-gpu --all-targets: no warnings.cargo test -p victory-gpu --lib descriptor: 43 passed. New here: the stamp's ends at 1, 8 and 240 frames; the pass over a page (a changed record of a table's slot is left up to the last frame, taken in the frame after, its deadline is that frame,VICTORY_HEAP_SYNC_TABLES=1holds nothing back, and a table's texture slot is left with no deadline); Filip722's merge test ofTableRetries; and Filip722's device test throughsync_heapson a write-watched heap, in child processes with the switch off and on.9c3deb8): the write watch there also reports a page's first touch when that is a read, so the test now touches its heap's pages and resets the watch before it counts anything.victory-gpusuite is intermittent on this PC with or without this PR: 5 of 48 runs failed on unmodified4c60466(watch::tests::a_write_is_reported_at_every_checked_viewamong them), 4 of 25 on this branch (each timeinplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset). Neither test is touched here.cargo xtask policyreports the two oversized files it reports onmain(host.rs,lower.rs); this PR touches neither.Numbers and text only: no game data, captures or screenshots.
AI-assisted (Claude Code, Claude Fable 5.2). The retry and its two tests are Filip722's (assisted by Codex, per their comment).
@akimfomin on GitHub · 2026-11-27 00:16 UTC · original
At pinned head
9a18dd08, the table-slot stamp stays eligible for 240 guest frames, inclusive, even in the branch wheremirrorfound no view. The stamp is local to that descriptor heap. Stamp test and lifetime. That gives a small boundary case for the risk you called out: seed a table slot, change the same slot to an indexed-only resource, and check the fetched value at the 240/241 boundary in fresh OFF and ON processes. This distinguishes delayed host-view publication from a frame-time win.I separately checked that #1414 and #1413 merge cleanly; the span-cache author has that exact tree and four-case suggestion. For an independently repeatable correctness result, you can link just the SHA, both expected/actual values and the switch in PortBridge #98 so a fork can reuse it. This is source evidence, without GPU validation. AI-assisted review.
@Filip722 on GitHub · 2026-11-27 00:35 UTC · original · edited 2026-11-27 00:52 UTC
I tested this commit on a Bazzite laptop with an RTX 5060 Laptop 8 GB, GE-Proton11-14, vkd3d-proton 3.2.0 and the indexed Wine server. Both Series S runs used the same executable, restored prefix and cache seed, 50% render scale and the same prison camera. Only
VICTORY_TABLED_ALLchanged. This is the4c604661-based compatibility build.The descriptor work fell sharply. In this single pair, median reported GPU phase was 22.5 / 60.8 ms and copy-back was 64.7 / 81.4 ms. Overall throughput fell in the same interval. Both rendered the same camera and had a median of zero queued host pipelines in the scoring windows. The usual GPU timing buckets are aggregate, so command attribution requires a separate trace.
The scoped descriptor filter passed 26 tests with each switch setting on the physical RTX. With a separate
b1d777aintegration, both default-wait arms hit the same title watchdog during loading and yielded no in-cell performance measurement.A separate synthetic D3D12 test on the b1 integration put a newly copied buffer view in a write-watched heap. With the switch off, the next sync registered it. With the switch on, the page was consumed during the 240-frame stamp window and the view was still absent after 241 frame tokens. A padding write elsewhere on the same page let sync discover the original descriptor, whose bytes and key were unchanged. Both child processes selected the RTX. This isolates a lost retry after expiry.
A source-only follow-up reproduces that failure on public base
b1d777aplus the PR and fixture at4f164079. Atf189f9a3, both physical test children pass. One deadline per changed page schedules a live reread when its table stamp can expire. The helper also checks that due pages merge in address order with ordinary dirty pages and that a failed read waits until a later frame. Windows-target GPU Clippy passed with warnings denied. The gameplay numbers above predate the expiry correction. Fixture and correctionAssisted by Codex (GPT-6.2-Sol High).
@akimfomin on GitHub · 2026-11-27 01:01 UTC · original
Your source-only fixture closes the 240/241 ambiguity: the view stays missing after expiry until another write hits the page, and the corrected branch passes without that write. I checked the full SHA of the fixture and correction and preserved their distinct baselines in Test Lab #106.
Anyone with a suitable host can give that card to an agent and run both exact revisions without a title. It records the selected adapter and treats an early return as skipped. We can credit any second-device report here. The Bazzite frame-time pair still belongs to the earlier revision, so it won't be used as a performance claim for your expiry correction.
On Windows the write watch also reports a page's first touch when that touch is a read. The pass reads the whole 64 KiB page that holds a changed slot, so the fifteen kernel pages of the test's heap that nothing had written counted as written after the first sync, and the test's own check that nothing wrote the heap again failed before it reached what it tests (with the switch off, on Windows 11 26200: 'no descriptor writes after the first sync', 15 against 0). With every page touched and the watch reset first, on an RTX 3090 Ti: at the commit that adds the test the child with the switch on fails where it should ('stamp expiry must discover the copied slot without re-dirtying its page') and the child with it off passes; with the retry both pass. Co-Authored-By: Claude Fable 5.2 <[email protected]>@KyleS98 on GitHub · 2026-11-27 02:05 UTC · original
@akimfomin @Filip722 thank you both. The branch has changed a good deal because of what you wrote (head
c59bc53, five commits on top of the one you read), and the description is rewritten to match. In short:1. The lost retry is real, and Filip722's test and fix are in. Writing a boundary test for akimfomin's question I had come to the same hole from the other side (the pass does not note a record it leaves as seen, so it is taken the next time its page is read, and nothing reads the page again unless something writes on it), and was about to write it up as a known limit.
TableRetriescloses it instead. Both commits are picked with Filip722 as their author:d4e76ed(the test) and82d837b(the fix).Two things I changed around them, each in a commit of its own so it can be judged apart:
9c3deb8: the device test did not get as far as its subject on Windows. The write watch there also reports a page's first touch when that touch is a read, and the pass reads the slot's whole 64 KiB page, so the "no descriptor writes after the first sync" check found 15 kernel pages written with the switch off. The test now touches its heap's pages and resets the watch before it counts anything. With that, on Windows 11 and an RTX 3090 Ti: at the commit that adds the test the child with the switch on fails where it should ("stamp expiry must discover the copied slot without re-dirtying its page") and the child with it off passes; with the fix both pass.c59bc53: the retry asks again only for what the switch's own stamp left. As picked, it also read a page again when the texture queue's 240 frames ended for a record on it, which changesmain's texture rule whenever the switch is on. In one of two runs of that wider form the cell's window frame drew flat yellow in all nine screenshots of the cell (three minutes); none of nine runs without a retry did, and neither of two with the narrower one. One run in two does not prove the wider retry did it, but the narrower rule does not need the proof: the texture rule ismain's, and with the switch on it now behaves exactly as without it. @Filip722, this is the one place where I changed what your fix does, so please say if you see a case it loses.2. Stamps of the switch's own, and a window that can be set (
e072a19). The first version wrote the texture queue's stamp for every table slot, so the switch also changed how that queue treats a slot that had held a table's buffer view. Now the stamps are separate and read only by the pass over copied records.VICTORY_TABLED_ALL_FRAMES(1 to 240) sets the window, and the default is 60:The title makes its per-draw tables in a ring of its heap's slots, so the stamp has to outlast the ring's turn; 60 frames keeps nearly all of it for a quarter of the exposure.
3. Tests (
cargo test -p victory-gpu --lib descriptor: 43 passed): where the stamp ends at 1, 8 and 240 frames; the pass over a page (left up to the last frame, taken in the frame after, the deadline it reports, nothing held back withVICTORY_HEAP_SYNC_TABLES=1, a table's texture slot left with no deadline); and Filip722's two.The slower pair stands. @Filip722, I am not claiming this switch is a gain on your machine, and the description now says so near the top. Your descriptor figures match mine (at the same 240 frames, records mirrored 11,292 → 191 against 16,994 → 218 here, and the pass 30.5 → 5.3 ms against 15.8 → 3.0). What I can add is that my own frame lines point the same way as your copy-back: with the switch on, the submitting thread's "copies" go from 60–65 MB and 9–10 ms a frame to 74–83 MB and 19–24 ms, its "preparing" from 25 to 37–43 ms, and copying back takes 16–18 ms where it took 12 for the same 31–33 MB. I have not found why yet (the buffer pass defers its refreshes to the submission too, so it is not simply work moved between threads). Here the frame is shorter all the same, because without the switch recording was the limit; with it the submitting thread is. Where that side is the limit already, the extra could be the whole difference, which is what your pair looks like. If you run it again, an off-on-off order would tell a warm laptop apart from the switch, and
VICTORY_TABLED_ALL_FRAMES=240is the window your pair had.One note on the suite, since both of you ran it:
cargo test -p victory-gpu --libis intermittent on this PC with or without this PR (5 of 48 runs failed on unmodified4c60466,watch::tests::a_write_is_reported_at_every_checked_viewamong them; 4 of 25 on this branch, each timeinplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset). Neither is touched here.AI-assisted (Claude Code, Claude Fable 5.2).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.