d3d12: keep a render heap while its guest range is committed #373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/373"
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 Jerkin42 on 2026-11-28T05:34:36Z.
Summary
Fixes #323.
A render target that the title places at a guest address through the layout API (slot 133) lives in a device-local render heap.
RenderHeapskept only aWeakper guest range, so releasing the last image there freed the native heap at once. On the console, releasing an image does not free the memory behind it. The title still owns the range and can read it through descriptors it made earlier. #323 shows a shader reading a freed heap's VA 11 minutes later, which loses the device after 15 to 18 minutes of play.RenderHeapsnow holds each heap, and drops one only when no image uses it and no page of its guest range is committed (any_committed, aVirtualQuerywalk). As a result, another image placed at the same address also sees the texels left there, as it would in console memory. Heaps that a larger placement replaces are still dropped from the table as before, and the images that use them keep them.Memory cost: #323 counted 592 render heaps created in a run and only about 10 freed, so keeping the few whose range stays committed costs little. The check runs only over heaps that no image uses, when a new image is placed.
Tested
python tuxbox.py check --adapter 10de:2b85onab0751c8, 162 of 162 passed (RTX 5090, driver 620.70.10, GE-Proton11-14), including the regression controls (comment).New regression control
render-heap(d3d12-placement.exe --render-heap):On
mainthe second image kept 0 of 65,536 texels (two runs). With this change it keeps all 65,536 (two runs, plus the full check).I have not run ProjectScarlett with this change: #323's fault takes 15 to 18 minutes from a story save to appear. A run from someone who can reproduce it (the reporter, with
VKD3D_CONFIG=fault) would confirm it.GPU, driver and backend: AMD RX 9060 XT, Mesa RADV 26.1.8, Linux 7.3.1, Proton Experimental (private rootful Xwayland); NVIDIA RTX 5090, 620.70.10, GE-Proton11-14 (run by NickStallman)
Commands run and their results:
invalid-routealso fails on plainmainhere: it checksroute-game.exe's exit status and has failed on this machine before. Themeshcontrol places no images at guest addresses. It is intermittent on RADV here (the amplified dispatch's word 76 sometimes reads 0) and fails the same way on branches that don't touch D3D12, as noted on #367 and #368.Checks
No evidence JSON changes.
🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-28T05:34:50Z.
I only have an AMD card (RX 9060 XT, RADV), so the NVIDIA half of the checks is still open. If someone with an NVIDIA GPU can run
python tuxbox.py checkon this branch and post the summary, that would cover the vendor row. Thank you!Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T06:19:16Z.
NVIDIA results for
ab0751c8: the fullpython tuxbox.py check --adapter 10de:2b85passed, 162 of 162 (RTX 5090, driver 620.70.10, GE-Proton11-14), including the regression controls.For context, on the same card we saw a device loss about 12 minutes after the story load. We are now running a build with this PR in it, with vkd3d-proton
's device-fault reporting, and will post what it shows.Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-28T06:22:04Z.
Thank you, @NickStallman! That covers the NVIDIA row; I've added your result to the description.
The device-fault report will be useful either way. On the RX 9060 XT our own long runs were also lost in the story prologue, so if the fault names a heap or a placed resource, I'd like to compare it with ours.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T07:00:03Z.
Here are the device-fault reports from builds that include this PR, as promised (RTX 5090, 620.70.10, trace-built vkd3d-proton
cae8353ewithVKD3D_CONFIG=breadcrumbs,fault). None of the faults named a render heap.ReadInvalidin the title's streaming span. In one run the faulting page held an unresolved BLAS index-buffer address (format 53); in the other it sat 0x1370 bytes after one. The tracker found no allocation there in either run.ReadInvalidwas at0x6124c7000, inside a 2.2 GB vkd3d allocation (aVkDeviceMemoryand a globalVkBuffer). That allocation lived 1.8 s and was freed 31 s before the fault; vkd3d called it "very likely use-after-free". It wasn't a render heap: 0 were released in that run, and the largest was 15 MiB. We haven't yet identified which D3D12 object owned it.Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-28T07:01:07Z.
Thanks, @NickStallman, that's very helpful, and good to know none of them was a render heap.
On the RX 9060 XT, our latest prologue run (with the two known-bad shaders nulled) went about 6.5 minutes without a fault, but I stopped it there, so that doesn't prove much yet.