Shaders mark the pages they write, and the compare reads only those (VICTORY_VIEW_MARKS=1): the layer's half #4174
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4174
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4173"
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?
@banaanpapa on GitHub · 2026-11-30 17:02 UTC · original
banaanpapa:port/view-marks-layer→main· +1360 −38 · 15 files · 4 commits · closed without mergingPart 2 of 2, stacked on #3641 (its commits are the first here; the last commit is this one's). Off unless
VICTORY_VIEW_MARKS=1; with it off nothing changes. No game was run: the figures are from the card alone (RTX 5080, driver 621.24).Why
A copy in the card's memory whose shader writes are declared is compared on the card after every submission, every declared piece of 64 KiB: for the title's heap of 174 MB, "2.2 GB of the card's reads a frame to find about 2.6 MB that shaders wrote" (
host/lazy.rs). The launcher now setsVICTORY_LAZY_COMPARE_MB=64, which compares fewer pieces by guessing which were written lately and can lose bytes (its own header says where). With write marks the shaders say which pages they wrote, and the compare reads those and no others: nothing is guessed.What this half adds
view_marks.rs: the switch (it is in the shader cache's key, and its first asking tells the translator), a run of bits for each copy in the card's memory (one for each piece the compare cuts, so bitbase + pieceis that piece), and the bitmap, 512 KiB in the card's own memory.u<SLOT_VIEW_WRITES>declares what it writes through tables' views as marked. Everything else that declares a write (the layer's own copies, stores at computed addresses, root views,picked) notes the copy as having an unmarked writer in that list, and the submission's compare then takes that copy's ranges whole, as before. So do copies with no bits left, rangeslazypicked, two queues, and windows that grow.card_compare_marks: the batch compare with one more constant (the copy's base bit) and the bitmap. A piece whose bit is clear is not read: its dword ofdiffersis 0 and its stored hash stays, as that of a piecelazyleaves out does. A piece whose bit is set is compared as ever and its bit cleared. Its source is made fromCARD_COMPARE_BATCH's by five replacements that are checked to match once each, so the two cannot drift apart unseen.VICTORY_UNIFIED_BACKthe pieces a class keeps for the copy-back are declared the same way, so the two work together.A bit that is set and should not be costs a compare. Nothing clears a bit but the compare that read it.
Measured
indirect::tests::what_the_compare_by_marks_saves_the_card(ignored; run by name): the heap of 174 MB declared whole, 2,784 pieces, compared after each of 12 submissions. Best of six, three runs:CARD_COMPARE_BATCH)The last two rows are why the bitmap is in the card's memory: every thread reads a dword of it, and over the bus that is most of the pass.
Tests
the_compare_by_marks_reads_the_marked_pieces_and_clears_their_bits, on WARP and on the card: against the batch compare, a marked piece gets the same dword and the same stored hash and its bit is cleared; an unmarked piece gets 0 though its bytes changed and keeps its hash; other copies' bits around this one's stay; a pass that stores hashes reads every piece; a piece marked later is found by its stale hash. It fails when a clear bit is compared all the same, when the base is left out, and when the bit read is not cleared.a_views_bits_are_the_pieces_the_compare_cuts: for 20,000 copies and views, the bit of a view's first byte is the first piece of its range as the compare cuts it, the bit a program computes for its last byte is the last piece, and a copy takes as many bits as it has pieces.runs_of_bits_are_apart_and_come_back: the bits' allocator.a_copy_is_left_to_its_marks_only_while_every_writer_marks(added after the first push; run with the switch and without): through real host lists, what a marking shader, a shader that does not mark and a copy of the layer's own each declare is declared; with the switch a copy in the card's memory has a run of bits and a view's entry is its first byte's piece and offset; the copy is left to its marks only while every writer of the submission marks; a list's reset forgets what it noted. Without the switch no copy has bits and nothing is left to the marks. It fails when a writer that does not mark is not noted, and when every shader is taken to mark.cargo test -p victory-gpu --release --libwith the switch off and with it on: 1,116 pass both ways; the three that fail aremain's (shader_cache's key test,list::thin::tests::bindings_record_no_work, and theuav_poollifecycle test now and then). Run with #4115 applied and not committed here (the crate's tests do not compile onmainwithout it).Limits
LEFT_TO_MARKScounts the pieces given to the compare by marks.VICTORY_CARD_BATCH=0ranges are compared whole.Measured in play: the marks cost more card time than they save (2026-11-30)
One 9-minute session in the title's world on an RTX 5080 (driver 621.40,
e1251c31with #3641 and #4174, about 4,800 draws a frame, the card 99 % busy), compared with sessions in the same scene without marks:VICTORY_VIEW_MARKS=1The extra card time holds through the session (31-32 ms in each quarter, no pipelines being made). Coverage was high: per frame 300 compared copies were left to their marks and 18 were compared whole. But on a card that is the frame's limit, the work each marked store does costs about 27 % more card time, and the compare it saves is only 0.2 ms. So on this card the marks are a loss as built, and should stay off. A slower card whose compare costs milliseconds might come out differently; that hasn't been measured.
🤖 Generated with Claude Code
@paales on GitHub · 2026-11-30 20:52 UTC · original
Written by 🤖:
In-game numbers with
VICTORY_VIEW_MARKS=1. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off, 30 fps cap. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s from its first frame. On this PC the same build's submitting thread took 24 ms a frame in one run and 35 ms in another half an hour later, so only large differences count.Base:
main84bd61e2with #3918, #1727, #3553, #3043, #4207, #4138 and #720. The build with this PR also had #2504 and #4341. One run each, back to back:VICTORY_VIEW_MARKS=1Less work on the submitting thread, but more frames over 40 ms: the marks seem to move the time to the card on this setup. The build needed one run first to translate the changed shaders.
@trustno1-coder on GitHub · 2026-12-01 18:46 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed