runtime: resolve readable guest Mesh86 root SRVs #3813

Open
lambirou wants to merge 14 commits from upstream-pr/3813 into main
lambirou commented 2026-12-02 01:51:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-02T01:51:22Z.


Problem

After #3810, the focus run reaches the prologue and key 13c660ac281d07d5 passes the 18-byte material t0, then refuses at t1 root=3:

x2w-mesh86 material refused ... stage=mesh srv=t1 root=3 needed=128 size=0 ... reason=root SRV has no mapped buffer

The four DispatchMesh calls that draw the prologue therefore bind no geometry. The 128-byte range is readable guest memory that no live D3D12 resource owns, so the upload-ring, placement-index and committed-resource lookups all miss.

Change

  • Resolve a readable guest root SRV through the recording-owned upload snapshot, the same backing rule slot 44 already uses for root SRVs and the root-CBV branch uses for scalar loads. The snapshot also makes a range whose guest offset is not 16-byte aligned addressable by the desktop raw SRV.
  • Refuse a range that overlaps a GPU-written resource before copying title bytes, so the desktop bytes stay authoritative.
  • Replace root SRV has no mapped buffer with a named reason and a bounded X2W_D3D12_TRACE_DIRECT_MESH row carrying the address, readability, VirtualQuery state/type, placement result and resource-index result. A reserved page now reports root SRV range is not readable in title memory.

Tests

tests/startup_mesh86_root_srv_check.py publishes a PS-less profile 6 with one 128-byte root SRV, then runs startup_indirect_draw_indexed twice:

  • positive: a committed 64 KiB private page at offset 0x40; the mesh stage reads dwords 0 and 124 and writes depth 0.5.
  • negative: a reserved page; the bind must print the named refusal and leave the depth clear.
. .\tools\dev.ps1
cmake --preset release -DINTAKE_PYTHON=<python>
cmake --build --preset release --target startup_indirect_draw_indexed
python -B tests/startup_mesh86_root_srv_check.py <dxc> out\build\release\startup_indirect_draw_indexed.exe hardware
python -B tests/startup_mesh86_root_srv_check.py <dxc> out\build\release\startup_indirect_draw_indexed.exe warp

Results on this worktree (f40d7a0c):

  • RX 9060 XT, driver 32.0.32029.2010: positive read depth 0.5 (8/8 non-clear pixels, all 0x8000); negative refused by name with depth clear.
  • Microsoft Basic Render Driver 10.0.26100.10068: the 128-byte root SRV binds and DispatchMesh is recorded; WARP then removes the device after the mesh dispatch (0x887a0005), so the depth readback is a capability skip. The negative control passes.
ctest --test-dir out/build/release --no-tests=error -j1 -R '^startup_mesh86_root_srv_' --output-on-failure
1/2 Test #4234: startup_mesh86_root_srv_warp ....... Passed
2/2 Test #4235: startup_mesh86_root_srv_hardware ... Passed

Focus title

The previous focus run stopped at the old root SRV has no mapped buffer refusal. The final integration run with the material and input fixes is launched separately; its refusal or mesh-bind result will be recorded here.

Stack

Stacked on #3725 / #3803 (integration head f4c9e174). Refs #3639, #3641, #870.

Review follow-up (2026-12-02)

The PR currently conflicts with main and remains stacked on open dependencies #3803 and #3810. On head f40d7a0c, a release rebuild and the two root-SRV CTest cases passed on the existing fixture. The WARP positive depth readback was a capability skip after device removal; its negative control passed.

Outstanding correctness issue: a readable range rejected by placed_buffer_range as crossing or ambiguous can reach the guest-memory snapshot fallback. Add a regression fixture and preserve the placement rejection before treating this as ready to merge. The existing positive and reserved-page controls do not cover this case.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5598189189 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3813). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-02T01:51:22Z. --- ## Problem After #3810, the focus run reaches the prologue and key `13c660ac281d07d5` passes the 18-byte material `t0`, then refuses at `t1 root=3`: ``` x2w-mesh86 material refused ... stage=mesh srv=t1 root=3 needed=128 size=0 ... reason=root SRV has no mapped buffer ``` The four `DispatchMesh` calls that draw the prologue therefore bind no geometry. The 128-byte range is readable guest memory that no live D3D12 resource owns, so the upload-ring, placement-index and committed-resource lookups all miss. ## Change - Resolve a readable guest root SRV through the recording-owned upload snapshot, the same backing rule slot 44 already uses for root SRVs and the root-CBV branch uses for scalar loads. The snapshot also makes a range whose guest offset is not 16-byte aligned addressable by the desktop raw SRV. - Refuse a range that overlaps a GPU-written resource before copying title bytes, so the desktop bytes stay authoritative. - Replace `root SRV has no mapped buffer` with a named reason and a bounded `X2W_D3D12_TRACE_DIRECT_MESH` row carrying the address, readability, `VirtualQuery` state/type, placement result and resource-index result. A reserved page now reports `root SRV range is not readable in title memory`. ## Tests `tests/startup_mesh86_root_srv_check.py` publishes a PS-less profile 6 with one 128-byte root SRV, then runs `startup_indirect_draw_indexed` twice: - positive: a committed 64 KiB private page at offset `0x40`; the mesh stage reads dwords 0 and 124 and writes depth 0.5. - negative: a reserved page; the bind must print the named refusal and leave the depth clear. ```powershell . .\tools\dev.ps1 cmake --preset release -DINTAKE_PYTHON=<python> cmake --build --preset release --target startup_indirect_draw_indexed python -B tests/startup_mesh86_root_srv_check.py <dxc> out\build\release\startup_indirect_draw_indexed.exe hardware python -B tests/startup_mesh86_root_srv_check.py <dxc> out\build\release\startup_indirect_draw_indexed.exe warp ``` Results on this worktree (`f40d7a0c`): - RX 9060 XT, driver 32.0.32029.2010: positive read depth 0.5 (8/8 non-clear pixels, all `0x8000`); negative refused by name with depth clear. - Microsoft Basic Render Driver 10.0.26100.10068: the 128-byte root SRV binds and `DispatchMesh` is recorded; WARP then removes the device after the mesh dispatch (`0x887a0005`), so the depth readback is a capability skip. The negative control passes. ``` ctest --test-dir out/build/release --no-tests=error -j1 -R '^startup_mesh86_root_srv_' --output-on-failure 1/2 Test #4234: startup_mesh86_root_srv_warp ....... Passed 2/2 Test #4235: startup_mesh86_root_srv_hardware ... Passed ``` ## Focus title The previous focus run stopped at the old `root SRV has no mapped buffer` refusal. The final integration run with the material and input fixes is launched separately; its refusal or mesh-bind result will be recorded here. ## Stack Stacked on #3725 / #3803 (integration head `f4c9e174`). Refs #3639, #3641, #870. ## Review follow-up (2026-12-02) The PR currently conflicts with main and remains stacked on open dependencies #3803 and #3810. On head f40d7a0c, a release rebuild and the two root-SRV CTest cases passed on the existing fixture. The WARP positive depth readback was a capability skip after device removal; its negative control passed. Outstanding correctness issue: a readable range rejected by placed_buffer_range as crossing or ambiguous can reach the guest-memory snapshot fallback. Add a regression fixture and preserve the placement rejection before treating this as ready to merge. The existing positive and reserved-page controls do not cover this case.
lambirou commented 2026-12-02 14:44:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-02T14:44:26Z.

Review: COMMENTED


Reviewed f40d7a0c against #3725; read the runtime and fixture delta, not built here.

Verdict: approve. The new root-SRV path reuses the recording-owned upload snapshot rather than inventing a second backing, refuses a range that overlaps a GPU-written resource before copying title bytes, and replaces the generic refusal with named reasons. The positive/negative fixture covers a committed readable page and a reserved page.

  • SHOULD The snapshot branch returns a source-2 view for any minimum that is readable, without applying the existing 16 MiB snapshot bound or consulting title_input_snapshot_enabled(). A 128-byte root SRV is harmless, but the same branch would copy a much larger guest range if a profile declares it. Bound the copy and state whether this path is intentionally independent of the snapshot switch.
  • NIT root_srv_unmapped_reason keeps a process-wide static std::vector for de-duplication. The existing diagnostic paths use the same pattern, but this function can be called from several lists; a small lock or a per-recording set would make the bound explicit.
  • Checked, no finding: gpu_written_overlap is checked before the title snapshot; the placement, mapped-resource and readability reasons are ordered and named; the test's reserved-page control expects the named refusal and a clear depth. The PR remains stacked on #3725, so it should not merge before that base.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6153048009 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3813#pullrequestreview-6153048009). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-02T14:44:26Z. **Review:** COMMENTED --- Reviewed `f40d7a0c` against #3725; read the runtime and fixture delta, not built here. **Verdict: approve.** The new root-SRV path reuses the recording-owned upload snapshot rather than inventing a second backing, refuses a range that overlaps a GPU-written resource before copying title bytes, and replaces the generic refusal with named reasons. The positive/negative fixture covers a committed readable page and a reserved page. - **SHOULD** The snapshot branch returns a source-2 view for any `minimum` that is readable, without applying the existing 16 MiB snapshot bound or consulting `title_input_snapshot_enabled()`. A 128-byte root SRV is harmless, but the same branch would copy a much larger guest range if a profile declares it. Bound the copy and state whether this path is intentionally independent of the snapshot switch. - **NIT** `root_srv_unmapped_reason` keeps a process-wide `static std::vector` for de-duplication. The existing diagnostic paths use the same pattern, but this function can be called from several lists; a small lock or a per-recording set would make the bound explicit. - Checked, no finding: `gpu_written_overlap` is checked before the title snapshot; the placement, mapped-resource and readability reasons are ordered and named; the test's reserved-page control expects the named refusal and a clear depth. The PR remains stacked on #3725, so it should not merge before that base.
timbot103 commented 2026-12-03 10:33:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T10:33:58Z.


Independent RTX 5080 + WARP run, in case a second NVIDIA data point helps (the reviewer runs here are on an RTX 4060 Laptop). Two of these findings repeat on all three of #3803, #3812 and #3813, so they probably do not come from this PR's own change, and I have not bisected them: (1) native_direct_mesh fails its uniform-load-offen refusal assertion, and (2) in-box WARP removes the device (0x887a0005) after the PS-less dispatch. The RTX 5080 depth readback of 0x7fff where the new fixtures expect 0x8000 looks NVIDIA-specific. It might need a one-ULP tolerance, or a depth value that is exactly representable. Full details below.


Independent verification of head f40d7a0c00a508a22dd35b4b8f8884c3dff808a9 against pinned main d2e6a4ed9fd7377ea5a01d9384a845c26ed7b5e5.
The merge stopped with 12 conflicts, including src/startup_stubs/mesh86_cache.inl and tests/startup_indirect_draw_indexed.cpp. These runs used the published head.

Windows 11 build 26200.9974. RTX 5080 driver 32.0.16.2140 (621.40). Microsoft Basic Render Driver with in-box WARP 10.0.26100.9818. DXC 1.9.2602.17 (21d28f727). The startup fixture reported the debug layer unavailable.

Commands run with $cfg set to dev and release, $python set to the project venv interpreter and XBOX2WINDOWS_ADAPTER set to NVIDIA GeForce RTX 5080.

. .\tools\dev.ps1
cmake --preset $cfg "-DINTAKE_PYTHON=$python"
cmake --build out/build/$cfg --target compile_dxil startup_indirect_draw_indexed startup_mesh86_material_backing -- -j 6
ctest --preset $cfg --no-tests=error -j 1 -R '^(startup_mesh86_|runtime_mesh86_cache_cli_check$|startup_indirect_mesh(_console|_request|_create_result)?_(warp|hardware)$|startup_indirect_mesh_(cache|lease)_|native_direct_(mesh|container)$|native_mesh_).*$' -V
$dxc = Join-Path (Get-Content "out/build/$cfg/x2w-dxc-dir.txt") dxc.exe
foreach ($adapter in "hardware","warp") {
    & $python -B tests/startup_mesh86_root_srv_check.py $dxc "out/build/$cfg/startup_indirect_draw_indexed.exe" $adapter
}

Counts are pass/fail/skip. The totals include the adapter-independent tests.

Config WARP RTX 5080 Other Total
Debug 28/1/0 26/2/0 3/1/0 57/4/0
Release 28/1/0 26/2/0 3/1/0 57/4/0
  • Debug startup_mesh86_root_srv_warp (Passed). warp positive: 128-byte root SRV bound and DispatchMesh recorded; WARP removes the device after the mesh dispatch, so the depth readback is a capability skip
  • Release startup_mesh86_root_srv_warp (Passed). warp positive: 128-byte root SRV bound and DispatchMesh recorded; WARP removes the device after the mesh dispatch, so the depth readback is a capability skip
  • The direct root-SRV checks reproduced the corresponding CTest results.
  • Separate Debug hardware replay of checks after the positive readback. reserved page pass.
  • Separate Release hardware replay of checks after the positive readback. reserved page pass.

Failure diagnostics

Debug native_direct_mesh

AssertionError: ('compiler_init_ms=20.5746\ncold_compile_and_publish_ms=12.536 bytes=4580\n', '')

Debug/Release startup_mesh86_psless_warp

map argument readback failed (HRESULT 0x887a0005)

Debug/Release startup_mesh86_psless_hardware

guest root SRV 128 bytes: pixel (0,0): got 0x00007fff, expected 0x00008000

Debug/Release startup_mesh86_root_srv_hardware

guest root SRV 128 bytes: pixel (0,0): got 0x00007fff, expected 0x00008000

Release native_direct_mesh

AssertionError: ('compiler_init_ms=16.069\ncold_compile_and_publish_ms=5.9024 bytes=4580\n', '')

native_direct_mesh failed its uniform-load-offen refusal assertion. The compiler published a shader where the fixture expected a refusal.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7375422751 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3813#issuecomment-7375422751). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T10:33:58Z. --- Independent RTX 5080 + WARP run, in case a second NVIDIA data point helps (the reviewer runs here are on an RTX 4060 Laptop). Two of these findings repeat on all three of #3803, #3812 and #3813, so they probably do not come from this PR's own change, and I have not bisected them: (1) `native_direct_mesh` fails its `uniform-load-offen` refusal assertion, and (2) in-box WARP removes the device (`0x887a0005`) after the PS-less dispatch. The RTX 5080 depth readback of `0x7fff` where the new fixtures expect `0x8000` looks NVIDIA-specific. It might need a one-ULP tolerance, or a depth value that is exactly representable. Full details below. --- Independent verification of head `f40d7a0c00a508a22dd35b4b8f8884c3dff808a9` against pinned main `d2e6a4ed9fd7377ea5a01d9384a845c26ed7b5e5`. The merge stopped with 12 conflicts, including `src/startup_stubs/mesh86_cache.inl` and `tests/startup_indirect_draw_indexed.cpp`. These runs used the published head. Windows 11 build 26200.9974. RTX 5080 driver 32.0.16.2140 (621.40). Microsoft Basic Render Driver with in-box WARP 10.0.26100.9818. DXC 1.9.2602.17 (21d28f727). The startup fixture reported the debug layer unavailable. Commands run with `$cfg` set to `dev` and `release`, `$python` set to the project venv interpreter and `XBOX2WINDOWS_ADAPTER` set to `NVIDIA GeForce RTX 5080`. ```powershell . .\tools\dev.ps1 cmake --preset $cfg "-DINTAKE_PYTHON=$python" cmake --build out/build/$cfg --target compile_dxil startup_indirect_draw_indexed startup_mesh86_material_backing -- -j 6 ctest --preset $cfg --no-tests=error -j 1 -R '^(startup_mesh86_|runtime_mesh86_cache_cli_check$|startup_indirect_mesh(_console|_request|_create_result)?_(warp|hardware)$|startup_indirect_mesh_(cache|lease)_|native_direct_(mesh|container)$|native_mesh_).*$' -V $dxc = Join-Path (Get-Content "out/build/$cfg/x2w-dxc-dir.txt") dxc.exe foreach ($adapter in "hardware","warp") { & $python -B tests/startup_mesh86_root_srv_check.py $dxc "out/build/$cfg/startup_indirect_draw_indexed.exe" $adapter } ``` Counts are pass/fail/skip. The totals include the adapter-independent tests. | Config | WARP | RTX 5080 | Other | Total | |---|---:|---:|---:|---:| | Debug | 28/1/0 | 26/2/0 | 3/1/0 | 57/4/0 | | Release | 28/1/0 | 26/2/0 | 3/1/0 | 57/4/0 | - Debug `startup_mesh86_root_srv_warp` (Passed). warp positive: 128-byte root SRV bound and DispatchMesh recorded; WARP removes the device after the mesh dispatch, so the depth readback is a capability skip - Release `startup_mesh86_root_srv_warp` (Passed). warp positive: 128-byte root SRV bound and DispatchMesh recorded; WARP removes the device after the mesh dispatch, so the depth readback is a capability skip - The direct root-SRV checks reproduced the corresponding CTest results. - Separate Debug hardware replay of checks after the positive readback. reserved page pass. - Separate Release hardware replay of checks after the positive readback. reserved page pass. Failure diagnostics Debug `native_direct_mesh` ```text AssertionError: ('compiler_init_ms=20.5746\ncold_compile_and_publish_ms=12.536 bytes=4580\n', '') ``` Debug/Release `startup_mesh86_psless_warp` ```text map argument readback failed (HRESULT 0x887a0005) ``` Debug/Release `startup_mesh86_psless_hardware` ```text guest root SRV 128 bytes: pixel (0,0): got 0x00007fff, expected 0x00008000 ``` Debug/Release `startup_mesh86_root_srv_hardware` ```text guest root SRV 128 bytes: pixel (0,0): got 0x00007fff, expected 0x00008000 ``` Release `native_direct_mesh` ```text AssertionError: ('compiler_init_ms=16.069\ncold_compile_and_publish_ms=5.9024 bytes=4580\n', '') ``` `native_direct_mesh` failed its `uniform-load-offen` refusal assertion. The compiler published a shader where the fixture expected a refusal.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3813:upstream-pr/3813'
git switch 'upstream-pr/3813'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3813'
git switch 'upstream-pr/3813'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3813'
git switch 'upstream-pr/3813'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3813'
git switch 'main'
git merge --squash 'upstream-pr/3813'
git switch 'main'
git merge --ff-only 'upstream-pr/3813'
git switch 'main'
git merge 'upstream-pr/3813'
git push origin 'main'
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
R0Y00/Xbox2Windows!3813
No description provided.