Renderer port 2: tables the title fills whole mark every slot they overlap (#301) #359
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!359
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-359"
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?
@Jesper-Andersson on GitHub · 2026-11-26 18:47 UTC · original
Jesper-Andersson:port2-table-ranges→main· +444 −29 · 3 files · 1 commits · openFixes #301.
With
VICTORY_PORT_DESCRIPTORS=1(renderer port 2), port 2's fallback finds hundreds of view records a frame in the title's heap that no mark told of (#301: 250 a frame on a 7900 XTX, all indirect light black). Until the fallback reaches their page, those slots show stale views. Port 2 marks slots from six patched record stores (crates/victory-loader/src/descriptor_sites.rs), from our own calls, and from the title's importedmemcpy/memmove. The title has other code that fills whole descriptor tables taken from its frame allocator (the memory of the placed view heap), and port 2 never sees those writes:vmovups [rbx+disp], ymmfor 128 bytes (a form the search for the six stores does not find), the importedmemcpyotherwise. This is thetitle+0x4d9f25fwriter in #301's table.Of the other writers #301 names:
title+0x18849c,+0x2474afcand+0x4e9b4e2store 8-byte list-node links from the same allocator.0x7ff9…0000is our own first stub. The writers outside the image are vcruntime'smemcpybehind our wrapper. They appear because the writer is recorded per 64 KiB block (the last fault on it), and the allocator mixes constants, nodes and tables in the same blocks.Change
descriptor_sites.rs: a second kind of site,Kind::Range { table, size, moved }. It hooks the point where such a function goes on once the table is filled, and marks every slot that[table, table+size)overlaps: a table that begins half into a slot marks that slot too, and the range is cut at the heap's end. The hooked instructions are moved into the stub. Arip-relativemov eax, [rip+x](the +0x248d6d0 sites) is done from its absolute address (Moved::LoadEax:mov rax, address ; mov eax, [rax], the sameraxand flags). Four sites: +0x4d9f272, +0x4e51aee, +0x248d71b and +0x248d7cb, which are the joins where both paths of each function meet. As with the six stores, each window's bytes are compared before anything is written. All four were checked against the 1.0.2.1 executable.port_descriptors.rs(diagnostics in the existing per-frame line):memcpycalls into the heap that begin half into a slot, and the view records they put half into one.VCRUNTIME140.dll+0x1c26f). When the word on top of its stack is in the title, the title code that called it is named too.watch.rspasses that word from the fault's context.VICTORY_PORT_DESCRIPTORS=1, which is off by default.Where it does nothing
VICTORY_PORT_DESCRIPTORS=1nothing is patched (run.rsapplies the sites only with the switch).Measured
RTX 2070 SUPER 8 GB, Ryzen 7 5800X, 32 GB, Windows 11, diag build,
scripts\play.ps1withVICTORY_PORT_CONSTANTS=1 VICTORY_PORT_DESCRIPTORS=1 VICTORY_PORT_CBV=1 VICTORY_PORT_GUARD=1 VICTORY_PORT_JOURNAL=1, 7 minutes from start (into the first world cell at 1-3 fps). Main wasc9c932c. "After" had the +0x4d9f200 site only; the three callback sites came later and have not been run.memcpycalls into the heap a frame (records they marked)memcpyinto the heap carries a view record, either at a slot's start or 16 bytes into one, so the copies the wrapper sees are other data. What is left has to be written by other code with its own stores. The callback sites are my best guess at that code, from reading the callers of the table allocator (+0x4d9f3e0).Checks
cargo test -p victory-loader --locked: 54 passed. New tests:a_range_site_marks_every_slot_its_table_overlapsruns each of the four windows in test code, plain and hooked, with all 16 registers set. It compares the registers both leave, checks that the movedrip-relative load reads the same value, and checks the marks for half-slot, past-the-end, outside-the-heap and zero-size tables.a_moved_load_reads_the_same_addressanda_range_stub_refuses_the_registers_it_uses.cargo test -p victory-gpu --locked: 381 passed, 34 ignored.cargo clippy --workspace --all-targets --locked -- -D warnings: stops on main's existingmissing_transmute_annotationsin the olda_hooked_site_stores_and_marks_its_slottest (descriptor_sites.rs:482), which this PR does not change. #169 and others fix it. Without-D warnings, nothing in the changed code.cargo xtask policy: 265 files ok.Not checked
Related
let_goand the tests inport_descriptors.rs. This PR touches neither, and the two rebase onto each other without conflict (checked on a branch carrying both).This change was made with AI assistance (Claude Code).
@Sr-0w on GitHub · 2026-11-26 20:57 UTC · original
Tested on RDNA 3 (RX 7800 XT 16 GB, i9-12900K, 64 GB, Windows 11), Series X, ray tracing on, renderer ports 1, 2, 5, 6, 7 on, warm cache, diagnostics build of
origin/main2de9980+ this PR + #273, a retail game's opening and the boat scene (480 s runs).0x4d9f059 0x4d9f117 0x4d9f1a8 0x4d9f272 0x4e51aee 0x248d71b 0x248d7cb 0x4eec968 0x4eeca12 0x4eeca8d), no "not patched", no crash or device loss.About half the misses are left. On this machine they come one per 128 KiB of the frame allocator, at the same place in each block (slots 4096 apart), which looks like one more writer that starts each block. A hardware write watch armed on the next block's slot caught only the patched stores and the hooked
memcpy(which mark), so the remaining writer is not found yet.@Jesper-Andersson on GitHub · 2026-11-26 21:02 UTC · original
Thanks, this is the run I couldn't do here (my card drops ~1,100 draws a frame, so the picture told me nothing). 191 → 101 with the +0x4d9f200 site alone at 122 is the first measurement of the three callback sites (+0x4e51aee, +0x248d71b, +0x248d7cb), so they carry about 20 a frame of the remainder.
Main has since moved under this PR:
4da7c0band8eaf2dchook the same +0x4d9f200 copy (VICTORY_PORT_COPIES=1, opt-in since4aeb6d0), and8eaf2dcmoved its hook off +0x4d9f272 after a privileged-instruction stop there. I'll rebase: drop this PR's +0x4d9f200 site in favour of main's and keep the three callback sites, then ask for a re-run onmainwithVICTORY_PORT_COPIES=1.The one-per-128-KiB pattern at the same slot in each block is a good lead: it points at whatever starts a block of the frame allocator (+0x4d9f3e0's callers) writing a record at a fixed offset before handing it out. I'll look there next.
@Sr-0w on GitHub · 2026-11-26 21:56 UTC · original
Follow-up: most of the misses left after this PR came from the
memcpywrapper itself. It marked a slot only when the copy wrote the slot's first word, so copies that rewrite a record's later words marked nothing, which is why0 records they markedshowed up. #384 fixes that: on top of this PR and #273 (RX 7800 XT), missed view records fall from 101 to 6 a frame. #385 adds the hardware-watch trace used to find it (stacked on this PR forplace()).@Jesper-Andersson on GitHub · 2026-11-27 00:04 UTC · original
Thanks, that explains the
0 records they marked. This PR's own counters were pointing at the same copies: it counts the title'smemcpycalls that begin half into a slot and the view records they put half into one, but only counts them and marks nothing new. #384 is the part that marks them.Ran this PR + #384 on 8 GB NVIDIA: RTX 2070 SUPER (driver 621.14), Ryzen 7 5800X, 32 GB, Windows 11. Build: main
014d52d+ this PR + #384 + #203 (DLSS), diagnostics,play.ps1settings, Series S with DLSS,VICTORY_PORT_DESCRIPTORS=1,VICTORY_PORT_COPIESunset. One run, about 2 minutes in the world:014d52d, so this doesn't separate #384's share on this card.Against current main, this PR needs the rebase announced above in two places: its counters for copies half into a slot (
COPIES[2..3]) and main'sTITLE_COPIES(4da7c0b) share the per-frame line, and main'sCOPY_128site needs this PR's newkindfield to build. #384 then applies on top with one small conflict, where its slot loop replaces the old one.This comment was written with AI assistance (Claude Code).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.