RT on RX 9070 XT: ~⅔ of the "no copy" reads come from CS_RTDistantShadowTrace32_Tiled (outside/top addresses) #23
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/lobomfz--VIctory-xmem#23
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@LOCKhart07 on GitHub · 2026-11-30 10:31 UTC · original
Measurements on why ray tracing reads zeros ("title memory by address: shaders touched pages that had no copy") on an RX 9070 XT, and where those reads come from. Short version: about two-thirds of the bad reads come from one program,
CS_RTDistantShadowTrace32_Tiled, and they go to addresses that aren't backed (outside) or are clamped (top). Memory-side changes didn't move the numbers; my guess (unverified) is its wave32 translation.Setup
patches/mesa.patch, vkd3d-proton as pinned, Wine 11.21 Staging (wineserver rebuilt from wine-staging v11.21 +patches/wine.patch; protocol 972)cd811c1, diag build, Series X,VICTORY_OUTPUT=2560x1440,VICTORY_BVH_BUILDER=1(in place on by default)VICTORY_EXIT_AFTER. Counts below are summed over the run's warning lines (pages=/made=).What changed the count, and what didn't
VICTORY_BVH_SIZES_WAIT=1VICTORY_BVH_FAULTS_ALL=16384VICTORY_BVH_IN_PLACE=0Where the faults come from
A 4-minute run with
VICTORY_FAULT_TAGS=1(memory.rs's per-page reason, summed over the "loop probe faults" lines):outside(!um::covers)top(the clamp page)late(direct()true, not placed yet)therelow/low-buffer/low-shownbufferotherBy program tag:
a1b20bc4=CS_RTDistantShadowTrace32_Tiled(blake3a1b20bc47e3c9597…, compute, 13,916 bytes): outside 2,307, top 1,598 (all of them), late 943, there 487, low 151, buffer 59.5e687674=LeafRehydration(the builder's): there 219, late 73. Timing only, no bad addresses.So the
outsideandtopaddresses (⅔ of all faults) come from the distant shadow trace. The trace's ownlate(943) looks like ordinary first-touch zeros, which mapping those spans ahead would remove.Side finding: buffer pages can't be mapped under unified memory (minor)
Memory::direct()refuses pages inside a title buffer (shadow::in_buffer), andMemory::map()for a buffer page needs the buffer's host copy (shadow::find). Under UM, title buffers have no host copies (log: "host copies of title memory: 0 alive"). So such a page is never mapped and reads 0 for the whole run. Letting a buffer page go in place whenshadow::findis None (behind a switch here) is the last row of the first table: it's real but only ~1% of faults (bufferabove). The same test probably belongs onsmall_buffer_in.Guess (not verified)
The program is a console 32-lane wave program.
wave64_tests.rsdocuments a sibling,CS_RTShadowTrace32HQ_TiledFarOnly, whose skip has to be taken wave-wide. If this one's traversal (stack / skips) diverges per lane on the host where the console keeps the wave together, lanes would walk with wrong node pointers, which fitsoutside/top. I'll translate it offline withVICTORY_WAVE_WHY/VICTORY_WAVE_DUMPnext and add what I find here.Happy to run anything on this card; the bench is scripted and repeatable.
@LOCKhart07 on GitHub · 2026-11-30 10:35 UTC · original
Follow-up: the offline translation, plus a pointer from another fork.
Offline translation of
CS_RTDistantShadowTrace32_Tiled(examples/translate_file,K_RECORDS=1 VICTORY_WAVE_WHY=1, RDNA host, max wave 64): it translates (12,728 B DXIL in, 106,420 B out, 8 user-data dwords). There's no retry or approximate form, andwidenisn't taken (WAVE_WHYprints nothing; the retry chain only applies to console wave64 programs). So it's the exact wave32-to-wave32 path, and nothing in the translation flags it.How this walk works. Cyphco/VIctory-RTX3090 describes it in
crates/victory-shader/src/emit/shadow_patch.rs: "The title's shadow walks are wave-wide: one node pointer for the wave in SGPRs, the lanes that still walk in a mask, and the walk is skipped (s_cbranch_scc1 past) when no lane takes it." The distant traces walk a near top level and a far one. (They replace the walk with RayQuery on NVIDIA, so no fix of the translated walk there.)Narrower guess, still unverified. If the SGPR node pointer is updated by SALU code inside a branch only some lanes take, the per-lane copies in the translation could diverge from the console's single wave value. Lanes would then walk with a stale or partial pointer, which fits the
outside/topaddresses coming only from this program. It's the same family as theCS_RTShadowTrace32HQ_TiledFarOnlycase inwave64_tests.rs. I'm disassembling the walk loop (K_DIS=1) to check whether SALU updates sit in lane-divergent regions, and I'll try to reduce it to an instruction-level test like the ones there.@LOCKhart07 on GitHub · 2026-11-30 11:33 UTC · original
Update: I think first-touch zeros are the main source. Mapping in place eagerly removes most of them, and it's faster too.
Ruled out since the last comment (all RT on, same 8-min scripted bench):
VICTORY_SHADER_OPT=31(first-lane pass off) gives 92 warnings / 633 pages;VICTORY_SHADER_OPT=0gives 101 / 640. Both re-translated with a new cache key. So it's not an optimiser pass.CS_RTDistantShadowTrace32_Tiledto a 13-word test in the style ofwave64_tests.rs:s63 = exec; loopexec = s16 & s63, step, done lanes vias_and_saveexec,s63 &= ~exec,s_cbranch_scc1. Run on the 9070 XT throughwhole_uav, every lane does its own number of steps at host wave 32 and 64. The loop mechanics translate correctly.What worked: eager placement. The trace's
latefaults (943) andLeafRehydration'sthere/latefaults are valid title memory that only goes in place on first touch, so that frame reads 0. I added a switch inmemory.rs:ready(),put_whole(um::SPACE);put_in_placesucceeds,put_wholeof the page's wholeSTRETCH(128 MiB) instead of just its cell.So about 80% fewer zero reads and about 4–5 ms faster per frame, with no extra memory (it's in place). My reading: rehydration and the builder read pages before they're placed, write broken nodes, and the distant trace then follows them to
outside/top. That's the chain I can't fully prove yet. The remaining ~134 pages are a smaller second source I haven't classified.I haven't been able to look at the picture indoors yet (this bench spot is a sunny street, and RT bounce light there is subtle). The patch is small and switch-gated; happy to open a PR if you want it.
@LOCKhart07 on GitHub · 2026-11-30 11:38 UTC · original
Correction to my last comment: the chain I proposed doesn't hold. A 4-minute
VICTORY_FAULT_TAGS=1run with eager placement on:latethereLeafRehydration(5e687674)outside, alla1b20bc4top, alla1b20bc4Eager placement does remove the first-touch faults (
late, and the builder's), which is where the ~80% fewer pages and the 4–5 ms come from. The distant trace'soutside/topaddresses are unchanged, though, so they don't come from rehydration reading zeros. That's a separate problem and still open. Two things I can't tell apart yet: corrupt data coming from somewhere else, or reads the console itself makes past a structure's end (they would land in unmapped or clamped space here too). Sorry for the noise.@LOCKhart07 on GitHub · 2026-11-30 13:20 UTC · original
I tracked the distant trace's
outside/topreads down to bad nodes in the top-level structure itself. Measured with local diagnostics patches oncd811c1, RT on,VICTORY_BVH_BUILDER=1, eager placement (#25), 4-minute scripted runs on a 9070 XT.1. Which instructions fault. I extended
VICTORY_FAULT_TAGSso a tag also carries the console instruction offset (low 16 bits = offset / 4), and printed example addresses per site. ForCS_RTDistantShadowTrace32_Tiled:outside(~2,200 / 4 min): thes_load_dwordx4at 0x9e4, 0x1a7c and 0x3e8c. Per 0x98c–0x9e4, that's the instance fetch: TLAS base (s[24:25] << 8) +(s92 >> 3) << 6, wheres92is an instance child pointer from the TLAS box test at 0x96c. The addresses are 0x1099…–0x126d…, gigabytes past the TLAS and past every title request in the log.top(clamped 0x1fffff0000),low(< 4 GB) andoutside~0x1be050000: the BLAS node loads (global_load_dword0x4544, 0x2134, 0x407c, 0x1c6c, 0x109c, 0xbd4) andimage_bvh0x1050/0x20e8/0x44f8.2. Ruled out:
0xffffffff) inintersect.rsgave no change after re-translation (outside 2,103, top 1,349).VICTORY_BVH_SIZES_WAIT=1, and the waits do fire. A handful of copies per 4 minutes are allocated far too small and spill over neighbouring structures (example: the slot held 0xd80 for a 0x64500-byte structure).3. The TLAS at rest. Every 60 frames, from the host and after the frame, I walked each top level the trace dispatches read, starting from its root (header dword 12).
0xc34b498d= −203.3,0x43409075= 192.6). As pointers they land at 0x1087…–0x1493…, the same range as group A. Their low bits pick the kind at random, which gives group A (kind 6) or group B (everything else).0x7f7fffff/0xff7fffffempty-box values.What I think it is (not proven yet): node-size accounting in the TLAS build when box16 (64 B) and box32 (128 B) nodes are mixed. Either a child pointer is one 64-byte unit too far, or a box32 node is written into a slot sized for a box16 and runs over its neighbour. One way the second could happen under translation: the builder's "bounds fit in halves → box16" test coming out differently than on the console. I'm reading the builder's box-node writer next. One more run, logging the kind of the pointer that names the box32 node, would tell the two apart.
None of the diagnostics patches are PR-ready; they're local and diag-only. Happy to share them if they're useful.