d3d12: withdraw a title-memory structure when the list over it is submitted #409
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/409"
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?
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T19:48:56Z.
Summary
A structure a title builds in its own memory gets host storage when its build is recorded (#320). A later recording that wrote a structure over an older one dropped the older structure's address at once. So a list recorded before that build, and submitted after it was recorded, resolved the older structure to one of two wrong addresses:
Before
e380da14such a list was refused, and its queue stopped. Sincee380da14it runs. Its copy or size query uses the storage it recorded, but a scene it builds over the structure, and lists after it, read through the bad address.PERMISSION_FAULTS: 0x3). The faulting pages there are title-range addresses next to the logged structure sources. That link to the game's faults is inferred: the faulting draw or dispatch wasn't identified.Changes:
Withdrawn at submission.
guest_memory::targetno longer drops older structures' addresses at recording time. It returns the storage it takes, both from structures the new one covers and from a rebuild at the same address. The recording list keeps that storage alive until it completes. When the list is submitted, a scene command withdraws each older address, unless a later recording has since given that address other storage.The recorded storage stays published. When a list's structure source got new storage after the list recorded it (e380da14's case), the list publishes the storage it recorded. Its own later commands, and lists submitted before the replacing list, then mean the structure that storage holds.
Instances whose structure is gone (
a2b56c94). An instance naming an address in title memory where no structure is published now gets a null structure, instead of keeping the raw address. Registered and native structures pass through unchanged. This is the first cause DrArroway named on #403, and the one the RX 6600 retest on this PR pinned down.Updates whose source was never built (
ce620c7). An in-place update resolved its source after its destination had got new storage, so it could read storage that nothing had built. The source is now taken first, and an update whose title-memory source has no storage is built in full, with private scratch, and logged. On an RX 6600, @1093i3511 ran this commit: no GPU fault and no reset, where every earlier run on that card since2af42c9had faulted, and the new log line appeared 16 times in 9 minutes. That run also hadTUXBOX_TRACE_RAYTRACING=1.Tested
Lanes
ray-tracing-guest-memorynow also builds a scene over the structure in its earlier list. It traces a ray onto the structure's triangle and one beside it, then records a build over the structure and submits the earlier list.mainwith only the test (RTX 5090): the provider logs that the source got new storage, then the GPU hangs (Xid 109) and the self-test never completes.928abca(beforee380da14): the list is refused withE_INVALIDARG, as expected.mainon the AMD iGPU.GPU, driver and backend:
At
a2b56c94, the AMD full check passed all 11 steps. The RTX 5090 full check passed 9 of 11 on a busy machine;lanes-late-pipelineand the translator'stranslated-meshfailed and each passed on a rerun. I have not found a cause; both passed atce620c7. Atce620c7(the last commit) the full check passed all 11 steps on the AMD iGPU and on the RTX 5090. The results below are for the first two commits.Commands run and their results:
🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-28T20:17:46Z.
Thanks for the fix. I ran this branch on the RX 6600 under the same conditions as before. The Lanes test passes here, but in the game the fault is still there, and now it lands on the structure addresses themselves.
Setup: RX 6600 (
1002:73ff, NAVI23, 8 GB), Mesa RADV 26.3.1, Linux 7.3.6,linux-firmware-amdgpu20261124, GE-Proton11-14. This branch atd5002e0(onmainb8355fa), D3D12 provider sha2565b27b58e…,XboxBvhBuilder.dllf9d957b9…. Warm caches,TUXBOX_TRACE_GPU_FAULT=1, default settings otherwise.Lanes
tuxbox.py verify --only lanes-selftest: 23 of 23 pass, includingray-tracing-guest-memory,ray-tracing-rehydrateandray-tracing-builder. No reset.Game
The run went the same way as on
main, but ended sooner, after 388 s and 5,380 frames, before a world frame was shown; the intro's audio could be heard. The title had made 32 rehydration calls (469 structures, 0 skipped). The last lines before the fault:The kernel (21:03:56), 10 reports, all
ring:24, TCP,PERMISSION_FAULTS: 0x3,RW: 0x0:0x179ae30000x179e9b0000x179ee70000x17a16b000comp_1.1.1, status0x701031)0x17a18c0000x17a18c400)0x17a1a70000x17a1a7a00)Then
Ring comp_1.1.1 reset failed, a MODE1 reset and VRAM lost, as before.What differs from
main:main, about half of theAS sourcelines resolved to new host storage and the rest to the raw title address. Here all three resolve to the raw title address.0x179a…–0x17a1…). Onmainthe faulting pages only lay near the AS sources.So something still reads through the raw title address of a structure whose storage was replaced. My guess is a TLAS instance record or a later list, like the first cause in #403 (an instance whose structure address isn't found keeps the raw guest address). The GPU fault trace again printed nothing, because the game was gone within about 0.4 s of the device loss.
Memory, peak: requested VRAM 6.7 GB, GTT 11.0 GB, RAM 29.5 GB, swap 4.4 GB.
I can rerun with extra logging if you point me at what would help.
Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-28T20:28:15Z.
One more detail from the amdgpu devcoredumps, for this run and my last two on
main.main2af42c9comp_1.1.1mainb8355facomp_1.3.0comp_1.1.1Each time, exactly one submission was pending on the hung compute ring, and it was a large compute list. The dump holds only the ring, not the contents of the indirect buffers, so I can't name the dispatch from it.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T20:41:32Z.
Thanks for the retest; the faults landing on the structure pages pinned it down. See also #403.
What was left. When the list that writes over a structure in title memory is submitted, the older structure's address is withdrawn.
d5002e0, that's where "now resolves to" the address itself comes from: the rehydration over the structure was submitted before a list that still named the old one.That's DrArroway's first cause on #403.
The change (
a2b56c9). An instance naming an address in title memory where no structure is published now gets a null structure, which makes it inactive. Following #403, only title-memory pools count; registered and native structures pass through unchanged.Two new Lanes cases cover it, one per fixup path:
ray-tracing-guest-memorysubmits the build over the structure before a scene recorded earlier;ray-tracing-rehydraterehydrates a structure over another on a second queue, and runs it before the scene.Both hang the GPU on
d5002e0on an RTX 5090 (Xid 109), and pass with this change on the 5090 and on an RDNA2 iGPU.Not covered yet: #403's second cause, a TLAS built before the overwrite and traced in a later frame after the older storage is freed. Your third run on
main, which faulted at host addresses, looks like that one.@1093i3511, could you rerun this branch at
a2b56c9under the same conditions? If it still faults, whether the pages are title addresses (0x17…) or host addresses (0x8007…) tells the two causes apart.Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-28T21:05:01Z.
Rerun at
a2b56c9on the RX 6600, under the same conditions (warm caches,TUXBOX_TRACE_GPU_FAULT=1, provider sha2565746bf71…).lanes-selftestpasses 23 of 23 again, including both new cases. The game still faults, but now only at host addresses, so the first cause looks fixed here and what's left is the second.Run
It lasted 400.6 s and 5,251 frames, about as long as before. There were 471 structures rehydrated (0 skipped). The last lines before the fault:
The kernel (21:57:40): 10 reports, all
ring:24, TCP,PERMISSION_FAULTS: 0x3,RW: 0x0, on two pages only:0x8007831fe0000x8007831ff000Then
ring comp_1.3.0 timeout,Ring comp_1.3.0 reset failed, a MODE1 reset and VRAM lost, as before.Compared with
d5002e0d5002e0, all ten faulting pages were title addresses in0x179a…–0x17a1….0xffff800783200000, and the faults are at0x8007831fe000and0x8007831ff000, the two 4 KiB pages just before0x800783200000. All reads.place TLAS on VA … previously used by non-TLASline this time either.So it fits the second cause you described: storage that was freed or replaced, then read by work recorded against it. I can't tell from here whether the pages below
0x800783200000belonged to an older structure that was freed, or whether a read starts before that structure's storage.The game was killed with the desktop again, so the GPU fault trace didn't print anything. I didn't keep the devcoredump this time.
Memory, peak: requested VRAM 6.7 GB, GTT 12.3 GB, RAM 29.6 GB, swap 6.4 GB.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T21:31:35Z.
Thanks, that's very useful: no title addresses, and two pages directly below one structure's storage.
A possible cause. Reads just below a structure are what RADV's update shader would do if the source header is zero: it finds parent links before an offset it reads from that header. I read that in Mesa 26.0.8, not your 26.3.1. We had a path to it: an in-place update resolved its source after its destination got new storage, so it could read storage nothing had built.
To try: branch
fix/as-update-unbuilt-sourceon my fork (ce620c77, one commit on top ofa2b56c94). It takes the source first, and builds in full when there is none.What I haven't shown:
Could you run it with
TUXBOX_TRACE_RAYTRACING=1? Two things would separate the explanations:update of a structure in title memory without storage built in fulllines;AS storage START..ENDlines around the faulting pages. Does an older structure's range end at the fault, or does nothing lie there?@DrArroway, your TLAS-pinned snapshots cover the freed-storage cause, which this doesn't. Are you planning to open that as a PR? I'd rather combine than duplicate it. Your unfinished
build_aswithnative_dst == srcmay be a related update, though its fault addresses don't fit this directly.Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-28T21:50:44Z.
Yes, happy to coordinate rather than duplicate. I split my local work on top of
main(b8355fa) into two branches and just finished a 59-minute live ProjectScarlett run with both applied (alongside#389,#390, and#408): 8 consecutive 3D world frames (pool #256,512 MiBprivate BLAS storage) with 0AS sourceerrors, 0build_asfaults, 0 GPUVM faults, and 0 GPU resets (the run ended only on the game's stall watchdog during heavy placed-texture readback).I am running the full dual-GPU (
1002:73bf+1002:164e) Lanes + regression verification gate on both branches now:fix/d3d12-gpu-fault-trace-flush(independent of#409): flushesgpu_tracesynchronously onUINT64_MAX/device-removed errors and addsgpu_tracemarkers around raytracing builds, instance fixup, dispatch, and rehydration. That should also give @1093i3511 the unfinished command even when a GPU reset kills the desktop before process exit.tlas_deps+ retiring replacedInstancessnapshots + grace window so freed BLAS storage is not read by in-flight or reused TLAS builds), andPERFORM_UPDATE(native_dst == src) fault we hit: resolvingguest_sourcebeforebuild_destinationand converting missing-source updates to full builds, plus callingGetRaytracingAccelerationStructurePrebuildInfoafter geometry translation, normalizing Xbox vertex formats inray_build::prebuild, and allocating private scratch when full-build scratch exceeds update scratch.I can open the
gpu_tracePR first, and either open the TLAS-pinned snapshot + prebuild/update fixes as a standalone PR or rebase the non-overlapping pieces on top of#409once it lands — whichever is easier for you.Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-28T22:11:09Z.
Before trying your branch, I ran
a2b56c9with local logging of my own (not pushed). It logs every buffer the structure code creates (rebuild::buffer) and every new, reused and released storage inguest_memory.rs. It also adds trace markers on the raytracing commands (build_as,rehydrate_as,copy_as,postbuild_as,instance_fixup,dispatch_rays), and checks for device loss every 50 ms. Same card and conditions as before. It answers your second question: nothing lay below the faulting pages.Faulting pages
At 22:47:09, 10 reports on ring 24, TCP,
PERMISSION_FAULTS: 0x3,RW: 0x0:That is the 48 KiB directly below
0x8003c8000000. Thenring gfx_0.1.0 timeout,Ring gfx_0.1.0 reset failed, MODE1. This time it was the graphics ring, not a compute ring.What the log says about that address
The storage at
0x8003c8000000and everything near it:0x8003c8000000ends at0x8003b7d30000, about 250 MiB lower. So it isn't a freed neighbour, as far as this logging can see.0x17dd43b00(9.4 MB of storage) and the one at0x17e4f5900overlap and keep replacing each other.0x17dd43b00gets new storage, the next build at the same address reuses it (line 7500 to 7504, line 8213 to 8343). The fault comes after the second reuse.That fits your explanation: an update in place over storage that nothing had built yet, reading below its start. My logging doesn't show the build flags for the reuse, so I can't confirm it was an update. Your branch's
update of a structure in title memory without storage built in fullline should show that.The trace
With the 50 ms check, the trace reported in time this time, but found nothing:
So every marked raytracing command, including the builds, had finished when the device was lost. A faulting read returns data and lets the build complete with garbage, and a later traversal on the graphics ring can then hang. That would explain it, but I'm inferring it from the gfx timeout, not seeing it.
@DrArroway, this may matter for the trace flush branch: on RADV a faulting build apparently doesn't stay unfinished, so a marker on
build_asalone may not name it. The hang shows up later on another ring.With
fix/as-update-unbuilt-source(ce620c77): no fault@NickStallman, I ran your branch unchanged, under the same conditions, with
TUXBOX_TRACE_RAYTRACING=1andTUXBOX_TRACE_GPU_FAULT=1. Lanes passes 23 of 23 first.2af42c9with no fault.update of a structure in title memory without storage built in full, for example: So the case you described happens in the game, 16 times in 9 minutes.AS sourcelines, 1,532AS storagelines.Current Mission Name: 0x98c85f2a [F:1734]andFrame: 1747. So about 13 game frames in the world, at 18–28 s per presented frame.What ends it now is the readback volume from #292 / #300, not a fault:
Memory got tighter than in earlier runs: requested VRAM 6.8 GB, GTT up to 15.9 GB (the card's GTT limit is 16 GB), RAM up to 31.1 of 32 GB and swap 11.0 GB.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T22:19:47Z.
Thank you both.
@1093i3511, that's a decisive test: no fault on your card, and the case happens 16 times in 9 minutes. I've moved the commit onto this PR (
ce620c7) and put your result in the description. Your note about the marker is useful too: a faulting build can finish, and the hang then shows up later on another ring.@DrArroway, that plan works well. Since
ce620c7already covers the "resolveguest_sourcebeforebuild_destination, full build when the source is missing" part of your update fix, could you rebase the rest on top of #409 once it lands: the TLAS-pinned snapshots, the prebuild changes and the scratch handling? Please also open thegpu_traceflush separately whenever it suits you. If you'd rather have the update fix as your own commit, say so, and I'll drop mine.On the readback volume that now ends the runs: draft #413 keeps GPU-written placed textures on the GPU until title memory is looked at, so no readback is recorded for textures the title never reads. It hasn't been run in the game yet, and its AMD check isn't clean. It has one known gap you might hit: textures with unmapped mips, or on memory XMem doesn't manage, still use the old path. If you want to try it,
TUXBOX_GPU_OWNED=0turns it off for a comparison. Our own run with and without it is in progress.Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-28T22:23:47Z.
Sounds good — keeping
ce620c7in#409makes total sense, and I'll rebase the remaining pieces (TLAS-pinned BLAS snapshots, prebuild-after-translation + Xbox vertex format normalization, and private scratch when full-build scratch exceeds update scratch) on top of#409once it lands.I opened the
gpu_traceflush + raytracing markers PR separately as #424 (dual-GPU verified on1002:73bfand1002:164e), and noted @1093i3511's caveat about RADV faulting builds sometimes finishing and hanging a later ring.Also excited to try draft
#413on the placed-texture readback volume next!