d3d12: map title memory far past root SRVs and UAVs #441
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/441"
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 glovepost on 2026-11-29T04:41:10Z.
Summary
A root SRV or UAV has no size of its own. ProjectScarlett reads about 80 KiB past one, and the device was lost 32 KiB past a one-page import. Import up to 4 MiB behind the address, from the 4 MiB boundary below when that memory is committed, otherwise from the address's page, and span 8 MiB clipped to the committed run. Root constant buffers stay 64 KiB.
Lookups check up to eight preceding registry entries. Command imports stay in a 1024-entry cache only while their pages stay mapped, so a title
VirtualAllocimport does not outlive memory the title has released.The
root-srv-reachcontrol reads 0, 65280, 65536, 81920 and 1048576 bytes past a root SRV.A non-null address waits for a pending page mapping over that 8 MiB window before
VirtualQueryand before a covering import is reused. Sampling first kept the one-page fallback, or a GPU address the remap was about to retire.A root view of an address already returned by
GetGPUVirtualAddressbinds that buffer. Widening the host GPU address imported committed memory around it, and NVIDIA rejected the command list.Rebased onto current
main(28717263). This branch does not touch the ray-tracing builds in the companion pull requests.Tested
Run the checks relevant to this change.
The reach is the
root-srv-reachD3D12 regression control, not a Lanes scenario. A Lanes dispatch does not place a root view over title memory the way this import does, and it does not queue aCopyPageMappingsbehind that bind. The wait is the same case: nothing in Lanes holds a page mapping pending across the import.The first command block is
4065d2c5, before the wait.4657a53cpassed the regression controls on both adapters and the guest suites on AMD, and failedlanes-selftest-thread-dimensionson NVIDIA (close list failed: 0x80070057).f244a687binds an existing buffer instead of widening that address. On that commit both adapters passed the regression controls and the guest suites, 72/72, includingthread-dimensions.Code checks on this rebase:
Both exited 0.
cargo checkprinted two existing warnings indescriptor_paging.rsandtests/device/placement/upload.rs.GPU, driver and backend:
10de:1e84, driver 620.73.041002:13c0, Mesa 26.3.1upstream-pr-checks,--windows-dxcpointing at Microsoft's x64dxcompiler.dllanddxil.dllCommands run and their results:
4657a53c, rebuilt before these runs. Gamescope was--backend headless -w 1280 -h 720 --prefer-vk-device <adapter>withENABLE_GAMESCOPE_WSI=0.f244a687, rebuilt before these runs. Gamescope was--backend headless -w 1280 -h 720 --prefer-vk-device <adapter>withENABLE_GAMESCOPE_WSI=0.Claude Code wrote the original port. This session rebased it onto current main, added the wait and the existing-buffer bind, and recorded the runs above.
cargo check --offline --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 --testson the wait commit exited 0, with the same two existing warnings. The buffer-bind commit was built withpython3 build.py d3d12andpython3 build.py lanes.Checks
CI runs the Python unit tests, the shader compiler, DXBC, and XG layout tests, and a Windows typecheck of
tuxbox-d3d12.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T04:58:32Z.
Thanks for putting this on current
main. One thing aboutroot_view_address, found by reading only: I haven't reproduced it, and I'm not saying it causes any fault reported here. The same code is in #389.It queries the regions and calls
covering_bufferbefore anything waits for a pendingCopyPageMappings.buffer_atwaits first, but only after the window has been chosen. Example: the title queues a mapping for pages at or after A behind GPU work, then binds a root SRV at A. While the mapping is pending,VirtualQuerystill sees the old state, so:Noneand the one-byte path imports only A's 64 KiB page;covering_bufferfinds an import over the range, it's returned without a wait, although the pending mapping may be about to retire it.The smallest fix I can see is to wait before sampling, for a non-null address, at the top of the function:
That can wait for more than the binding needs; waiting only for
address..address + ROOT_VIEW_REACHwould be narrower. If I've missed a reason it can't happen, say so.We'll run the full check on an RTX 5090 and an RDNA 2 iGPU for this PR, #440, #442 and #443 and post the results.
Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T07:33:46Z.
Tested this in ProjectScarlett on AMD RDNA 2 (
RX 6900 XT,1002:73bf, Mesa RADV 26.3.1, GE-Proton11-14, Linux 7.3.6, offline, 3840x2160):main2871726+ local BLAS branch, without#441): two consecutive runs hit a deterministicTCPread GPUVM fault (RW: 0,PERMISSION_FAULTS: 3) right after entering 3D (0x8005a2542000and0x8001f9bc0000, outside all AS ranges) insidedraw VS 281b4977 PS 96e8aaaa(2 and 17 unfinished draws reported byTUXBOX_TRACE_GPU_FAULT=1;VS 281b4977reads root/heap SRVs with no raytracing instructions).#441applied on top: passed that draw cleanly and rendered 24+ consecutive 3D world frames over545.6s(2 frames / 15-19s, live AS churn up to998/173 MiB) with 0 GPUVM faults and 0VK_ERROR_DEVICE_LOST(the run eventually exited on a title CPU access violation atgame_scarlett_master.exe + 0x7B61A7).(
tuxbox.py checkwas not run separately on standalone#441here.)Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-29T15:08:17Z.
This carries the same
root_view_addresschange as #389. I posted our memory measurements and two open questions there: https://github.com/brcly/TuxBox/pull/389#issuecomment-7257849244. They apply here too. Please settle between the two PRs which one carries on.Imported from brcly/TuxBox. Originally posted by ReverendOzmund on 2026-11-29T16:02:23Z.
Tested on NVIDIA: RTX 3080 Ti, driver 620.73.04, GE-Proton11-14, Bazzite (kernel 7.3.5), with #441 merged onto main at
065a7f9a.tuxbox.py checkpasses every guest check, including lanes-selftest-thread-dimensions, compute-root-srv and compute-root-recovery. Regression controls weren't run (no Windows DXC here).Running ProjectScarlett with it next; I'll report whether the Xid 31 unmapped read from my earlier runs comes back.
Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-29T17:01:20Z.
Closing in favor of #389, as the maintainer asked. The two additions this PR had over #389 (the CopyPageMappings wait and the existing-buffer bind) are described there, with the dual-GPU results.
Pull request closed