xmem: back physical pages with private memory and export backing holds #258

Merged
DrArroway merged 5 commits from upstream-pr/258 into main 2026-11-27 19:22:37 +00:00
DrArroway commented 2026-11-26 18:18:00 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-26T18:18:00Z.


Implements the runtime/xmem/ half of #191 so RADV can import XMem physical pages directly via VK_EXT_external_memory_host without hitting libdrm's AMDGPU_GEM_USERPTR_ANONONLY rejection or falling back to the #200 shadow copy. Pairs with #218 (already on main) and #253.

Part of #191

Summary

  • Private anonymous physical backings (MEM_PRIVATE, PAGE_READWRITE):
    • Single CPU views and GPU aliases allocate MEM_PRIVATE pages inside placeholder apertures rather than section views (runtime/xmem/src/physical_pages/private_views.rs, runtime/xmem/src/shared_pages.rs).
    • Mapping a second CPU view of the same token lazily promotes it to SharedSection so existing multi-view CPU aliases remain coherent.
    • Pure GPU aliases (or contiguous ranges with non-contiguous/conflicting backing order) promote unbacked tokens on demand into a shared PrivateArena (VirtualAlloc MEM_PRIVATE).
  • Lifetime holds & deferred unmaps (runtime/xmem/src/physical_pages/backing.rs):
    • Exports TuxBoxAcquirePhysicalBacking, TuxBoxAcquirePhysicalBackingRuns, and TuxBoxReleasePhysicalBacking as PRIVATE symbols in runtime/xmem/xmem.def.
    • Unmapping, remapping, or freeing held backing ranges defers virtual teardown until TuxBoxReleasePhysicalBacking(hold) drops the last reference, keeping imported MEM_PRIVATE host pages valid across live GPU submissions.
  • Unit tests (runtime/xmem/src/tests/physical_backing.rs):
    • Covers private CPU view acquisition + ERROR_NOT_FOUND on foreign memory, held CPU views surviving unmap/free, PrivateArena + conflicting-order BackingRun splitting + ERROR_MORE_DATA, and lazy SharedSection promotion on a second CPU view.

Verification

Tested on RX 6900 XT (1002:73bf), Linux (7.3.6-1-cachyos), GE-Proton11-14 (1795427215), RADV:

  • cargo check --locked --target x86_64-pc-windows-msvc --manifest-path runtime/xmem/Cargo.toml: passed (0 warnings)
  • Wine cargo test --locked --target x86_64-pc-windows-msvc --manifest-path runtime/xmem/Cargo.toml -- --test-threads=1: 4/4 passed (physical_pages::backing::tests)
  • python -m unittest tests.test_repository_hygiene: 5/5 passed
  • tools/check_d3d12_regressions.py --case buffer-remap --adapter 1002:73bf: PASS (4.418s, d3d12-buffer-remap PASS pci=1002:73bf words=768/768 identical=1 replacement=1, null_fallback_enabled: false)
    • Log confirmed TuxBox d3d12_xs: game memory is imported through its XMem backing and three path=imported entries, with zero copied for the GPU messages.
  • Full tuxbox.py check --adapter 1002:73bf: all 10 groups passed:
    • Lanes and fixtures on the GPU: 72/72 passed (170s, including xmem-pages and xmem-scatter)
    • D3D12 regression controls: 19/19 passed (85s)
    • Shader translator on the GPU: 40/40 passed (238s)
<!-- greyfinch-sync:brcly/TuxBox:issue:5515152554 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-26T18:18:00Z. --- Implements the `runtime/xmem/` half of #191 so RADV can import XMem physical pages directly via `VK_EXT_external_memory_host` without hitting libdrm's `AMDGPU_GEM_USERPTR_ANONONLY` rejection or falling back to the #200 shadow copy. Pairs with #218 (already on `main`) and #253. Part of #191 ### Summary - **Private anonymous physical backings (`MEM_PRIVATE`, `PAGE_READWRITE`)**: - Single CPU views and GPU aliases allocate `MEM_PRIVATE` pages inside placeholder apertures rather than section views (`runtime/xmem/src/physical_pages/private_views.rs`, `runtime/xmem/src/shared_pages.rs`). - Mapping a second CPU view of the same token lazily promotes it to `SharedSection` so existing multi-view CPU aliases remain coherent. - Pure GPU aliases (or contiguous ranges with non-contiguous/conflicting backing order) promote unbacked tokens on demand into a shared `PrivateArena` (`VirtualAlloc` `MEM_PRIVATE`). - **Lifetime holds & deferred unmaps (`runtime/xmem/src/physical_pages/backing.rs`)**: - Exports `TuxBoxAcquirePhysicalBacking`, `TuxBoxAcquirePhysicalBackingRuns`, and `TuxBoxReleasePhysicalBacking` as `PRIVATE` symbols in `runtime/xmem/xmem.def`. - Unmapping, remapping, or freeing held backing ranges defers virtual teardown until `TuxBoxReleasePhysicalBacking(hold)` drops the last reference, keeping imported `MEM_PRIVATE` host pages valid across live GPU submissions. - **Unit tests (`runtime/xmem/src/tests/physical_backing.rs`)**: - Covers private CPU view acquisition + `ERROR_NOT_FOUND` on foreign memory, held CPU views surviving unmap/free, `PrivateArena` + conflicting-order `BackingRun` splitting + `ERROR_MORE_DATA`, and lazy `SharedSection` promotion on a second CPU view. ### Verification Tested on RX 6900 XT (`1002:73bf`), Linux (`7.3.6-1-cachyos`), GE-Proton11-14 (`1795427215`), RADV: - `cargo check --locked --target x86_64-pc-windows-msvc --manifest-path runtime/xmem/Cargo.toml`: passed (0 warnings) - Wine `cargo test --locked --target x86_64-pc-windows-msvc --manifest-path runtime/xmem/Cargo.toml -- --test-threads=1`: 4/4 passed (`physical_pages::backing::tests`) - `python -m unittest tests.test_repository_hygiene`: 5/5 passed - `tools/check_d3d12_regressions.py --case buffer-remap --adapter 1002:73bf`: `PASS` (`4.418s`, `d3d12-buffer-remap PASS pci=1002:73bf words=768/768 identical=1 replacement=1`, `null_fallback_enabled: false`) - Log confirmed `TuxBox d3d12_xs: game memory is imported through its XMem backing` and three `path=imported` entries, with zero `copied for the GPU` messages. - Full `tuxbox.py check --adapter 1002:73bf`: all 10 groups passed: - `Lanes and fixtures on the GPU`: 72/72 passed (`170s`, including `xmem-pages` and `xmem-scatter`) - `D3D12 regression controls`: 19/19 passed (`85s`) - `Shader translator on the GPU`: 40/40 passed (`238s`)
JeffreyBytes commented 2026-11-26 18:38:30 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-26T18:38:30Z.


ProjectScarlett run on the RX 6700 XT without the preload, as asked on #191. Short version: with this PR's xmem.dll the title hangs during start-up, before the first frame, so I can't say anything yet about the remap.

Setup: RX 6700 XT (1002:73df), Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline, shaders prepared, no LD_PRELOAD. Both xmem.dll and d3d12_xs.dll rebuilt and staged for each row.

tree result
main 5c5677b (this PR's base) starts normally on the copy path, 6 presents per 11 s, still running when I stopped it at 240 s
5c5677b + this PR (cd8ad92) exit code 5 after 57.5 s, no present
5c5677b + this PR + #253 (f9b630d) exit code 5 after 64.2 s and 60.6 s (two runs), no present

What the failing runs have in common

  • The title's crash log says Game State: System Init, Frame: 0. The stack is game_scarlett_master.exe+0x2215C35 ← +0x2215ECA, which is the 30 s main-thread watchdog from #215. So the main thread stopped making progress about 20 to 30 s after launch and the watchdog ended the run.
  • The last line from the provider is the same every time:
    TuxBox d3d12_xs: created pipeline from Xbox slot 86 stream (688 bytes)
    
    On the base commit the next lines are prepared compute shader loaded …, created compute pipeline with 6 reflected FSSM descriptor slots, memory wait trace #1 … and submitted first guest batch. With this PR none of them appear.
  • game memory is imported through its XMem backing is never logged, the host profile is section-import=substituted, and there is no page remap and no rejected submit. It doesn't get as far as an import.

I don't have a stack for the hung thread, only the watchdog's, so I can't say where it is waiting. Since the provider is identical in rows 1 and 2, it is something the title does through XMem between creating that first raster pipeline and its first compute pipeline.

tuxbox.py check was not part of this; I only ran the game. If it helps I can rerun with any tracing you want switched on (for example a log line per XMem export call), or try a branch.

Update, same day: the runs above shared the machine with other GPU tests of mine, so I repeated them with nothing else running (no other Proton guest or compile in any 5 s sample, load below 5), alternating the two trees:

tree result
5c5677b + this PR exit code 5 after 41.3 s, no present
5c5677b normal, 6 presents per 10 s, stopped at 150 s
5c5677b + this PR exit code 5 after 40.9 s, no present

Same crash log and same last provider line. So it is not a load effect: five of five runs with this PR's xmem.dll hang at start-up, and both runs without it don't.

<!-- greyfinch-sync:brcly/TuxBox:comment:7200690869 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7200690869). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-11-26T18:38:30Z. --- ProjectScarlett run on the RX 6700 XT without the preload, as asked on #191. Short version: with this PR's `xmem.dll` the title hangs during start-up, before the first frame, so I can't say anything yet about the remap. **Setup:** RX 6700 XT (`1002:73df`), Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline, shaders prepared, no `LD_PRELOAD`. Both `xmem.dll` and `d3d12_xs.dll` rebuilt and staged for each row. | tree | result | | --- | --- | | `main` `5c5677b` (this PR's base) | starts normally on the copy path, 6 presents per 11 s, still running when I stopped it at 240 s | | `5c5677b` + this PR (`cd8ad92`) | exit code 5 after 57.5 s, no present | | `5c5677b` + this PR + #253 (`f9b630d`) | exit code 5 after 64.2 s and 60.6 s (two runs), no present | **What the failing runs have in common** - The title's crash log says `Game State: System Init`, `Frame: 0`. The stack is `game_scarlett_master.exe+0x2215C35` ← `+0x2215ECA`, which is the 30 s main-thread watchdog from #215. So the main thread stopped making progress about 20 to 30 s after launch and the watchdog ended the run. - The last line from the provider is the same every time: ```text TuxBox d3d12_xs: created pipeline from Xbox slot 86 stream (688 bytes) ``` On the base commit the next lines are `prepared compute shader loaded …`, `created compute pipeline with 6 reflected FSSM descriptor slots`, `memory wait trace #1 …` and `submitted first guest batch`. With this PR none of them appear. - `game memory is imported through its XMem backing` is never logged, the host profile is `section-import=substituted`, and there is no page remap and no rejected submit. It doesn't get as far as an import. I don't have a stack for the hung thread, only the watchdog's, so I can't say where it is waiting. Since the provider is identical in rows 1 and 2, it is something the title does through XMem between creating that first raster pipeline and its first compute pipeline. `tuxbox.py check` was not part of this; I only ran the game. If it helps I can rerun with any tracing you want switched on (for example a log line per XMem export call), or try a branch. **Update, same day:** the runs above shared the machine with other GPU tests of mine, so I repeated them with nothing else running (no other Proton guest or compile in any 5 s sample, load below 5), alternating the two trees: | tree | result | | --- | --- | | `5c5677b` + this PR | exit code 5 after 41.3 s, no present | | `5c5677b` | normal, 6 presents per 10 s, stopped at 150 s | | `5c5677b` + this PR | exit code 5 after 40.9 s, no present | Same crash log and same last provider line. So it is not a load effect: five of five runs with this PR's `xmem.dll` hang at start-up, and both runs without it don't.
DrArroway commented 2026-11-26 18:53:26 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-26T18:53:26Z.


Thanks @JeffreyBytes for running that and catching the System Init hang! We reproduced the exact same 30 s watchdog crash (game_scarlett_master.exe+0x2215C35 right after created pipeline from Xbox slot 86 stream) locally on RX 6900 XT with cd8ad92.

Moving this PR to Draft while we track down the root cause in xmem and verify the fix locally before marking it ready again.

<!-- greyfinch-sync:brcly/TuxBox:comment:7200963779 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7200963779). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-26T18:53:26Z. --- Thanks @JeffreyBytes for running that and catching the `System Init` hang! We reproduced the exact same 30 s watchdog crash (`game_scarlett_master.exe+0x2215C35` right after `created pipeline from Xbox slot 86 stream`) locally on RX 6900 XT with `cd8ad92`. Moving this PR to Draft while we track down the root cause in `xmem` and verify the fix locally before marking it ready again.
DrArroway commented 2026-11-26 20:29:20 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-26T20:29:20Z.


Updated in 80e55e1 — @JeffreyBytes this is ready for another test on your RX 6700 XT (keeping the PR as Draft until confirmed).

Root causes & fixes

  1. System Init hang (runtime/xmem): map_cpu_page was eagerly promoting ~99,776 pages out of the large GPU allocation in a loop. Switched partial unmaps/remaps inside PrivateSpan to in-place MEM_DECOMMIT/MEM_COMMIT, tracked CPU vs GPU apertures via XMemVirtualAlloc, and left secondary views as PAGE_NOACCESS with a Vectored Exception Handler (AddVectoredExceptionHandler) for lazy SharedSection promotion on CPU access.
  2. Placed-texture & mirror CPU reads (runtime/d3d12): A/B testing against main caught a green video screen when d3d12_xs read or validated GPU-aperture addresses directly via ReadProcessMemory / WriteProcessMemory / VirtualQuery against GpuAlias or PAGE_NOACCESS views. Updated snapshot_mip, write_mapped, validate_shared_range, and CBV/resource mirror snapshots to resolve XMem physical backings (TuxBoxAcquirePhysicalBackingRuns / TuxBoxAcquirePhysicalBacking).

Verification (80e55e1)

  • cargo check (tuxbox-xmem and tuxbox-d3d12, x86_64-pc-windows-msvc): passed (0 warnings)
  • Wine unit tests: tuxbox-xmem (7/7 passed) and tuxbox-d3d12 device::heap::backing (6/6 passed)
  • python -m unittest tests.test_repository_hygiene: 5/5 passed
  • RADV buffer-remap on RX 6900 XT (1002:73bf, GE-Proton11-14): PASS (words=768/768, null_fallback_enabled: false, game memory is imported through its XMem backing)
  • Local ProjectScarlett test on RX 6900 XT (GE-Proton11-14): passed System Init, imports game memory through its XMem backing, and UI + video launch cleanly.
<!-- greyfinch-sync:brcly/TuxBox:comment:7202741984 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7202741984). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-26T20:29:20Z. --- Updated in `80e55e1` — @JeffreyBytes this is ready for another test on your RX 6700 XT (keeping the PR as Draft until confirmed). ### Root causes & fixes 1. **`System Init` hang (`runtime/xmem`):** `map_cpu_page` was eagerly promoting ~99,776 pages out of the large GPU allocation in a loop. Switched partial unmaps/remaps inside `PrivateSpan` to in-place `MEM_DECOMMIT`/`MEM_COMMIT`, tracked CPU vs GPU apertures via `XMemVirtualAlloc`, and left secondary views as `PAGE_NOACCESS` with a Vectored Exception Handler (`AddVectoredExceptionHandler`) for lazy `SharedSection` promotion on CPU access. 2. **Placed-texture & mirror CPU reads (`runtime/d3d12`):** A/B testing against `main` caught a green video screen when `d3d12_xs` read or validated GPU-aperture addresses directly via `ReadProcessMemory` / `WriteProcessMemory` / `VirtualQuery` against `GpuAlias` or `PAGE_NOACCESS` views. Updated `snapshot_mip`, `write_mapped`, `validate_shared_range`, and CBV/resource mirror snapshots to resolve XMem physical backings (`TuxBoxAcquirePhysicalBackingRuns` / `TuxBoxAcquirePhysicalBacking`). ### Verification (`80e55e1`) - `cargo check` (`tuxbox-xmem` and `tuxbox-d3d12`, `x86_64-pc-windows-msvc`): passed (0 warnings) - Wine unit tests: `tuxbox-xmem` (`7/7` passed) and `tuxbox-d3d12` `device::heap::backing` (`6/6` passed) - `python -m unittest tests.test_repository_hygiene`: `5/5` passed - RADV `buffer-remap` on RX 6900 XT (`1002:73bf`, `GE-Proton11-14`): `PASS` (`words=768/768`, `null_fallback_enabled: false`, `game memory is imported through its XMem backing`) - Local ProjectScarlett test on RX 6900 XT (`GE-Proton11-14`): passed `System Init`, imports game memory through its XMem backing, and UI + video launch cleanly.
DrArroway commented 2026-11-26 22:07:32 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-26T22:07:32Z.


Rebased cleanly onto origin/main (e76ff6a) as 5a795cb (reusing #253's TuxBoxAcquirePhysicalBackingRuns in runtime/d3d12/src/device/heap/backing.rs) and marked Ready for review.

First, sorry @JeffreyBytes for asking you to test the initial revision before we had run it locally ourselves, and thank you for catching the System Init hang and calling out snapshot_mip (ReadProcessMemory) on #191 — our A/B test against main caught a green screen on video playback from that exact path (runtime/d3d12 now resolves XMem physical backings for snapshot_mip, write_mapped, validate_shared_range, and CBV/resource mirrors).

Real-world RX 6900 XT (GE-Proton11-14) results vs main (5c5677b)

  • Menu & intro video frame pacing: on main (shadow-copy fallback game memory is copied for the GPU), presentation dropped to 9 frames in 10s (~0.9 FPS) once hitting the intro; with zero-copy XMem backing import (game memory is imported through its XMem backing), it sustained 464–503 frames in 10s (~46–50 FPS) through the menu and intro video.
  • World streaming & gameplay: passed the menu and intro video cleanly, streamed the world (DispatchMesh), and reached Game Running (Frame: 5215, TileHeap: 2112Mb / 6236Mb, Streaming Requests: 3608, 7,319 buildings, 213 vehicles, 48 peds, 4,274 objects).
  • Later crash in Game Running (exit code 3): hit VK_ERROR_DEVICE_LOST (vr -4) from radv: GPUVM fault detected at address 0x8004914e0000 right after vkd3d-proton:vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory, with zero amdgpu kernel hang/reset and no host-pointer EFAULT — confirming XMem backings and holds stayed intact into Game Running.

Verification (5a795cb)

  • cargo check --locked --target x86_64-pc-windows-msvc (runtime/xmem & runtime/d3d12): passed (0 warnings)
  • Wine unit tests: tuxbox-xmem (7/7 passed) and tuxbox-d3d12 device::heap::backing (11/11 passed, 162 filtered)
  • python -m unittest tests.test_repository_hygiene: 5/5 passed
  • RADV buffer-remap on RX 6900 XT (1002:73bf, GE-Proton11-14): PASS (4.374 s, words=768/768 identical=1 replacement=1, null_fallback_enabled: false, game memory is imported through its XMem backing, buffer backing path=imported)
<!-- greyfinch-sync:brcly/TuxBox:comment:7204385757 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7204385757). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-26T22:07:32Z. --- Rebased cleanly onto `origin/main` (`e76ff6a`) as `5a795cb` (reusing #253's `TuxBoxAcquirePhysicalBackingRuns` in `runtime/d3d12/src/device/heap/backing.rs`) and marked Ready for review. First, sorry @JeffreyBytes for asking you to test the initial revision before we had run it locally ourselves, and thank you for catching the `System Init` hang and calling out `snapshot_mip` (`ReadProcessMemory`) on #191 — our A/B test against `main` caught a green screen on video playback from that exact path (`runtime/d3d12` now resolves XMem physical backings for `snapshot_mip`, `write_mapped`, `validate_shared_range`, and CBV/resource mirrors). ### Real-world RX 6900 XT (`GE-Proton11-14`) results vs `main` (`5c5677b`) - **Menu & intro video frame pacing:** on `main` (shadow-copy fallback `game memory is copied for the GPU`), presentation dropped to **`9` frames in 10s (~0.9 FPS)** once hitting the intro; with zero-copy XMem backing import (`game memory is imported through its XMem backing`), it sustained **`464–503` frames in 10s (~46–50 FPS)** through the menu and intro video. - **World streaming & gameplay:** passed the menu and intro video cleanly, streamed the world (`DispatchMesh`), and reached **`Game Running`** (`Frame: 5215`, `TileHeap: 2112Mb / 6236Mb`, `Streaming Requests: 3608`, `7,319` buildings, `213` vehicles, `48` peds, `4,274` objects). - **Later crash in `Game Running` (`exit code 3`):** hit `VK_ERROR_DEVICE_LOST` (`vr -4`) from `radv: GPUVM fault detected at address 0x8004914e0000` right after `vkd3d-proton:vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory`, with zero `amdgpu` kernel hang/reset and no host-pointer `EFAULT` — confirming XMem backings and holds stayed intact into `Game Running`. ### Verification (`5a795cb`) - `cargo check --locked --target x86_64-pc-windows-msvc` (`runtime/xmem` & `runtime/d3d12`): passed (0 warnings) - Wine unit tests: `tuxbox-xmem` (`7/7` passed) and `tuxbox-d3d12` `device::heap::backing` (`11/11` passed, `162` filtered) - `python -m unittest tests.test_repository_hygiene`: `5/5` passed - RADV `buffer-remap` on RX 6900 XT (`1002:73bf`, `GE-Proton11-14`): `PASS` (`4.374` s, `words=768/768 identical=1 replacement=1`, `null_fallback_enabled: false`, `game memory is imported through its XMem backing`, `buffer backing path=imported`)
Valdi320 commented 2026-11-26 22:16:09 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Valdi320 on 2026-11-26T22:16:09Z.


Independent NVIDIA control run for 5a795cb on main e76ff6a: RTX 4080 (10de:2704), NVIDIA 620.73.4, GE-Proton11-14. Rebuilt XMem, D3D12 provider, XMem guests and Lanes. Six isolated D3D12 memory controls passed: buffer-remap, buffer-layout, buffer-import, buffer-import-reject, buffer-unmap-alive, buffer-unmap-released (2,816 checked words in first three, no stand-ins). Fresh-prefix 15/15 selected guest gates: all 12 XMem gates, heaps, tables, Lanes replay. This verifies NVIDIA synthetic compatibility, not the AMD performance claim or retail execution. No changes to your PR branch.

<!-- greyfinch-sync:brcly/TuxBox:comment:7204520020 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7204520020). Originally posted by [Valdi320](https://github.com/Valdi320) on 2026-11-26T22:16:09Z. --- Independent NVIDIA control run for 5a795cb on main e76ff6a: RTX 4080 (10de:2704), NVIDIA 620.73.4, GE-Proton11-14. Rebuilt XMem, D3D12 provider, XMem guests and Lanes. Six isolated D3D12 memory controls passed: buffer-remap, buffer-layout, buffer-import, buffer-import-reject, buffer-unmap-alive, buffer-unmap-released (2,816 checked words in first three, no stand-ins). Fresh-prefix 15/15 selected guest gates: all 12 XMem gates, heaps, tables, Lanes replay. This verifies NVIDIA synthetic compatibility, not the AMD performance claim or retail execution. No changes to your PR branch.
JeffreyBytes commented 2026-11-26 22:55:10 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-26T22:55:10Z.


Retest on the RX 6700 XT, no preload, nothing else running on the machine: 80e55e1 once, then 5a795cb (on e76ff6a, with #253) twice. The start-up hang is gone and the game runs at full speed without the preload for the first time on this card. All three runs still lose the device on the story loading screen, with a different error than the preload gave.

Setup: as above (1002:73df, Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline, shaders prepared, 3840x2160). xmem.dll and d3d12_xs.dll rebuilt and staged for each commit.

What works now

  • Passes System Init, reaches the Account Picker and, after A, the story loading screen with its artwork.
  • game memory is imported through its XMem backing and, on 5a795cb, game memory is imported through non-contiguous XMem backings are logged.
  • Presents per 10 s, every present sample lit:
run picker loading screen
80e55e1 887 417, 424, 323, 288, 252, 148
5a795cb run 1 1028 471, 270, 300, 260, 123, 100
5a795cb run 2 984 458, 439, 358, 300, 300, 189, 121

For comparison, the copy path on main gives about 6 per 10 s here.

What still fails

run device lost at exit code
80e55e1 141 s 5
5a795cb run 1 139 s 3
5a795cb run 2 106 s 3

The order of events is the same in all three:

page remap replaced imported range 0xd751e0000..0xd751f0000 (0x10000 bytes) retired stale GPU import verdict=HRESULT(0x80004001) batches=193 …
  (24 of these, which is the log cap)
  … 20 to 30 s and two or three more present intervals, at a falling rate …
radv/amdgpu: The CS has been rejected, see dmesg for more information (-1).
radv/amdgpu: The CS has been rejected, see dmesg for more information (-1).
vkd3d-proton: Device … is lost (reason 0x887a0005, "VK_ERROR_DEVICE_LOST").

There is no GPUVM fault line in any of the three, so this is not the fault from your RX 6900 XT run, and it happens earlier: none of these runs left the loading screen.

The error code is the difference from the preload runs, which stopped at the same remap batch with -14 (EFAULT, nothing mapped under a live import). Here it is -1 (EPERM). My reading, not checked against your code: the ranges under live imports stay mapped now, so the hold is doing its part, but at some point after the remap batch one of them has a file behind it (a section view, or a page promoted to SharedSection on a CPU access), and the kernel's anonymous-only check refuses it when it revalidates that userptr buffer on a later submit. That is the ANONONLY branch in amdgpu_ttm_tt_get_user_pages(), which returns -EPERM; every submit carries every live import, so one such range is enough. The delay after the remap batch would fit a lazy promotion more than the remap itself.

If that is right, the rule would be that an address a held backing still covers stays private memory until the hold is released, whatever a remap or a promotion wants to put there.

Two other things from the logs, in case they are useful:

  • RtlReleaseSRWLockExclusive Lock … is not owned exclusive! appears about 2,400 to 3,200 times per run with this PR, against about 520 per run on main with the preload. I have not looked at which lock it is.
  • vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e once per run, about a second after device creation and before the first backing import. I assume that is the host profile's section probe. Run 1 on 5a795cb had a second one between the remap batch and the device loss; run 2 did not.

Happy to rerun on a new commit, or with extra logging if you want to see which range is refused; the whole cycle takes about five minutes.

<!-- greyfinch-sync:brcly/TuxBox:comment:7205097821 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7205097821). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-11-26T22:55:10Z. --- Retest on the RX 6700 XT, no preload, nothing else running on the machine: `80e55e1` once, then `5a795cb` (on `e76ff6a`, with #253) twice. The start-up hang is gone and the game runs at full speed without the preload for the first time on this card. All three runs still lose the device on the story loading screen, with a different error than the preload gave. **Setup:** as above (`1002:73df`, Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline, shaders prepared, 3840x2160). `xmem.dll` and `d3d12_xs.dll` rebuilt and staged for each commit. **What works now** - Passes `System Init`, reaches the Account Picker and, after A, the story loading screen with its artwork. - `game memory is imported through its XMem backing` and, on `5a795cb`, `game memory is imported through non-contiguous XMem backings` are logged. - Presents per 10 s, every present sample lit: | run | picker | loading screen | | --- | --- | --- | | `80e55e1` | 887 | 417, 424, 323, 288, 252, 148 | | `5a795cb` run 1 | 1028 | 471, 270, 300, 260, 123, 100 | | `5a795cb` run 2 | 984 | 458, 439, 358, 300, 300, 189, 121 | For comparison, the copy path on `main` gives about 6 per 10 s here. **What still fails** | run | device lost at | exit code | | --- | --- | --- | | `80e55e1` | 141 s | 5 | | `5a795cb` run 1 | 139 s | 3 | | `5a795cb` run 2 | 106 s | 3 | The order of events is the same in all three: ```text page remap replaced imported range 0xd751e0000..0xd751f0000 (0x10000 bytes) retired stale GPU import verdict=HRESULT(0x80004001) batches=193 … (24 of these, which is the log cap) … 20 to 30 s and two or three more present intervals, at a falling rate … radv/amdgpu: The CS has been rejected, see dmesg for more information (-1). radv/amdgpu: The CS has been rejected, see dmesg for more information (-1). vkd3d-proton: Device … is lost (reason 0x887a0005, "VK_ERROR_DEVICE_LOST"). ``` There is no `GPUVM fault` line in any of the three, so this is not the fault from your RX 6900 XT run, and it happens earlier: none of these runs left the loading screen. The error code is the difference from the preload runs, which stopped at the same remap batch with `-14` (`EFAULT`, nothing mapped under a live import). Here it is `-1` (`EPERM`). My reading, not checked against your code: the ranges under live imports stay mapped now, so the hold is doing its part, but at some point after the remap batch one of them has a file behind it (a section view, or a page promoted to `SharedSection` on a CPU access), and the kernel's anonymous-only check refuses it when it revalidates that userptr buffer on a later submit. That is the `ANONONLY` branch in `amdgpu_ttm_tt_get_user_pages()`, which returns `-EPERM`; every submit carries every live import, so one such range is enough. The delay after the remap batch would fit a lazy promotion more than the remap itself. If that is right, the rule would be that an address a held backing still covers stays private memory until the hold is released, whatever a remap or a promotion wants to put there. Two other things from the logs, in case they are useful: - `RtlReleaseSRWLockExclusive Lock … is not owned exclusive!` appears about 2,400 to 3,200 times per run with this PR, against about 520 per run on `main` with the preload. I have not looked at which lock it is. - `vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e` once per run, about a second after device creation and before the first backing import. I assume that is the host profile's section probe. Run 1 on `5a795cb` had a second one between the remap batch and the device loss; run 2 did not. Happy to rerun on a new commit, or with extra logging if you want to see which range is refused; the whole cycle takes about five minutes.
DrArroway commented 2026-11-26 23:42:23 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-26T23:42:23Z.


Thanks @JeffreyBytes for the detailed 3-run RX 6700 XT logs — especially noting that 5a795cb run 2 hit CS has been rejected (-1) with no second vkd3d_import_host_memory warning. That pointed directly to a backing-lifetime / VMA-protection race on already-imported userptr BOs rather than a failed import.

Pushed 0e927be with four fixes addressing that:

  1. Attach backing holds to each native ID3D12Heap (d3d12 BackingGuard): vkd3d-proton's d3d12_resource_destroy tears down resource->private_store before calling d3d12_heap_decref(resource->heap) (vkFreeMemory). Keeping Hold / ShadowPages only on ImportedHeap (attached to the resource) allowed host backings to be decommitted or freed while the RADV userptr BO was still in the global BO list, causing subsequent CS submissions to fail in the kernel with -EPERM (-1). BackingGuard is now attached via a cycle-free IUnknown marker directly on each native ID3D12Heap (including every piece heap in scattered CreateReservedResource imports) via SetPrivateDataInterface.
  2. Guard held slots against PAGE_NOACCESS (xmem private_views.rs): When a deferred-unmap or remapped slot still has an active GPU hold (has_hold(va, va + PAGE)), apply_slot_role, map_private_page, and map_private_contiguous now leave it PAGE_READWRITE and out of secondary_aliases instead of flipping a live userptr page to PROT_NONE.
  3. Prevent unpinned imports over doomed pages & cross-origin coalescing (xmem backing.rs): resolve_backings now returns ERROR_INVALID_ADDRESS (instead of ERROR_NOT_FOUND) when an unmapped range falls inside deferred_unmaps or an XMem aperture so d3d12 cannot create an unpinned hold: None direct import over a page about to be decommitted; runs no longer coalesce across distinct backing origins (PrivateView, distinct PrivateArenas, SharedSection); and flush_deferred_unmaps restores deferred_unmaps / span.deferred state if unmap/decommit fails.
  4. Restore strict validate_shared_range (d3d12 heap.rs): Reverted validate_shared_range to strict MEM_COMMIT + PAGE_READWRITE, keeping the XMem backing exemption scoped to place_gpu_target.

Verification (0e927be)

  • Unit & hygiene tests: tuxbox-xmem (10/10 pass), tuxbox-d3d12 device::heap::backing on RADV (13/13 pass, including placed_resource_keeps_backing_hold_alive_after_imported_heap_drops and adjacent_placeholder_private_spans_import_check), tests.test_repository_hygiene (5/5 pass).
  • RADV synthetic regressions (tools/check_d3d12_regressions.py, RX 6900 XT 1002:73bf, GE-Proton11-14): buffer-remap PASS (words=768/768, zero-copy XMem backing) and buffer-unmap-released PASS (later-submits=ok).
  • 3/3 full title runs on RX 6900 XT (1002:73bf, Mesa RADV 26.3.1, Linux 7.3.6-1-cachyos, GE-Proton11-14):
    • 0 radv/amdgpu: The CS has been rejected, 0 VK_ERROR_DEVICE_LOST, 0 GPUVM faults across all 3 runs.
    • All 3 runs passed the page remap batches cleanly into the world load; 2/3 rendered live 3D world frames (Run 3 reached 2,853 presented frames and stayed alive rendering until manually stopped).
    • RtlReleaseSRWLockExclusive dropped from ~2,400–3,200/run down to 3–5/run, matching vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory 1:1.

Would be great to hear how 0e927be behaves on your RX 6700 XT when you get a chance to re-test.

<!-- greyfinch-sync:brcly/TuxBox:comment:7205778162 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7205778162). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-26T23:42:23Z. --- Thanks @JeffreyBytes for the detailed 3-run RX 6700 XT logs — especially noting that `5a795cb` run 2 hit `CS has been rejected (-1)` with no second `vkd3d_import_host_memory` warning. That pointed directly to a backing-lifetime / VMA-protection race on already-imported userptr BOs rather than a failed import. Pushed `0e927be` with four fixes addressing that: 1. **Attach backing holds to each native `ID3D12Heap` (`d3d12` `BackingGuard`):** `vkd3d-proton`'s `d3d12_resource_destroy` tears down `resource->private_store` *before* calling `d3d12_heap_decref(resource->heap)` (`vkFreeMemory`). Keeping `Hold` / `ShadowPages` only on `ImportedHeap` (attached to the resource) allowed host backings to be decommitted or freed while the RADV userptr BO was still in the global BO list, causing subsequent CS submissions to fail in the kernel with `-EPERM` (`-1`). `BackingGuard` is now attached via a cycle-free `IUnknown` marker directly on each native `ID3D12Heap` (including every piece heap in scattered `CreateReservedResource` imports) via `SetPrivateDataInterface`. 2. **Guard held slots against `PAGE_NOACCESS` (`xmem` `private_views.rs`):** When a deferred-unmap or remapped slot still has an active GPU hold (`has_hold(va, va + PAGE)`), `apply_slot_role`, `map_private_page`, and `map_private_contiguous` now leave it `PAGE_READWRITE` and out of `secondary_aliases` instead of flipping a live userptr page to `PROT_NONE`. 3. **Prevent unpinned imports over doomed pages & cross-origin coalescing (`xmem` `backing.rs`):** `resolve_backings` now returns `ERROR_INVALID_ADDRESS` (instead of `ERROR_NOT_FOUND`) when an unmapped range falls inside `deferred_unmaps` or an XMem aperture so `d3d12` cannot create an unpinned `hold: None` direct import over a page about to be decommitted; runs no longer coalesce across distinct backing origins (`PrivateView`, distinct `PrivateArena`s, `SharedSection`); and `flush_deferred_unmaps` restores `deferred_unmaps` / `span.deferred` state if unmap/decommit fails. 4. **Restore strict `validate_shared_range` (`d3d12` `heap.rs`):** Reverted `validate_shared_range` to strict `MEM_COMMIT` + `PAGE_READWRITE`, keeping the XMem backing exemption scoped to `place_gpu_target`. ### Verification (`0e927be`) - **Unit & hygiene tests:** `tuxbox-xmem` (`10/10` pass), `tuxbox-d3d12` `device::heap::backing` on RADV (`13/13` pass, including `placed_resource_keeps_backing_hold_alive_after_imported_heap_drops` and `adjacent_placeholder_private_spans_import_check`), `tests.test_repository_hygiene` (`5/5` pass). - **RADV synthetic regressions (`tools/check_d3d12_regressions.py`, RX 6900 XT `1002:73bf`, GE-Proton11-14):** `buffer-remap` PASS (`words=768/768`, zero-copy XMem backing) and `buffer-unmap-released` PASS (`later-submits=ok`). - **3/3 full title runs on RX 6900 XT (`1002:73bf`, Mesa RADV 26.3.1, Linux `7.3.6-1-cachyos`, GE-Proton11-14):** - **0** `radv/amdgpu: The CS has been rejected`, **0** `VK_ERROR_DEVICE_LOST`, **0** `GPUVM` faults across all 3 runs. - All 3 runs passed the `page remap` batches cleanly into the world load; 2/3 rendered live 3D world frames (Run 3 reached 2,853 presented frames and stayed alive rendering until manually stopped). - `RtlReleaseSRWLockExclusive` dropped from ~2,400–3,200/run down to 3–5/run, matching `vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory` 1:1. Would be great to hear how `0e927be` behaves on your RX 6700 XT when you get a chance to re-test.
Valdi320 commented 2026-11-26 23:54:21 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Valdi320 on 2026-11-26T23:54:21Z.


I found a separate, reproducible coherence failure on your current head 0e927be, using only synthetic XMem pages (no game or AMD GPU required).

Two small regression tests in runtime/xmem/src/tests/physical_backing.rs:

  • Map one CPU page, create a GPU alias, unmap the CPU view, acquire the GPU alias (now backed by a PrivateArena), keep that hold live, map a new CPU view, read to trigger lazy section promotion, then write through the still-held arena pointer.
  • GE-Proton11-14 / Windows x64 Rust test: initial CPU value 0x12345678, CPU Type=0x40000 (MEM_MAPPED), write 0xaabbccdd through the held arena, CPU still reads 0x12345678. The same test retiring the hold before promotion passes, including write/read through the subsequent acquired backing. Existing arena split test also passes.

The arena hold retains an Arc, not a view_holds entry. promote_faulting_alias checks the mapped VA spans, but can change the canonical backing away from a still-held PrivateArena. Old imports may then write storage the CPU no longer sees. A plain ERROR_BUSY in the VEH would not be a complete solution (it would reject a legitimate CPU access); the ownership transition needs coordination with import retirement or a coherent fallback.

This is a demonstrated CPU-side model of stale backing writes, not proof of the AMD EPERM/device-loss cause. The tests are on my fork only; no new PR or change to your branch.

<!-- greyfinch-sync:brcly/TuxBox:comment:7205978063 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7205978063). Originally posted by [Valdi320](https://github.com/Valdi320) on 2026-11-26T23:54:21Z. --- I found a separate, reproducible coherence failure on your current head `0e927be`, using only synthetic XMem pages (no game or AMD GPU required). [Two small regression tests](https://github.com/Valdi320/TuxBox/commit/49c95fdf7fcaf996622aecd35c796312c2f8f417) in `runtime/xmem/src/tests/physical_backing.rs`: - Map one CPU page, create a GPU alias, unmap the CPU view, acquire the GPU alias (now backed by a PrivateArena), keep that hold live, map a new CPU view, read to trigger lazy section promotion, then write through the still-held arena pointer. - GE-Proton11-14 / Windows x64 Rust test: initial CPU value 0x12345678, CPU Type=0x40000 (MEM_MAPPED), write 0xaabbccdd through the held arena, CPU still reads 0x12345678. The same test retiring the hold before promotion passes, including write/read through the subsequent acquired backing. Existing arena split test also passes. The arena hold retains an Arc, not a view_holds entry. `promote_faulting_alias` checks the mapped VA spans, but can change the canonical backing away from a still-held PrivateArena. Old imports may then write storage the CPU no longer sees. A plain ERROR_BUSY in the VEH would not be a complete solution (it would reject a legitimate CPU access); the ownership transition needs coordination with import retirement or a coherent fallback. This is a demonstrated CPU-side model of stale backing writes, not proof of the AMD EPERM/device-loss cause. The tests are on my fork only; no new PR or change to your branch.
JeffreyBytes commented 2026-11-27 00:34:24 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-27T00:34:24Z.


Retest of 0e927be on the RX 6700 XT: the -1 rejection is gone. Three no-preload runs on a quiet machine, and all three pass the page-remap batch with no CS has been rejected line at all. They end about a minute later for a different reason, still on the story loading screen.

Setup: as before (1002:73df, 12 GB, Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, 32 GB RAM, 3840x2160, shaders prepared, no LD_PRELOAD).

run picker, presents / 10 s loading screen, presents / 10 s ended at how
1 1380 662, 472, 448, 327, 300, 289, 175, 175, 121, 73, 100, 84, 87, 70 208 s radv/amdgpu: Not enough memory for command submission., device lost, exit code 3
2 1199 487, 439, 404, 301, 300, 225, 151, 89, 94, 85, 62, 77, 36 198 s same line twice, device lost, exit code 5
3 978 472, 450, 361, 300, 300, 186, 117, 101, 79, 84, 80, 67, 62, 67 212 s no device loss; label waits stall and the title's watchdog ends it, exit code 5

In all three the present rate falls steadily, then the last intervals are one to four frames in 14 to 18 s with lines like:

GPU memory wait released after 5s without reaching its target (#6): address=0x4f8f980 op=>= target=0x11f6 value=0x11f5
stalled label 0x4f8f980 >= 0x11f6: waited by list … (order 4681), submitted to a type 2 queue, after waits []
radv/amdgpu: Not enough memory for command submission.
vkd3d-proton: d3d12_command_queue_execute: Failed to submit queue(s), vr -4.

The kernel log has the matching amdgpu: [drm] *ERROR* Not enough memory for command submission! for runs 1 and 2. No GPUVM fault in any run.

Memory. For run 3 I sampled the amdgpu counters (mem_info_vram_used, mem_info_gtt_used) and MemAvailable every 3 s, and then did the same for main (8c56463) with the preload as a control. MiB, time from launch:

45 s 75 s 105 s 120 s 135 s 180 s peak
0e927be VRAM 8733 9079 12236 12239 12241 12256 12263 (card total 12272)
0e927be GTT 1237 1271 2084 3142 5693 7950 8488 (total 15913)
0e927be MemAvailable 17508 16140 13646 12480 9941 6506
main + preload VRAM 8442 8899 9179 9188 9188 – 9188
main + preload GTT 1238 1277 1277 1280 1280 – 1295
main + preload MemAvailable 18674 17731 16982 16774 16849 –

The control dies at 144 s at the remap batch (-14, as always with the preload), so the comparison only holds up to there. Up to that point the two start out the same, and from about 90 s this PR uses roughly 3 GB more VRAM, fills the card, and then GTT and system memory keep growing where the control is flat. I have not found what the extra memory is; one run each, so treat the numbers as a first look. A 16 GB card would have more room before this shows.

Lock errors: RtlReleaseSRWLockExclusive Lock … is not owned exclusive! went up here, not down: 5,084 / 5,289 / 5,877 per run on 0e927be, against 2,400 to 3,200 on 5a795cb and about 520 on main with the preload. Memory allocation failed, falling back to system memory is about 470 per run on every build including main, so the two are not 1:1 on this card.

Happy to rerun with extra logging (for example the live hold count and total held bytes over time) if that helps.

<!-- greyfinch-sync:brcly/TuxBox:comment:7206572666 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7206572666). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-11-27T00:34:24Z. --- Retest of `0e927be` on the RX 6700 XT: the `-1` rejection is gone. Three no-preload runs on a quiet machine, and all three pass the page-remap batch with no `CS has been rejected` line at all. They end about a minute later for a different reason, still on the story loading screen. **Setup:** as before (`1002:73df`, 12 GB, Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, 32 GB RAM, 3840x2160, shaders prepared, no `LD_PRELOAD`). | run | picker, presents / 10 s | loading screen, presents / 10 s | ended at | how | | --- | --- | --- | --- | --- | | 1 | 1380 | 662, 472, 448, 327, 300, 289, 175, 175, 121, 73, 100, 84, 87, 70 | 208 s | `radv/amdgpu: Not enough memory for command submission.`, device lost, exit code 3 | | 2 | 1199 | 487, 439, 404, 301, 300, 225, 151, 89, 94, 85, 62, 77, 36 | 198 s | same line twice, device lost, exit code 5 | | 3 | 978 | 472, 450, 361, 300, 300, 186, 117, 101, 79, 84, 80, 67, 62, 67 | 212 s | no device loss; label waits stall and the title's watchdog ends it, exit code 5 | In all three the present rate falls steadily, then the last intervals are one to four frames in 14 to 18 s with lines like: ```text GPU memory wait released after 5s without reaching its target (#6): address=0x4f8f980 op=>= target=0x11f6 value=0x11f5 stalled label 0x4f8f980 >= 0x11f6: waited by list … (order 4681), submitted to a type 2 queue, after waits [] radv/amdgpu: Not enough memory for command submission. vkd3d-proton: d3d12_command_queue_execute: Failed to submit queue(s), vr -4. ``` The kernel log has the matching `amdgpu: [drm] *ERROR* Not enough memory for command submission!` for runs 1 and 2. No `GPUVM fault` in any run. **Memory.** For run 3 I sampled the amdgpu counters (`mem_info_vram_used`, `mem_info_gtt_used`) and `MemAvailable` every 3 s, and then did the same for `main` (`8c56463`) with the preload as a control. MiB, time from launch: | | 45 s | 75 s | 105 s | 120 s | 135 s | 180 s | peak | | --- | --- | --- | --- | --- | --- | --- | --- | | `0e927be` VRAM | 8733 | 9079 | 12236 | 12239 | 12241 | 12256 | 12263 (card total 12272) | | `0e927be` GTT | 1237 | 1271 | 2084 | 3142 | 5693 | 7950 | 8488 (total 15913) | | `0e927be` MemAvailable | 17508 | 16140 | 13646 | 12480 | 9941 | 6506 | | | `main` + preload VRAM | 8442 | 8899 | 9179 | 9188 | 9188 | – | 9188 | | `main` + preload GTT | 1238 | 1277 | 1277 | 1280 | 1280 | – | 1295 | | `main` + preload MemAvailable | 18674 | 17731 | 16982 | 16774 | 16849 | – | | The control dies at 144 s at the remap batch (`-14`, as always with the preload), so the comparison only holds up to there. Up to that point the two start out the same, and from about 90 s this PR uses roughly 3 GB more VRAM, fills the card, and then GTT and system memory keep growing where the control is flat. I have not found what the extra memory is; one run each, so treat the numbers as a first look. A 16 GB card would have more room before this shows. **Lock errors:** `RtlReleaseSRWLockExclusive Lock … is not owned exclusive!` went up here, not down: 5,084 / 5,289 / 5,877 per run on `0e927be`, against 2,400 to 3,200 on `5a795cb` and about 520 on `main` with the preload. `Memory allocation failed, falling back to system memory` is about 470 per run on every build including `main`, so the two are not 1:1 on this card. Happy to rerun with extra logging (for example the live hold count and total held bytes over time) if that helps.
JeffreyBytes commented 2026-11-27 00:50:26 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-27T00:50:26Z.


Update, with a correction to the memory comparison above. I reran both sides with TUXBOX_TRACE_BUFFER_BACKING=1 and sampled the title's RssAnon as well. The growth starts at the page-remap batch, which is exactly where the main + preload control dies, so the control cannot tell this PR's overhead apart from what the title does after the remap. Please read the "3 GB more VRAM than main" above as "3 GB more than main had when it died", not as overhead of this PR.

What the traced runs show (0e927be no preload, 229 s; main 8c56463 + preload, 113 s; the trace is rate-limited to powers of two, so these are floors):

buffer backing path 0e927be before the remap batch main before the remap batch 0e927be at the end
imported / view 32768 32768 65536
page_hit / view 16384 16384 16384
span_hit / view 8192 8192 16384
page_open / view 512 512 8192
span_open / view 512 256 4096
imported_scattered / place_virtual_layout 16 – 16
  • Up to the remap batch the two builds are the same in every row, and so are VRAM and GTT.
  • After it, on 0e927be, fresh opens from views go up by 8 to 16 times while hits barely move. VRAM goes from about 9.1 GB to full (12.2 GB) within 30 s of the batch, GTT then climbs from 1.5 GB to 6 to 7 GB over the next two minutes, and in the last 10 s it jumps to exactly mem_info_gtt_total (15,913 MiB), which is when Not enough memory for command submission appears.
  • The title's RssAnon levels off at about 10 GB and stays flat while GTT keeps growing, so this is not the process's own private memory ballooning.
  • Scattered imports are rare here (16 to 31 in the run), so they are not the volume.

What I can't tell from this: whether the opens after the remap are the title legitimately streaming more than a 12 GB card can hold at 3840x2160, or imports that were retired by the remap staying alive (as far as I can read commands/page_mapping.rs, retiring only marks the pin not live, and the old heap, guard and hold stay until the title releases the resource) while their replacements are opened next to them. A count of live imported heaps and their total bytes, logged every few seconds, would settle it; I can run that if you add it or tell me where you'd want it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7206796149 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7206796149). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-11-27T00:50:26Z. --- **Update, with a correction to the memory comparison above.** I reran both sides with `TUXBOX_TRACE_BUFFER_BACKING=1` and sampled the title's `RssAnon` as well. The growth starts at the page-remap batch, which is exactly where the `main` + preload control dies, so the control cannot tell this PR's overhead apart from what the title does after the remap. Please read the "3 GB more VRAM than `main`" above as "3 GB more than `main` had when it died", not as overhead of this PR. What the traced runs show (`0e927be` no preload, 229 s; `main` `8c56463` + preload, 113 s; the trace is rate-limited to powers of two, so these are floors): | `buffer backing path` | `0e927be` before the remap batch | `main` before the remap batch | `0e927be` at the end | | --- | --- | --- | --- | | `imported` / view | 32768 | 32768 | 65536 | | `page_hit` / view | 16384 | 16384 | 16384 | | `span_hit` / view | 8192 | 8192 | 16384 | | `page_open` / view | 512 | 512 | **8192** | | `span_open` / view | 512 | 256 | **4096** | | `imported_scattered` / `place_virtual_layout` | 16 | – | 16 | - Up to the remap batch the two builds are the same in every row, and so are VRAM and GTT. - After it, on `0e927be`, fresh opens from views go up by 8 to 16 times while hits barely move. VRAM goes from about 9.1 GB to full (12.2 GB) within 30 s of the batch, GTT then climbs from 1.5 GB to 6 to 7 GB over the next two minutes, and in the last 10 s it jumps to exactly `mem_info_gtt_total` (15,913 MiB), which is when `Not enough memory for command submission` appears. - The title's `RssAnon` levels off at about 10 GB and stays flat while GTT keeps growing, so this is not the process's own private memory ballooning. - Scattered imports are rare here (16 to 31 in the run), so they are not the volume. What I can't tell from this: whether the opens after the remap are the title legitimately streaming more than a 12 GB card can hold at 3840x2160, or imports that were retired by the remap staying alive (as far as I can read `commands/page_mapping.rs`, retiring only marks the pin not live, and the old heap, guard and hold stay until the title releases the resource) while their replacements are opened next to them. A count of live imported heaps and their total bytes, logged every few seconds, would settle it; I can run that if you add it or tell me where you'd want it.
DrArroway commented 2026-11-27 01:00:53 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-27T01:00:53Z.


Rebased onto latest main (12e4b06) and pushed d50a51c addressing both @Valdi320's PrivateArena finding and @JeffreyBytes's memory/diagnostics follow-up:

Re: @Valdi320 (PrivateArena hold tracking & import retirement)

Good catch — HoldRecord.arenas wasn't tracked in Pool, so PrivateArena neither adopted a new CPU view when unheld nor notified d3d12 when promoted under a live hold. In d50a51c:

  • Pool::arena_holds tracking (xmem backing.rs): commit_hold / release_hold now maintain per-arena hold counts.
  • Unheld arena -> zero-copy PrivateView(cpu) (xmem private_views.rs): When a PrivateArena has no live hold (arena_holds == 0), mapping a new CPU view adopts it directly as SlotRole::Canonical (MEM_PRIVATE + PAGE_READWRITE), preserving bytes without a VEH fault or SharedSection downgrade (tested in unheld_private_arena_adopts_new_cpu_view_without_section_promotion).
  • Held-arena promotion retires d3d12 imports (xmem + d3d12): Exported TuxBoxSetBackingInvalidationCallback (registered once by d3d12 -> GPU_APERTURE.retire_range). When promote_faulting_alias transitions a still-held PrivateArena to SharedSection, xmem drops POOL and notifies all mapped guest VAs so ImportedHeap::is_live() flips to false, TextureAddress::is_stale() triggers re-import of the promoted backing, and PagePools never reuses the stale arena heap — while the old PrivateArena remains committed MEM_PRIVATE until release_physical_backing(hold) (tested in held_private_arena_promotion_notifies_invalidation_and_keeps_hold_live and retire_range_invalidates_imported_heap_and_prevents_cache_reuse).
  • (OS boundary note: once acquire_physical_backing hands out an anonymous MEM_PRIVATE arena pointer for amdgpu userptr, Windows/Wine cannot hardware-alias a different VA cpu != backing to that same private page mid-hold without retiring the old import — which the invalidation callback now coordinates cleanly.)

Re: @JeffreyBytes (memory reductions & live hold/arena trace)

Glad to hear CS has been rejected (-1) is 0/3 on the RX 6700 XT, and thanks for the TUXBOX_TRACE_BUFFER_BACKING=1 follow-up. d50a51c also adds three memory cleanups plus opt-in live hold/arena stats (TUXBOX_TRACE_XMEM_BACKING=1, logged every 5 s):

  • Skip GpuAlias RAM dirtying (xmem): map_private_page, map_private_contiguous, apply_alias, and detach_private_slot no longer populate or snapshot-copy SlotRole::GpuAlias pages, keeping GPU-only alias slots as untouched OS zero-pages instead of dirtying a duplicate copy of the GPU aperture.
  • Read-only TuxBoxIsPhysicalBacked (xmem + d3d12): place_gpu_target's is_backed_range check now queries Pool.mappings read-only instead of calling acquire_backing and allocating phantom PrivateArenas for unbacked GPU-only targets (is_physical_backed_does_not_allocate_private_arena_for_unbacked_gpu_alias).
  • Cache scattered piece heaps (d3d12 PagePools::pieces): import_scattered_buffer now reuses live piece ID3D12Heaps across scattered imports (scattered_imports_reuse_cached_piece_heaps).

Live TUXBOX_TRACE_XMEM_BACKING=1 numbers on RX 6900 XT (16 GB VRAM / 64 GB RAM, 3840x2160, d50a51c):

  • Pre-remap: pages=114,096 (7,131 MiB) | holds=458 | view_holds=9,149 (571 MiB) | live_arenas=0 (0 MiB) | deferred=0.
  • Post-remap -> 3D world (235.4 s, 0 CS rejections): holds grows to 12,865 (matching page_open=8192+ + span_open=4096+), while view_holds totals only 1,498 MiB (~1.5 GiB), live_arenas = 0 (0 MiB), and deferred drains cleanly across the remap (107 -> 1) before sitting at 1,531 pages (95 MiB) during world streaming.
  • On the 16 GB / 64 GB card, total VRAM + GTT rises from 14.8 GiB VRAM + 2.7 GiB GTT at DispatchMesh to 16.2 GiB VRAM + 12.3 GiB GTT (~28.5 GiB total) once 4K world textures stream and spill out of VRAM via vkd3d_allocate_device_memory. That sits just over a 12 GB VRAM / 32 GB RAM card's ~27.5 GiB combined VRAM+GTT ceiling (12,272 + 15,913 MiB), which matches the Not enough memory for command submission failure you saw — with XMem holds themselves accounting for ~1.5 GiB of that total rather than leaking unboundedly.

(Unit & hygiene checks on d50a51c: tuxbox-xmem 13/13 pass, tuxbox-d3d12 device::heap::backing on RADV 15/15 pass, tests.test_repository_hygiene 5/5 pass.)

<!-- greyfinch-sync:brcly/TuxBox:comment:7206938099 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7206938099). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-27T01:00:53Z. --- Rebased onto latest `main` (`12e4b06`) and pushed `d50a51c` addressing both @Valdi320's `PrivateArena` finding and @JeffreyBytes's memory/diagnostics follow-up: ### Re: @Valdi320 (`PrivateArena` hold tracking & import retirement) Good catch — `HoldRecord.arenas` wasn't tracked in `Pool`, so `PrivateArena` neither adopted a new CPU view when unheld nor notified `d3d12` when promoted under a live hold. In `d50a51c`: - **`Pool::arena_holds` tracking (`xmem` `backing.rs`):** `commit_hold` / `release_hold` now maintain per-arena hold counts. - **Unheld arena -> zero-copy `PrivateView(cpu)` (`xmem` `private_views.rs`):** When a `PrivateArena` has no live hold (`arena_holds == 0`), mapping a new CPU view adopts it directly as `SlotRole::Canonical` (`MEM_PRIVATE` + `PAGE_READWRITE`), preserving bytes without a VEH fault or `SharedSection` downgrade (tested in `unheld_private_arena_adopts_new_cpu_view_without_section_promotion`). - **Held-arena promotion retires `d3d12` imports (`xmem` + `d3d12`):** Exported `TuxBoxSetBackingInvalidationCallback` (registered once by `d3d12` -> `GPU_APERTURE.retire_range`). When `promote_faulting_alias` transitions a still-held `PrivateArena` to `SharedSection`, `xmem` drops `POOL` and notifies all mapped guest VAs so `ImportedHeap::is_live()` flips to `false`, `TextureAddress::is_stale()` triggers re-import of the promoted backing, and `PagePools` never reuses the stale arena heap — while the old `PrivateArena` remains committed `MEM_PRIVATE` until `release_physical_backing(hold)` (tested in `held_private_arena_promotion_notifies_invalidation_and_keeps_hold_live` and `retire_range_invalidates_imported_heap_and_prevents_cache_reuse`). - *(OS boundary note: once `acquire_physical_backing` hands out an anonymous `MEM_PRIVATE` arena pointer for `amdgpu` userptr, Windows/Wine cannot hardware-alias a different VA `cpu != backing` to that same private page mid-hold without retiring the old import — which the invalidation callback now coordinates cleanly.)* ### Re: @JeffreyBytes (memory reductions & live hold/arena trace) Glad to hear `CS has been rejected (-1)` is 0/3 on the RX 6700 XT, and thanks for the `TUXBOX_TRACE_BUFFER_BACKING=1` follow-up. `d50a51c` also adds three memory cleanups plus opt-in live hold/arena stats (`TUXBOX_TRACE_XMEM_BACKING=1`, logged every 5 s): - **Skip `GpuAlias` RAM dirtying (`xmem`):** `map_private_page`, `map_private_contiguous`, `apply_alias`, and `detach_private_slot` no longer populate or snapshot-copy `SlotRole::GpuAlias` pages, keeping GPU-only alias slots as untouched OS zero-pages instead of dirtying a duplicate copy of the GPU aperture. - **Read-only `TuxBoxIsPhysicalBacked` (`xmem` + `d3d12`):** `place_gpu_target`'s `is_backed_range` check now queries `Pool.mappings` read-only instead of calling `acquire_backing` and allocating phantom `PrivateArena`s for unbacked GPU-only targets (`is_physical_backed_does_not_allocate_private_arena_for_unbacked_gpu_alias`). - **Cache scattered piece heaps (`d3d12` `PagePools::pieces`):** `import_scattered_buffer` now reuses live piece `ID3D12Heap`s across scattered imports (`scattered_imports_reuse_cached_piece_heaps`). **Live `TUXBOX_TRACE_XMEM_BACKING=1` numbers on RX 6900 XT (16 GB VRAM / 64 GB RAM, 3840x2160, `d50a51c`):** - **Pre-remap:** `pages=114,096 (7,131 MiB)` | `holds=458` | `view_holds=9,149 (571 MiB)` | `live_arenas=0 (0 MiB)` | `deferred=0`. - **Post-remap -> 3D world (`235.4 s`, `0` CS rejections):** `holds` grows to `12,865` (matching `page_open=8192+` + `span_open=4096+`), while **`view_holds` totals only `1,498 MiB` (~1.5 GiB)**, **`live_arenas = 0 (0 MiB)`**, and `deferred` drains cleanly across the remap (`107 -> 1`) before sitting at `1,531` pages (`95 MiB`) during world streaming. - On the 16 GB / 64 GB card, total `VRAM + GTT` rises from `14.8 GiB VRAM + 2.7 GiB GTT` at `DispatchMesh` to **`16.2 GiB VRAM + 12.3 GiB GTT` (~28.5 GiB total)** once 4K world textures stream and spill out of VRAM via `vkd3d_allocate_device_memory`. That sits just over a 12 GB VRAM / 32 GB RAM card's `~27.5 GiB` combined VRAM+GTT ceiling (`12,272 + 15,913 MiB`), which matches the `Not enough memory for command submission` failure you saw — with XMem holds themselves accounting for ~`1.5 GiB` of that total rather than leaking unboundedly. *(Unit & hygiene checks on `d50a51c`: `tuxbox-xmem` `13/13` pass, `tuxbox-d3d12` `device::heap::backing` on RADV `15/15` pass, `tests.test_repository_hygiene` `5/5` pass.)*
JeffreyBytes commented 2026-11-27 01:43:53 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-27T01:43:53Z.


Retest of d50a51c on the RX 6700 XT, two no-preload runs with TUXBOX_TRACE_XMEM_BACKING=1. The trace agrees with your reading: the holds are small and nothing accumulates, and what ends the runs on this card is total GPU memory at 3840x2160.

run ended at how CS has been rejected
1 243 s Not enough memory for command submission (3 lines), device lost, exit code 3 0
2 171 s label-wait stall, title watchdog, exit code 5, no device loss 0

backing stats, run 1 (run 2 is the same shape):

pages=14320 (895 MiB)    holds=1    view_holds=2784 (174 MiB)   arena_holds=0 live_arenas=0 (0 MiB) deferred=0
pages=114096 (7131 MiB)  holds=147  view_holds=8986 (561 MiB)   arena_holds=0 live_arenas=0 (0 MiB) deferred=0      before the remap batch
pages=114096 (7131 MiB)  holds=907  view_holds=9892 (618 MiB)   arena_holds=0 live_arenas=0 (0 MiB) deferred=139
pages=114096 (7131 MiB)  holds=5650 view_holds=17456 (1091 MiB) arena_holds=0 live_arenas=0 (0 MiB) deferred=4
pages=114096 (7131 MiB)  holds=9938 view_holds=22039 (1377 MiB) arena_holds=0 live_arenas=0 (0 MiB) deferred=382    last sample

So about 1.4 GiB under hold at the end, no live arenas, and deferred drains. Meanwhile the amdgpu counters go the same way as on 0e927be: VRAM is full (12.2 GB) about 30 s after the remap batch, GTT climbs from 2 GB to 6 to 9 GB, and in run 1 it reaches mem_info_gtt_total (15,913 MiB) at the moment the submit is refused. That is the 12,272 + 15,913 MiB ceiling you worked out. Neither run left the loading screen, so I can't say how far past it a 12 GB / 32 GB machine would get; the three memory reductions did not visibly move the point where VRAM fills here.

From this card's side I have nothing left against the PR: the -1 and -14 rejections are gone in 7 of 7 no-preload runs since 0e927be, the page-remap batch passes every time, and the menu and loading screen run at 300 to 1,000 presents per 10 s where the copy path on main gives about 6. What remains here is the title's memory demand at this resolution, which is a separate problem from this PR.

One thing that is still different from your card, in case it means something: RtlReleaseSRWLockExclusive Lock … is not owned exclusive! is 6,571 and 5,331 per run here on d50a51c (about 520 on main with the preload), where you saw 3 to 5.

<!-- greyfinch-sync:brcly/TuxBox:comment:7207531152 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7207531152). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-11-27T01:43:53Z. --- Retest of `d50a51c` on the RX 6700 XT, two no-preload runs with `TUXBOX_TRACE_XMEM_BACKING=1`. The trace agrees with your reading: the holds are small and nothing accumulates, and what ends the runs on this card is total GPU memory at 3840x2160. | run | ended at | how | `CS has been rejected` | | --- | --- | --- | --- | | 1 | 243 s | `Not enough memory for command submission` (3 lines), device lost, exit code 3 | 0 | | 2 | 171 s | label-wait stall, title watchdog, exit code 5, no device loss | 0 | `backing stats`, run 1 (run 2 is the same shape): ```text pages=14320 (895 MiB) holds=1 view_holds=2784 (174 MiB) arena_holds=0 live_arenas=0 (0 MiB) deferred=0 pages=114096 (7131 MiB) holds=147 view_holds=8986 (561 MiB) arena_holds=0 live_arenas=0 (0 MiB) deferred=0 before the remap batch pages=114096 (7131 MiB) holds=907 view_holds=9892 (618 MiB) arena_holds=0 live_arenas=0 (0 MiB) deferred=139 pages=114096 (7131 MiB) holds=5650 view_holds=17456 (1091 MiB) arena_holds=0 live_arenas=0 (0 MiB) deferred=4 pages=114096 (7131 MiB) holds=9938 view_holds=22039 (1377 MiB) arena_holds=0 live_arenas=0 (0 MiB) deferred=382 last sample ``` So about 1.4 GiB under hold at the end, no live arenas, and `deferred` drains. Meanwhile the amdgpu counters go the same way as on `0e927be`: VRAM is full (12.2 GB) about 30 s after the remap batch, GTT climbs from 2 GB to 6 to 9 GB, and in run 1 it reaches `mem_info_gtt_total` (15,913 MiB) at the moment the submit is refused. That is the 12,272 + 15,913 MiB ceiling you worked out. Neither run left the loading screen, so I can't say how far past it a 12 GB / 32 GB machine would get; the three memory reductions did not visibly move the point where VRAM fills here. From this card's side I have nothing left against the PR: the `-1` and `-14` rejections are gone in 7 of 7 no-preload runs since `0e927be`, the page-remap batch passes every time, and the menu and loading screen run at 300 to 1,000 presents per 10 s where the copy path on `main` gives about 6. What remains here is the title's memory demand at this resolution, which is a separate problem from this PR. One thing that is still different from your card, in case it means something: `RtlReleaseSRWLockExclusive Lock … is not owned exclusive!` is 6,571 and 5,331 per run here on `d50a51c` (about 520 on `main` with the preload), where you saw 3 to 5.
gtb-sbe commented 2026-11-27 13:12:07 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-11-27T13:12:07Z.


RDNA4 results for d50a51c, and a question about acceleration structures for anyone who got past the remap batch.

Setup: RX 9060 XT 16 GB (RADV GFX1200, Mesa 26.2.6), Ryzen 7 5800X, 31 GB, kernel 6.18.60, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline at 3840x2160, no preload.

What works on this card: the menu runs at about 90 fps and the loading after the picker at about 9 fps. On the copy path it was 1-2 fps and then 0.6 fps. The page-remap batch passes, holds go from about 460 to 9,600-11,000, and nothing accumulates. Card VRAM peaks at 13.7 to 15.1 of 16 GB, with no CS has been rejected and no Not enough memory. Three runs reached Game Running with SRL fbk_stry000_FBK_STRY000_INTRO, according to the title's own crash logs. I see no RtlReleaseSRWLockExclusive ... is not owned lines at all, so the 5-6k per run on the RX 6700 XT don't show up on RDNA4.

What fails: right after the remap batch, vkd3d drops every bottom-level AS build:

err:vkd3d-proton:d3d12_command_list_build_raytracing_blas_and_tlas: Failed to place destAccelerationStructure. Dropping call.

There were between 147 and 776 per run, starting at world entry. To see where they go, I added a local diagnostic to build_raytracing.rs that logs builds whose destination blas::resolve does not find (d50a51c + #294 + the diagnostic):

  • Every logged build is BOTTOM_LEVEL, 1.4 KB to 12 MB, at destinations from 0x17421bb00 to 0x17c264500, about 128 MiB in one range.
  • None of the provider's AS, upload or default buffer registries covers any of them, so the guest address goes to vkd3d unchanged and vkd3d cannot place it.
  • VirtualQuery puts all of them in one allocation at 0x14b070000, about 2.2 GiB, MEM_PRIVATE, committed, read-write. It is not XMem-backed (is_backed_range is false), so #258's backing exports are probably not involved.
  • In the code, only resources created through depth::wrap reach blas.register: committed, placed-in-heap and reserved. Buffers from place_virtual and place_virtual_layout (CreatePlacedResourceX at a guest address) don't. So a pool placed at a guest address would never be known to blas::resolve. I haven't confirmed yet which call creates this one.

All three runs end within a few minutes. Each title crash log shows Unsignaled CrossQueueBarrier, and the cause is not proven:

  • first run: a page fault at address 0x0 from SQC (data) on a compute ring, then device lost;
  • second run, with #294 so the direct-indexed dispatches run: a page fault at the unmapped 0x8003a8b1f000 from TCP on the gfx ring, about a minute into the intro;
  • third run, same build: no GPU fault. The title's watchdog ends it after 7m38s of Game Running, which looks like #215.

A ray query against BLASes that were never built would fit the two faults, but so would other things, such as the released label waits just before. With #302 and #306 merged, more of the shadow passes now trace these structures, so it will likely matter more on current main.

Question: do your logs past the remap batch contain Failed to place destAccelerationStructure, @DrArroway (the RX 6900 XT run that reached Game Running) and @JeffreyBytes? And @NickStallman, do the NVIDIA runs on main without #258 show it? From the region above I'd expect it everywhere, which would make it a separate gap rather than something in this PR. If so, I'll open an issue for it and keep this thread for the #258 results.

<!-- greyfinch-sync:brcly/TuxBox:comment:7219183163 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7219183163). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-11-27T13:12:07Z. --- RDNA4 results for `d50a51c`, and a question about acceleration structures for anyone who got past the remap batch. **Setup:** RX 9060 XT 16 GB (RADV GFX1200, Mesa 26.2.6), Ryzen 7 5800X, 31 GB, kernel 6.18.60, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline at 3840x2160, no preload. **What works on this card:** the menu runs at about 90 fps and the loading after the picker at about 9 fps. On the copy path it was 1-2 fps and then 0.6 fps. The page-remap batch passes, holds go from about 460 to 9,600-11,000, and nothing accumulates. Card VRAM peaks at 13.7 to 15.1 of 16 GB, with no `CS has been rejected` and no `Not enough memory`. Three runs reached `Game Running` with SRL `fbk_stry000_FBK_STRY000_INTRO`, according to the title's own crash logs. I see no `RtlReleaseSRWLockExclusive ... is not owned` lines at all, so the 5-6k per run on the RX 6700 XT don't show up on RDNA4. **What fails:** right after the remap batch, vkd3d drops every bottom-level AS build: ```text err:vkd3d-proton:d3d12_command_list_build_raytracing_blas_and_tlas: Failed to place destAccelerationStructure. Dropping call. ``` There were between 147 and 776 per run, starting at world entry. To see where they go, I added a local diagnostic to `build_raytracing.rs` that logs builds whose destination `blas::resolve` does not find (`d50a51c` + #294 + the diagnostic): - Every logged build is `BOTTOM_LEVEL`, 1.4 KB to 12 MB, at destinations from `0x17421bb00` to `0x17c264500`, about 128 MiB in one range. - None of the provider's AS, upload or default buffer registries covers any of them, so the guest address goes to vkd3d unchanged and vkd3d cannot place it. - `VirtualQuery` puts all of them in one allocation at `0x14b070000`, about 2.2 GiB, `MEM_PRIVATE`, committed, read-write. It is not XMem-backed (`is_backed_range` is false), so #258's backing exports are probably not involved. - In the code, only resources created through `depth::wrap` reach `blas.register`: committed, placed-in-heap and reserved. Buffers from `place_virtual` and `place_virtual_layout` (`CreatePlacedResourceX` at a guest address) don't. So a pool placed at a guest address would never be known to `blas::resolve`. I haven't confirmed yet which call creates this one. All three runs end within a few minutes. Each title crash log shows `Unsignaled CrossQueueBarrier`, and the cause is not proven: - first run: a page fault at address `0x0` from `SQC (data)` on a compute ring, then device lost; - second run, with #294 so the direct-indexed dispatches run: a page fault at the unmapped `0x8003a8b1f000` from `TCP` on the gfx ring, about a minute into the intro; - third run, same build: no GPU fault. The title's watchdog ends it after 7m38s of `Game Running`, which looks like #215. A ray query against BLASes that were never built would fit the two faults, but so would other things, such as the released label waits just before. With #302 and #306 merged, more of the shadow passes now trace these structures, so it will likely matter more on current `main`. **Question:** do your logs past the remap batch contain `Failed to place destAccelerationStructure`, @DrArroway (the RX 6900 XT run that reached `Game Running`) and @JeffreyBytes? And @NickStallman, do the NVIDIA runs on `main` without #258 show it? From the region above I'd expect it everywhere, which would make it a separate gap rather than something in this PR. If so, I'll open an issue for it and keep this thread for the #258 results.
brcly commented 2026-11-27 14:30:43 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-27T14:30:43Z.


Thanks for this. On current main plus this PR, and on the PR head alone, buffer-remap fails on an RTX 4070 Ti SUPER and an AMD Raphael iGPU (RADV): d3d12-buffer-remap failed: initial CPU alias differs. It passes at 4a8d521, 0c9670b, 237ef52 and the base 12e4b06, and fails at d50a51c. Undoing the GpuAlias populate skip, the unheld-arena Canonical role, or the removed populate_page_bytes call in copy_mappings.rs, each on its own, did not fix it. Could you take a look? The RtlReleaseSRWLockExclusive ... not owned count JeffreyBytes reported would be good to explain before merging too.

<!-- greyfinch-sync:brcly/TuxBox:comment:7220874730 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7220874730). Originally posted by [brcly](https://github.com/brcly) on 2026-11-27T14:30:43Z. --- Thanks for this. On current `main` plus this PR, and on the PR head alone, `buffer-remap` fails on an RTX 4070 Ti SUPER and an AMD Raphael iGPU (RADV): `d3d12-buffer-remap failed: initial CPU alias differs`. It passes at `4a8d521`, `0c9670b`, `237ef52` and the base `12e4b06`, and fails at `d50a51c`. Undoing the `GpuAlias` populate skip, the unheld-arena `Canonical` role, or the removed `populate_page_bytes` call in `copy_mappings.rs`, each on its own, did not fix it. Could you take a look? The `RtlReleaseSRWLockExclusive ... not owned` count JeffreyBytes reported would be good to explain before merging too.
DrArroway commented 2026-11-27 16:26:18 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-27T16:26:18Z.


Quick update while a fresh test run on current main (c2a59af) + #258 finishes:

  • buffer-remap (@brcly): Found the cause — skipping populate_page_bytes for SlotRole::GpuAlias in both private_views.rs (initial map) and copy_mappings.rs (apply_alias remap) left the destination zero-filled for CPU reads in buffer_import_guest.cpp, which is why reverting only one hunk alone didn't fix it. Reverted both locally on top of c2a59af and verified buffer-remap, buffer-unmap-released, and buffer-unmap-alive all PASS on RX 6900 XT (1002:73bf, GE-Proton11-14). I'll push the rebased branch once the fresh main run finishes.
  • RtlReleaseSRWLockExclusive ... not owned (@brcly, @JeffreyBytes): TuxBox runtime/ makes no SRWLock calls. This is an upstream vkd3d-proton double-unlock in libs/vkd3d/memory.c (vkd3d_try_allocate_device_memory): line 1061 locks memory_info->budget_lock (rebar_budget && respect_budget), line 1114 unlocks it on vkAllocateMemory failure while leaving rebar_budget true, and line 1161 unconditionally unlocks it a second time (after lines 1130–1131 skip re-locking). Every failed ReBAR-budgeted allocation attempt therefore triggers one warning, matching 0 on RX 9060 XT, 3–5 on RX 6900 XT, and ~5.3k–6.6k on 12 GB RX 6700 XT once VRAM fills.
  • Failed to place destAccelerationStructure (@gtb-sbe): My earlier logs from d50a51c weren't kept across reboot — running a fresh test on current main (c2a59af) + #258 now and will report back with the numbers shortly.
<!-- greyfinch-sync:brcly/TuxBox:comment:7223260466 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7223260466). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-27T16:26:18Z. --- Quick update while a fresh test run on current `main` (`c2a59af`) + `#258` finishes: - **`buffer-remap` (@brcly):** Found the cause — skipping `populate_page_bytes` for `SlotRole::GpuAlias` in both `private_views.rs` (initial map) and `copy_mappings.rs` (`apply_alias` remap) left the destination zero-filled for CPU reads in `buffer_import_guest.cpp`, which is why reverting only one hunk alone didn't fix it. Reverted both locally on top of `c2a59af` and verified `buffer-remap`, `buffer-unmap-released`, and `buffer-unmap-alive` all PASS on RX 6900 XT (`1002:73bf`, GE-Proton11-14). I'll push the rebased branch once the fresh `main` run finishes. - **`RtlReleaseSRWLockExclusive ... not owned` (@brcly, @JeffreyBytes):** TuxBox `runtime/` makes no `SRWLock` calls. This is an upstream `vkd3d-proton` double-unlock in `libs/vkd3d/memory.c` (`vkd3d_try_allocate_device_memory`): line 1061 locks `memory_info->budget_lock` (`rebar_budget && respect_budget`), line 1114 unlocks it on `vkAllocateMemory` failure while leaving `rebar_budget` true, and line 1161 unconditionally unlocks it a second time (after lines 1130–1131 skip re-locking). Every failed ReBAR-budgeted allocation attempt therefore triggers one warning, matching `0` on RX 9060 XT, `3–5` on RX 6900 XT, and `~5.3k–6.6k` on 12 GB RX 6700 XT once VRAM fills. - **`Failed to place destAccelerationStructure` (@gtb-sbe):** My earlier logs from `d50a51c` weren't kept across reboot — running a fresh test on current `main` (`c2a59af`) + `#258` now and will report back with the numbers shortly.
NickStallman commented 2026-11-27 16:42:50 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T16:42:50Z.


@gtb-sbe, answering your question for NVIDIA (RTX 5090, 620.70.10, GE-Proton11-14). These are without #258, on main from 9168b2f through 95480b5 plus our diagnostic branches, in runs that reached the story world:

  • Failed to place destAccelerationStructure: 0 occurrences in 7 runs. None of those logs show a BuildRaytracingAccelerationStructure call reaching vkd3d at all.
  • What builds the BVH on this card instead: the retail XboxBvhBuilder.dll's own compute kernels. A probe that tagged pipelines created with that DLL on the stack found 52 kernels:
    • 9 run;
    • 38 are stand-ins because they're standard DXIL calling Xbox xbox.* intrinsics, which dxil-spirv can't define (s_load_dword_with_cache, global_load_dword*_with_cache, LaneSwizzle, Med3_F32, …);
    • 5 are stand-ins because dxil-spirv's reader rejects their insertvalue ("Unhandled instruction!").
      Of 3,621 builder dispatches, 3,021 ran as stand-ins.
  • Same memory as yours: all four TLAS addresses and 41 of the BLAS addresses sit in one private allocation at 0x14b070000 (about 2.17 GiB, 4 allocations). Its BLAS run, 0x174222000–0x178088000, is inside the destination range you logged. The other 123 BLAS addresses (from the 64-byte instance records bound beside each TLAS) sit in small mapped views inside a 54 GiB reserved span at 0x300200000.
  • Nothing is built here: a re-read of each TLAS 2, 15 and 60 s after binding, on the CPU and through a GPU copy, was all zeros.

So on NVIDIA the structures aren't built by DXR calls that vkd3d drops; the builder's own kernels mostly don't run. Why your RDNA4 run sends the same region through DXR builds while ours doesn't isn't established. It may be a capability check in the builder; that's a guess. We're working on lowering those xbox.* intrinsics, and 42 of the 43 lower on the CPU so far.

<!-- greyfinch-sync:brcly/TuxBox:comment:7223583428 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7223583428). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T16:42:50Z. --- @gtb-sbe, answering your question for NVIDIA (RTX 5090, 620.70.10, GE-Proton11-14). These are without #258, on `main` from 9168b2f through 95480b5 plus our diagnostic branches, in runs that reached the story world: - **`Failed to place destAccelerationStructure`:** 0 occurrences in 7 runs. None of those logs show a `BuildRaytracingAccelerationStructure` call reaching vkd3d at all. - **What builds the BVH on this card instead:** the retail `XboxBvhBuilder.dll`'s own compute kernels. A probe that tagged pipelines created with that DLL on the stack found 52 kernels: - 9 run; - 38 are stand-ins because they're standard DXIL calling Xbox `xbox.*` intrinsics, which dxil-spirv can't define (`s_load_dword_with_cache`, `global_load_dword*_with_cache`, `LaneSwizzle`, `Med3_F32`, …); - 5 are stand-ins because dxil-spirv's reader rejects their `insertvalue` ("Unhandled instruction!"). Of 3,621 builder dispatches, 3,021 ran as stand-ins. - **Same memory as yours:** all four TLAS addresses and 41 of the BLAS addresses sit in one private allocation at `0x14b070000` (about 2.17 GiB, 4 allocations). Its BLAS run, `0x174222000`–`0x178088000`, is inside the destination range you logged. The other 123 BLAS addresses (from the 64-byte instance records bound beside each TLAS) sit in small mapped views inside a 54 GiB reserved span at `0x300200000`. - **Nothing is built here:** a re-read of each TLAS 2, 15 and 60 s after binding, on the CPU and through a GPU copy, was all zeros. So on NVIDIA the structures aren't built by DXR calls that vkd3d drops; the builder's own kernels mostly don't run. Why your RDNA4 run sends the same region through DXR builds while ours doesn't isn't established. It may be a capability check in the builder; that's a guess. We're working on lowering those `xbox.*` intrinsics, and 42 of the 43 lower on the CPU so far.
NickStallman commented 2026-11-27 16:46:23 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-27T16:46:23Z.


Correction to my comment above: those NVIDIA runs had the package's own XboxBvhBuilder.dll staged, not TuxBox's build/bvh one that docs/PROJECTSCARLETT.md says to use. Our run script missed it. That alone explains why we saw the builder's kernels and you saw DXR builds. TuxBox's builder forwards every build to the command list and never dispatches a kernel. So the "0 Failed to place destAccelerationStructure" and the stand-in counts describe the retail-builder setup, not the documented one. The address findings still hold: the destination pool is 0x14b070000, about 2.17 GiB, MEM_PRIVATE, and the BLAS runs fall inside your range. I'm rerunning with the documented staging and will report whether the dropped builds appear on NVIDIA too.

<!-- greyfinch-sync:brcly/TuxBox:comment:7223652793 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7223652793). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-27T16:46:23Z. --- Correction to my comment above: those NVIDIA runs had the package's own `XboxBvhBuilder.dll` staged, not TuxBox's `build/bvh` one that docs/PROJECTSCARLETT.md says to use. Our run script missed it. That alone explains why we saw the builder's kernels and you saw DXR builds. TuxBox's builder forwards every build to the command list and never dispatches a kernel. So the "0 `Failed to place destAccelerationStructure`" and the stand-in counts describe the retail-builder setup, not the documented one. The address findings still hold: the destination pool is `0x14b070000`, about 2.17 GiB, `MEM_PRIVATE`, and the BLAS runs fall inside your range. I'm rerunning with the documented staging and will report whether the dropped builds appear on NVIDIA too.
Kayotic1337 commented 2026-11-27 17:28:10 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-27T17:28:10Z.


RDNA4 results for d50a51c on current main (c2a59af, includes #294, #296, #298, #301, #303).

Setup: RX 9070 XT 16 GB (RADV GFX1201, Mesa 26.3.1), kernel 7.3.6, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline, no preload.

What #258 changes here: without it the menu runs at about 1 fps on the copy path; with it the menu and loading are responsive again (280-300 presents per 10 s in TuxBox's counter; that counts presents, not distinct title frames).

Things you asked about:

  • RtlReleaseSRWLockExclusive ... is not owned exclusive!: 1 per run, always the same lock. In the VKD3D_CONFIG=fault run it is the line right before vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory, on the same thread, about 20 s after Failed to allocate 131072 bytes on memory type 5 / type 10 and vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e. So here it seems to come with the out-of-VRAM fallback, which could explain why a 12 GB card sees thousands of them. That is a correlation from line order, not proven. Default WINEDEBUG from backend_log.py (-all,err+all,warn+debugstr,warn+seh), so it is not filtered. That fits gtb-sbe's 0 on the 9060 XT: the 5-6k per run look specific to the 6700 XT.
  • Failed to place destAccelerationStructure: 0 in every run.
  • CS has been rejected / Not enough memory: 0, but see the allocation failures above.
  • buffer-remap: fails here too, with the same message: d3d12-buffer-remap failed: initial CPU alias differs (tuxbox.py check on main + d50a51c, GE-Proton11-14, adapter 1002:7550). The other 10 regression controls pass, including buffer-import, buffer-unmap-alive and buffer-unmap-released, and so do all other check steps. So it is not specific to NVIDIA or the Raphael iGPU.

How far it gets (4 runs, each loading the same story save; the title's crash log reports SRL int_prolo_int_prolo_ext, SRL state Prestream, title crash log Unsignaled CrossQueueBarrier, Game Physical ~2188/2305 MB):

  1. Title watchdog, exit code 5, no GPU fault, no devcoredump. Two GPU memory wait released after 5s on one label at value = target - 1.

  2. After the save loads, the game shows at most two barely recognizable frames (one with a subtitle line), then after ~2 min a gfx ring timeout (signaled 1933026, emitted 1933028) with no page fault in the devcoredump (fault status 0x0).

  3. (RADV_DEBUG=hang) compute ring comp_1.1.0 TCP permission fault, write, at 0x80032ebe0000-0x80032ebe9000 (GCVM_L2_PROTECTION_FAULT_STATUS 0x741041, PERMISSION_FAULTS 0x4, MAPPING_ERROR 0), then ring timeout. The released memory wait in this run came after the hang, so it looks like a consequence, not the cause.

  4. (VKD3D_CONFIG=fault) vkd3d's device-fault report: WriteInvalid at 0x80044fd40000, "Fault address is currently unmapped. This is very likely use-after-free." The address history shows four short-lived VRAM heaps at that VA (VkBuffer [global-buffer], memory type 0; 3.68 GB, 985 MB twice with sparse unbinds, 152 MB), each bound and freed within 0.5-2.5 s. The last was freed 12 s before a compute dispatch wrote through the stale address (comp_1.0.1, TCP, 0x541041). So the permission faults look like writes into freed heaps rather than read-only views. The same run retired 24 stale GPU imports after page remaps (page remap replaced imported range ... retired stale GPU import) shortly before VRAM ran out. I haven't found which path creates and frees those heaps yet, so I can't say whether #258 is involved.

The fault at 0x0 from SQC that I reported in #289 has not come back on this main.

<!-- greyfinch-sync:brcly/TuxBox:comment:7224440037 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7224440037). Originally posted by [Kayotic1337](https://github.com/Kayotic1337) on 2026-11-27T17:28:10Z. --- RDNA4 results for `d50a51c` on current `main` (`c2a59af`, includes #294, #296, #298, #301, #303). **Setup:** RX 9070 XT 16 GB (RADV GFX1201, Mesa 26.3.1), kernel 7.3.6, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline, no preload. **What #258 changes here:** without it the menu runs at about 1 fps on the copy path; with it the menu and loading are responsive again (280-300 presents per 10 s in TuxBox's counter; that counts presents, not distinct title frames). **Things you asked about:** - `RtlReleaseSRWLockExclusive ... is not owned exclusive!`: 1 per run, always the same lock. In the `VKD3D_CONFIG=fault` run it is the line right before `vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory`, on the same thread, about 20 s after `Failed to allocate 131072 bytes on memory type 5` / `type 10` and `vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e`. So here it seems to come with the out-of-VRAM fallback, which could explain why a 12 GB card sees thousands of them. That is a correlation from line order, not proven. Default `WINEDEBUG` from `backend_log.py` (`-all,err+all,warn+debugstr,warn+seh`), so it is not filtered. That fits gtb-sbe's 0 on the 9060 XT: the 5-6k per run look specific to the 6700 XT. - `Failed to place destAccelerationStructure`: 0 in every run. - `CS has been rejected` / `Not enough memory`: 0, but see the allocation failures above. - `buffer-remap`: **fails here too**, with the same message: `d3d12-buffer-remap failed: initial CPU alias differs` (`tuxbox.py check` on `main` + `d50a51c`, GE-Proton11-14, adapter `1002:7550`). The other 10 regression controls pass, including `buffer-import`, `buffer-unmap-alive` and `buffer-unmap-released`, and so do all other check steps. So it is not specific to NVIDIA or the Raphael iGPU. **How far it gets (4 runs, each loading the same story save; the title's crash log reports SRL `int_prolo_int_prolo_ext`, SRL state `Prestream`, title crash log `Unsignaled CrossQueueBarrier`, Game Physical ~2188/2305 MB):** 1. Title watchdog, exit code 5, no GPU fault, no devcoredump. Two `GPU memory wait released after 5s` on one label at `value = target - 1`. 2. After the save loads, the game shows at most two barely recognizable frames (one with a subtitle line), then after ~2 min a gfx ring timeout (`signaled 1933026, emitted 1933028`) with no page fault in the devcoredump (fault status `0x0`). 3. (`RADV_DEBUG=hang`) compute ring `comp_1.1.0` TCP **permission** fault, write, at `0x80032ebe0000`-`0x80032ebe9000` (`GCVM_L2_PROTECTION_FAULT_STATUS 0x741041`, `PERMISSION_FAULTS 0x4`, `MAPPING_ERROR 0`), then ring timeout. The released memory wait in this run came after the hang, so it looks like a consequence, not the cause. 4. (`VKD3D_CONFIG=fault`) vkd3d's device-fault report: `WriteInvalid` at `0x80044fd40000`, "Fault address is currently unmapped. This is very likely use-after-free." The address history shows four short-lived VRAM heaps at that VA (`VkBuffer [global-buffer]`, memory type 0; 3.68 GB, 985 MB twice with sparse unbinds, 152 MB), each bound and freed within 0.5-2.5 s. The last was freed 12 s before a compute dispatch wrote through the stale address (`comp_1.0.1`, TCP, `0x541041`). So the permission faults look like writes into freed heaps rather than read-only views. The same run retired 24 stale GPU imports after page remaps (`page remap replaced imported range ... retired stale GPU import`) shortly before VRAM ran out. I haven't found which path creates and frees those heaps yet, so I can't say whether #258 is involved. The fault at `0x0` from `SQC` that I reported in #289 has not come back on this `main`.
Kayotic1337 commented 2026-11-27 17:53:48 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-27T17:53:48Z.


Correction to my comment above: the vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e lines (after Failed to allocate ... on memory type 5 / type 10) are not a sign of VRAM running out. In a later run they already appear right after vkd3d starts, before the menu, so they are failed host-pointer imports. The VRAM-related line is only vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory, and the single RtlReleaseSRWLockExclusive warning sits right before that line. I can't say from this whether the import failures matter for the warning on the 6700 XT.

<!-- greyfinch-sync:brcly/TuxBox:comment:7224901825 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7224901825). Originally posted by [Kayotic1337](https://github.com/Kayotic1337) on 2026-11-27T17:53:48Z. --- Correction to my comment above: the `vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e` lines (after `Failed to allocate ... on memory type 5` / `type 10`) are not a sign of VRAM running out. In a later run they already appear right after vkd3d starts, before the menu, so they are failed host-pointer imports. The VRAM-related line is only `vkd3d_allocate_device_memory: Memory allocation failed, falling back to system memory`, and the single `RtlReleaseSRWLockExclusive` warning sits right before that line. I can't say from this whether the import failures matter for the warning on the 6700 XT.
DrArroway commented 2026-11-27 17:59:26 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-27T17:59:26Z.


Rebased onto main (c2a59af) and pushed fcb5849 addressing the buffer-remap regression (@brcly, @Kayotic1337), the RtlReleaseSRWLockExclusive question (@brcly, @JeffreyBytes, @Kayotic1337), and one placed-texture writeback bug surfaced on main:

1. buffer-remap failure (initial CPU alias differs) — Fixed

  • Reverted the SlotRole::GpuAlias populate skip in runtime/xmem/src/physical_pages/private_views.rs (initial mapping + slot detach snapshot) and runtime/xmem/src/physical_pages/copy_mappings.rs (apply_alias fast path), and restored CPU-read assertions in runtime/xmem/src/tests/physical_backing.rs.
  • Both sites are needed because d3d12-buffer-remap verifies CPU reads on both initial placement and replacement remaps (initial CPU alias differs / replacement CPU alias differs).

2. try_write_xmem_bytes skipping unmapped XMem pages — Fixed

  • On rebased main (c2a59af), placed-texture writeback via try_write_xmem_bytes failed the queue batch with ERROR_INVALID_ADDRESS whenever any 64 KiB page in a multi-page span was unmapped/deferred, instead of skipping unmapped pages like write_mapped normally does.
  • Added a page-by-page fallback on ERROR_INVALID_ADDRESS in runtime/d3d12/src/device/heap/backing.rs to skip unmapped/deferred XMem pages without failing the batch (tested in try_write_xmem_bytes_skips_unmapped_xmem_pages_without_failing).

3. RtlReleaseSRWLockExclusive Lock ... is not owned exclusive! — Explained

  • TuxBox runtime/ makes zero SRWLock calls.
  • This comes from an upstream vkd3d-proton double-unlock bug in libs/vkd3d/memory.c (vkd3d_try_allocate_device_memory):
    • Line 1061 locks memory_info->budget_lock (rebar_budget && respect_budget), backed by SRWLOCK under mingw-w64 winpthreads.
    • When vkAllocateMemory fails (vr != VK_SUCCESS), line 1114 unlocks budget_lock while leaving rebar_budget set to true.
    • Execution then enters if (rebar_budget || VKD3D_CONFIG_FLAG_IS_SET(LOG_MEMORY_BUDGET)) at line 1126, skips the conditional lock at lines 1130–1131 (since rebar_budget && respect_budget is true), and unconditionally calls pthread_mutex_unlock(&memory_info->budget_lock) a second time at line 1161.
  • Every failed ReBAR-budgeted allocation attempt therefore logs one spurious unlock warning (whereas failed host-pointer vkd3d_import_host_memory calls on memory types 5/10 produce 0 lock warnings in our logs, matching @Kayotic1337's note). That explains 0 on RX 9060 XT, 1 on RX 9070 XT, 2–5 on RX 6900 XT, and ~5.3k–6.6k on 12 GB RX 6700 XT once VRAM saturates and vkd3d-proton retries multiple ReBAR-budgeted allocations before falling back to system memory.

4. Verification on main (c2a59af) + fcb5849

  • RX 6900 XT (1002:73bf, GE-Proton11-14): tuxbox.py check all checks passed — code checks (7/7), D3D12 regression controls (20/20 PASS, including d3d12-buffer-remap PASS pci=1002:73bf words=768/768 identical=1 replacement=1), Shader translator on the GPU PASS, Lanes and fixtures on the GPU (97/97 PASS, lanes-benchmark PASS pci=1002:73bf submit_us=116.3 roundtrip_us=152.9 copy64k_us=158.3 frame_us=257.1 frame_p99_us=480.7 shader_pipeline_us=476.6 dxil_pipeline_us=299.9).
  • AMD Raphael Radeon 610M iGPU (1002:164e, GE-Proton11-14): tuxbox.py check — code checks (7/7), D3D12 regression controls (20/20 PASS, d3d12-buffer-remap PASS pci=1002:164e words=768/768 identical=1 replacement=1), Shader translator on the GPU PASS, and 96/97 Lanes + guest fixtures PASS (lanes-benchmark PASS pci=1002:164e submit_us=72.2 roundtrip_us=118.5 copy64k_us=93.4 frame_us=289.9 frame_p99_us=533.1 shader_pipeline_us=479.8 dxil_pipeline_us=282.6); only guest-present-4k-splash (added in #311) timed out at 15 s on the iGPU.
  • ProjectScarlett on RX 6900 XT (c2a59af + #258, no preload): Reached Game Running (Frame: 2577, 7,006 presented frames), passed page-remap (batches=147), 0 CS has been rejected, 0 Not enough memory, live_arenas=0, view_holds=1,272 MiB, 2 RtlReleaseSRWLockExclusive matching 2 Memory allocation failed 1:1. Ended on main's world-streaming TCP GPUVM fault (0x80049e3bf000), and 0 Failed to place destAccelerationStructure (noting @NickStallman's note on retail vs build/bvh builder staging applies to this setup too).
<!-- greyfinch-sync:brcly/TuxBox:comment:7225000148 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7225000148). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-27T17:59:26Z. --- Rebased onto `main` (`c2a59af`) and pushed `fcb5849` addressing the `buffer-remap` regression (@brcly, @Kayotic1337), the `RtlReleaseSRWLockExclusive` question (@brcly, @JeffreyBytes, @Kayotic1337), and one placed-texture writeback bug surfaced on `main`: ### 1. `buffer-remap` failure (`initial CPU alias differs`) — Fixed - Reverted the `SlotRole::GpuAlias` populate skip in `runtime/xmem/src/physical_pages/private_views.rs` (initial mapping + slot detach snapshot) and `runtime/xmem/src/physical_pages/copy_mappings.rs` (`apply_alias` fast path), and restored CPU-read assertions in `runtime/xmem/src/tests/physical_backing.rs`. - Both sites are needed because `d3d12-buffer-remap` verifies CPU reads on both initial placement and replacement remaps (`initial CPU alias differs` / `replacement CPU alias differs`). ### 2. `try_write_xmem_bytes` skipping unmapped XMem pages — Fixed - On rebased `main` (`c2a59af`), placed-texture writeback via `try_write_xmem_bytes` failed the queue batch with `ERROR_INVALID_ADDRESS` whenever any 64 KiB page in a multi-page span was unmapped/deferred, instead of skipping unmapped pages like `write_mapped` normally does. - Added a page-by-page fallback on `ERROR_INVALID_ADDRESS` in `runtime/d3d12/src/device/heap/backing.rs` to skip unmapped/deferred XMem pages without failing the batch (tested in `try_write_xmem_bytes_skips_unmapped_xmem_pages_without_failing`). ### 3. `RtlReleaseSRWLockExclusive Lock ... is not owned exclusive!` — Explained - TuxBox `runtime/` makes zero `SRWLock` calls. - This comes from an upstream `vkd3d-proton` double-unlock bug in `libs/vkd3d/memory.c` (`vkd3d_try_allocate_device_memory`): - Line 1061 locks `memory_info->budget_lock` (`rebar_budget && respect_budget`), backed by `SRWLOCK` under mingw-w64 winpthreads. - When `vkAllocateMemory` fails (`vr != VK_SUCCESS`), line 1114 unlocks `budget_lock` while leaving `rebar_budget` set to `true`. - Execution then enters `if (rebar_budget || VKD3D_CONFIG_FLAG_IS_SET(LOG_MEMORY_BUDGET))` at line 1126, skips the conditional lock at lines 1130–1131 (since `rebar_budget && respect_budget` is true), and unconditionally calls `pthread_mutex_unlock(&memory_info->budget_lock)` a second time at line 1161. - Every failed ReBAR-budgeted allocation attempt therefore logs one spurious unlock warning (whereas failed host-pointer `vkd3d_import_host_memory` calls on memory types 5/10 produce 0 lock warnings in our logs, matching @Kayotic1337's note). That explains `0` on RX 9060 XT, `1` on RX 9070 XT, `2–5` on RX 6900 XT, and `~5.3k–6.6k` on 12 GB RX 6700 XT once VRAM saturates and vkd3d-proton retries multiple ReBAR-budgeted allocations before falling back to system memory. ### 4. Verification on `main` (`c2a59af`) + `fcb5849` - **RX 6900 XT (`1002:73bf`, GE-Proton11-14):** `tuxbox.py check` **all checks passed** — code checks (`7/7`), `D3D12 regression controls` (**`20/20` PASS**, including `d3d12-buffer-remap PASS pci=1002:73bf words=768/768 identical=1 replacement=1`), `Shader translator on the GPU` **PASS**, `Lanes and fixtures on the GPU` (**`97/97` PASS**, `lanes-benchmark PASS pci=1002:73bf submit_us=116.3 roundtrip_us=152.9 copy64k_us=158.3 frame_us=257.1 frame_p99_us=480.7 shader_pipeline_us=476.6 dxil_pipeline_us=299.9`). - **AMD Raphael Radeon 610M iGPU (`1002:164e`, GE-Proton11-14):** `tuxbox.py check` — code checks (`7/7`), `D3D12 regression controls` (**`20/20` PASS**, `d3d12-buffer-remap PASS pci=1002:164e words=768/768 identical=1 replacement=1`), `Shader translator on the GPU` **PASS**, and **`96/97` Lanes + guest fixtures PASS** (`lanes-benchmark PASS pci=1002:164e submit_us=72.2 roundtrip_us=118.5 copy64k_us=93.4 frame_us=289.9 frame_p99_us=533.1 shader_pipeline_us=479.8 dxil_pipeline_us=282.6`); only `guest-present-4k-splash` (added in `#311`) timed out at 15 s on the iGPU. - **ProjectScarlett on RX 6900 XT (`c2a59af` + `#258`, no preload):** Reached `Game Running` (`Frame: 2577`, `7,006` presented frames), passed `page-remap` (`batches=147`), `0` `CS has been rejected`, `0` `Not enough memory`, `live_arenas=0`, `view_holds=1,272 MiB`, `2` `RtlReleaseSRWLockExclusive` matching `2` `Memory allocation failed` 1:1. Ended on `main`'s world-streaming `TCP` `GPUVM fault` (`0x80049e3bf000`), and `0` `Failed to place destAccelerationStructure` (noting @NickStallman's note on retail vs `build/bvh` builder staging applies to this setup too).
brcly commented 2026-11-27 19:27:59 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-27T19:27:59Z.


Well done persevering through this, guys.

Glad a solution was found!

<!-- greyfinch-sync:brcly/TuxBox:comment:7226554283 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7226554283). Originally posted by [brcly](https://github.com/brcly) on 2026-11-27T19:27:59Z. --- Well done persevering through this, guys. Glad a solution was found!
Kayotic1337 commented 2026-11-27 19:31:05 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-27T19:31:05Z.


oh my god yes! rebuilding main now.

<!-- greyfinch-sync:brcly/TuxBox:comment:7226605571 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7226605571). Originally posted by [Kayotic1337](https://github.com/Kayotic1337) on 2026-11-27T19:31:05Z. --- oh my god yes! rebuilding main now.
brcly commented 2026-11-27 19:33:58 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-27T19:33:58Z.


oh my god yes! rebuilding main now.

Id hold off trying until I dial in these compilation changes which should speed shader compilation up, or you may be sat waiting at a black screen for a while 😂

<!-- greyfinch-sync:brcly/TuxBox:comment:7226653254 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/258#issuecomment-7226653254). Originally posted by [brcly](https://github.com/brcly) on 2026-11-27T19:33:58Z. --- > oh my god yes! rebuilding main now. Id hold off trying until I dial in these compilation changes which should speed shader compilation up, or you may be sat waiting at a black screen for a while 😂
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!258
No description provided.