d3d12: import XMem physical pages through their backing #218
No reviewers
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/brcly--TuxBox!218
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-218"
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?
@Exorion1er on GitHub · 2026-11-26 09:13 UTC · original
Exorion1er:d3d12-xmem-backing→main· +473 −28 · 6 files · 1 commits · openThis is the d3d12 half of the direction in #191 (one private backing per physical page, GPU-side aliases). It does not change XMem. Without the two XMem exports below, imports behave exactly as on
main.What it does
TuxBoxAcquirePhysicalBacking) and imports that memory instead of the guest address. An alias address with no CPU memory behind it can then still be imported, and every alias of a page shares the same pages.TuxBoxReleasePhysicalBacking). That covers the-14(EFAULT) crash @JeffreyBytes found and @DrArroway reproduced: on amdgpu, one live host-pointer import whose pages are gone makes every later submit fail.Contract for XMem (doc comment in
runtime/d3d12/src/device/heap/backing.rs)*backingis the start of the contiguous host range holding the same bytes (it may equaladdress), and*holdis a cookie.ERROR_NOT_FOUND: no XMem physical page in the range, so the provider imports the address itself.Not covered
CreateReservedResource+UpdateTileMappingsworks for them. I left it out until we know how often it happens: @gtb-sbe measured 100 of 119 alias imports as contiguous in guest addresses, but backing contiguity is still unmeasured.Tests
New
runtime/d3d12/src/tests/device/heap_backing.rs, with a fake XMem:ERROR_NOT_FOUNDfalls back to the address; other errors fail the import; a hold is released once, when dropped.PAGE_NOACCESSalias addresses. The GPU reads the CPU's bytes through the first alias. A GPU write through the first alias is visible through the second and to the CPU. Holds are released only when each heap is dropped. A page whose backing moved is imported again rather than reused.Results, Radeon RX 9070 series (
1002:7550), Mesa RADV 26.2.7, Linux 7.3.5, Proton Experimental,main31dd5a3+ this change:cargo test --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12, run through umu (Steam Linux Runtime 4): 148/149. The one failure,commands::memory_wait::tests::regressions::gpu_failed_mid_list_split_close_does_not_double_close_or_clobber_error, also fails onmain.buffer-import,buffer-import-reject,buffer-layout,buffer-remap,heapsall PASS.python tuxbox.py check --proton … --prefix … --windows-dxc …: all checks passed (70/70 GPU gates: Lanes and fixtures, D3D12 regression controls, shader translator on the GPU).🤖 Generated with Claude Code
buffer-remapregression control fails on RADV, with host memory imports refused #191@JeffreyBytes on GitHub · 2026-11-26 09:31 UTC · original
Two things from the RX 6700 XT (
1002:73df, Mesa RADV 26.3.1, GE-Proton11-14) that may help test this once the XMem half exists.Baselines for the device loss in ProjectScarlett. With the
ANONONLYpreload (host profilesection-import=aliased) every run that gets past the Account Picker ends the same way: oneCopyPageMappingsBatchXbatch logspage remap replaced imported range … retired stale GPU import(24 lines, which is the log cap, not the count), the next submit getsradv/amdgpu: The CS has been rejected (-14), thenVK_ERROR_DEVICE_LOST. Five runs so far:ac4f099ac4f099773278a773278aIt comes sooner the warmer the caches are, so it is a point in the title's loading rather than a timer. With shaders prepared I can reach it in two to six minutes, so I can run this PR plus the XMem side without the preload and say whether the game gets past that batch.
A control for the hold. In
page_mapping.rs,apply()applies the remap and then only marks the importlive = false; the native heap stays alive while placed resources hold it. That is the window this PR's hold closes. I have a small guest test for the same thing through slots 74 and 44, with privateVirtualAllocmemory and the default host profile:--unmap-alive: import, copy from it,VirtualFreethe pages with the buffer still alive, then three unrelated upload-to-readback copies. RADV prints the-14line and the copies read back 0 of 256 bytes.--unmap-released: release the buffer first, then free the pages. The same copies read back 256 of 256.It does not go through XMem, so this PR alone does not change its result. A variant on XMem pages (unmap or remap with the import alive, expect later submits to still work) would exercise the hold directly. I can open a PR with the test, or hand it over to be folded in here, whichever is more useful.
@Exorion1er on GitHub · 2026-11-26 09:40 UTC · original
Thanks, both are useful. I'd keep the test in its own PR: it covers a hazard
mainhas today and doesn't depend on #218, and the XMem-page variant (unmap or remap with the import alive, later submits still work) fits best alongside the XMem half, since that's the side that has to honour the hold. Your baselines and the 2–6 minute repro will be the real test of this plus the XMem side without the preload, so thanks for offering to run it.@NickStallman on GitHub · 2026-11-26 09:57 UTC · original
NVIDIA run of
python tuxbox.py checkon this PR's head (4461c8f), since the description lists NVIDIA as not yet covered:buffer-remapamong them) and the shader translator on the GPU.buffer-remapregression control fails on RADV, with host memory imports refused #191@DrArroway on GitHub · 2026-11-26 11:22 UTC · original
Tested
4461c8fon RX 6900 XT (1002:73bf, Mesa RADV26.3.1,GE-Proton11-14):python tuxbox.py check --adapter 1002:73bf: all CI/build steps + 70/70 GPU gates pass (1795427215 GE-Proton11-14).tuxbox-d3d12tests underGE-Proton11-14: 6/6device::heap::backing::testspass (0.10s, includingaliases_import_their_private_backing,a_moved_backing_is_imported_again, anda_backing_is_held_until_dropped_and_released_once), and 148/149 overall (only the pre-existinggpu_failed_mid_list_split_close_does_not_double_close_or_clobber_error).buffer-remap,buffer-import,buffer-import-reject,buffer-layout(TUXBOX_REQUIRE_BUFFER_IMPORT=1,TUXBOX_TRACE_BUFFER_BACKING=1): all 4/4 PASS.@ReverendOzmund on GitHub · 2026-11-26 11:53 UTC · original
Reviewed on the NVIDIA side. As far as I can tell this is dormant until XMem gains the two exports: neither TuxBoxAcquirePhysicalBacking nor TuxBoxReleasePhysicalBacking exists in xmem on main or in this branch, so lookup() returns None and every import keeps its guest address. The drop order in ImportedHeap (native, then shadow, then the hold) looks right for the EFAULT case. I'll run the D3D12 regression controls and Lanes on an RTX 3080 Ti (GE-Proton11-14) and post the result here.
buffer-remapregression control fails on RADV, with host memory imports refused #191@gtb-sbe on GitHub · 2026-11-26 13:46 UTC · original · edited 2026-11-26 13:54 UTC
Thanks for building the d3d12 half against that plan. I can't take on the XMem half right now, so it's open for anyone who wants it. I can still provide the measurements below and AMD runs.
Two things I can measure on ProjectScarlett (RX 9060 XT, RADV) before or while it's written. I have a local trace branch that describes every page behind an import (views, reservations, which views the CPU touches, through
/proc/<pid>/pagemap):CreateReservedResource+UpdateTileMappingswould be needed if XMem keeps CPU views where they are.For testing: this card runs
main(9b31fd8) with the fullcheckpassing on the #200 copy path (section-import=substituted), and ProjectScarlett reaches a the Account Picker without the preload. So it's a usable baseline to compare against once the XMem exports exist.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.