gpu: bind proven mesh root reads from ordinary XMem pages #2466

Merged
R0Y00 merged 4 commits from upstream-pr/2474 into main 2026-11-25 19:36:23 +00:00
R0Y00 commented 2026-11-25 17:46:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T17:46:44Z.


Summary

  • Add an opt-in slot 61 path for a cached mesh shader with a proved four-byte raw root SRV read and an ordinary XMem address outside registered placed buffers.
  • Reuse the XMem single-page lease ABI. Check the physical mapping again on queue submission and retain the resource, heap and section lease through GPU completion. A stale recording is refused after a same-address remap.
  • Keep registered inputs on the existing published-writer path. The scope is the one proved DWORD of CPU-owned XMem. A raw root descriptor does not establish bounds for a larger allocation.

Verification

Built Release with cmake --build out/build/loose-root --target startup_indirect_draw_indexed xmem_section_lease_check --parallel 3.

ctest --test-dir out/build/loose-root --no-tests=error -j1 -R '^(xmem_section_lease_(warp|hardware|mesh_|single_page)|startup_indirect_mesh_lease_|startup_mesh_xmem_writer_|startup_mesh86_srv_proof$|startup_indirect_mesh_cache_(warp|hardware)$)' --output-on-failure

24/24 passed, with zero skips. Rebuilt the final source and reran the two loose root tests and the single-page lease test, 3/3 passed. Windows 11 26200.9974, Microsoft WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, D3D12 debug layer enabled.

The source-built shader observed the CPU value written after Close. Misaligned, unmapped, untracked readable, registered-without-writer and stale remapped inputs produced clear pixels. A fresh recording after the remap read the replacement page.

Feature commit: df1c3e13a45a3c9a63d9e8dfa76e71a41484262d.

Maintainer verification

A separate maintainer session reviewed the exact head for flag gating, placement exclusion, lease revalidation and fence retirement, then independently reproduced the three targeted checks with no skips. This was performed under the same repository account.

Two additional local controls used the same Release DLL. With the flag unset, the proved ordinary XMem input left all eight pixels clear on WARP and RTX. With the consumer held behind a fence, releasing its closed recording and remapping the address preserved the original physical slot for the pending GPU read. All eight pixels read the original value, and a fresh recording read the replacement value on both adapters with no D3D12 warnings or errors.

Main branch update

The first full /O2 run passed the loose-root WARP fixture. Its two PE startup failures were on a base that predated #2465. The topic branch now contains that existing fix through a regular merge from main. The net feature diff is unchanged.

On refreshed head ba2fb6e36301765b8e5dc4335a69c019ec33a111, Release passed both loose-root adapter fixtures, the single-page lease check, the WARP mesh-cache control and both previously failing PE startup tests, 6/6 with no skips.

The full Windows /O2 job also passed on that head. A subsequent merge from main preserves both logging triggers in the shared indirect fixture. The feature diff is identical after accounting for the main-side other_refusal_census trigger.

On 4570fc216461302a937ad061dd64e650d34a6ce0, the command below passed 35/35 in local Release on WARP and RTX, with no skips. It covers the new refusal census and controls alongside the loose-root and dual-lease fixtures and the two PE tests.

cmake --build out/build/loose-root --target startup_indirect_draw_indexed xmem_section_lease_check startup_per_reason_refusal_census_check startup_per_reason_refusal_census_keep_last_control startup_per_reason_refusal_census_keep_first_control --parallel 3
ctest --test-dir out/build/loose-root --no-tests=error -j1 -R '^(xmem_section_lease_(warp|hardware|mesh_|single_page)|startup_indirect_mesh_lease_|startup_mesh_xmem_writer_|startup_mesh86_srv_proof$|startup_indirect_mesh_cache_(warp|hardware)$|cpu_native_(package_ordinal_startup|startup)$|startup_.*refusal_census)' --output-on-failure

The PR checks and full Windows /O2 job both passed at 4570fc21. After #2504 merged, 9f547e45b09bb0abe01abe3b9382e152482fcb3a preserves its writer/fence tracing and the loose-root lease changes in the same implementation. The same local Release command passed 36/36 with no skips, including the added paired writer trace test and the WARP and RTX loose-root fixtures.

Current-head PR checks and Windows /O2 checks.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6610324588 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2474). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T17:46:44Z. --- ## Summary - Add an opt-in slot 61 path for a cached mesh shader with a proved four-byte raw root SRV read and an ordinary XMem address outside registered placed buffers. - Reuse the XMem single-page lease ABI. Check the physical mapping again on queue submission and retain the resource, heap and section lease through GPU completion. A stale recording is refused after a same-address remap. - Keep registered inputs on the existing published-writer path. The scope is the one proved DWORD of CPU-owned XMem. A raw root descriptor does not establish bounds for a larger allocation. ## Verification Built Release with `cmake --build out/build/loose-root --target startup_indirect_draw_indexed xmem_section_lease_check --parallel 3`. ```powershell ctest --test-dir out/build/loose-root --no-tests=error -j1 -R '^(xmem_section_lease_(warp|hardware|mesh_|single_page)|startup_indirect_mesh_lease_|startup_mesh_xmem_writer_|startup_mesh86_srv_proof$|startup_indirect_mesh_cache_(warp|hardware)$)' --output-on-failure ``` 24/24 passed, with zero skips. Rebuilt the final source and reran the two loose root tests and the single-page lease test, 3/3 passed. Windows 11 26200.9974, Microsoft WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, D3D12 debug layer enabled. The source-built shader observed the CPU value written after Close. Misaligned, unmapped, untracked readable, registered-without-writer and stale remapped inputs produced clear pixels. A fresh recording after the remap read the replacement page. Feature commit: `df1c3e13a45a3c9a63d9e8dfa76e71a41484262d`. ## Maintainer verification A separate maintainer session reviewed the exact head for flag gating, placement exclusion, lease revalidation and fence retirement, then independently reproduced the three targeted checks with no skips. This was performed under the same repository account. Two additional local controls used the same Release DLL. With the flag unset, the proved ordinary XMem input left all eight pixels clear on WARP and RTX. With the consumer held behind a fence, releasing its closed recording and remapping the address preserved the original physical slot for the pending GPU read. All eight pixels read the original value, and a fresh recording read the replacement value on both adapters with no D3D12 warnings or errors. ## Main branch update The first full /O2 run passed the loose-root WARP fixture. Its two PE startup failures were on a base that predated #2465. The topic branch now contains that existing fix through a regular merge from main. The net feature diff is unchanged. On refreshed head `ba2fb6e36301765b8e5dc4335a69c019ec33a111`, Release passed both loose-root adapter fixtures, the single-page lease check, the WARP mesh-cache control and both previously failing PE startup tests, 6/6 with no skips. The full [Windows /O2 job](https://github.com/R0Y00/Xbox2Windows/actions/runs/45673149016/job/139413544806) also passed on that head. A subsequent merge from main preserves both logging triggers in the shared indirect fixture. The feature diff is identical after accounting for the main-side `other_refusal_census` trigger. On `4570fc216461302a937ad061dd64e650d34a6ce0`, the command below passed 35/35 in local Release on WARP and RTX, with no skips. It covers the new refusal census and controls alongside the loose-root and dual-lease fixtures and the two PE tests. ```powershell cmake --build out/build/loose-root --target startup_indirect_draw_indexed xmem_section_lease_check startup_per_reason_refusal_census_check startup_per_reason_refusal_census_keep_last_control startup_per_reason_refusal_census_keep_first_control --parallel 3 ctest --test-dir out/build/loose-root --no-tests=error -j1 -R '^(xmem_section_lease_(warp|hardware|mesh_|single_page)|startup_indirect_mesh_lease_|startup_mesh_xmem_writer_|startup_mesh86_srv_proof$|startup_indirect_mesh_cache_(warp|hardware)$|cpu_native_(package_ordinal_startup|startup)$|startup_.*refusal_census)' --output-on-failure ``` The PR checks and full Windows /O2 job both passed at `4570fc21`. After #2504 merged, `9f547e45b09bb0abe01abe3b9382e152482fcb3a` preserves its writer/fence tracing and the loose-root lease changes in the same implementation. The same local Release command passed 36/36 with no skips, including the added paired writer trace test and the WARP and RTX loose-root fixtures. Current-head [PR checks](https://github.com/R0Y00/Xbox2Windows/actions/runs/45683254863) and [Windows /O2 checks](https://github.com/R0Y00/Xbox2Windows/actions/runs/45683266814/job/139449090506).
tedin7 commented 2026-11-25 18:31:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:31:48Z.

Review: COMMENTED


Code review of head ba2fb6e36301765b8e5dc4335a69c019ec33a111. Comment only; I did not run Windows or the game.

Checked in the diff

  • The new XMemSectionBuffer (src/startup_stubs/xmem_section_buffer.h) is a move of the old MeshXMemLease open/teardown code. It adds range checks before the map: first_byte and bytes must fit inside window_bytes, section_offset + window_bytes must not overflow, and bytes > UINT64_MAX - address is rejected. Teardown order is unchanged: resource, heap, section handle, then unmap, then release only if the unmap succeeded.
  • The new path is opt-in behind X2W_MESH86_LOOSE_XMEM_SRV. It applies only to slot 61 with !placed.owner. Registered-placement inputs keep the old published-writer path. note_mesh_xmem_write now gates on handoff/indirect only, so the new flag does not turn on write tracking.
  • The submit-time lease->matches(address) re-check is kept. The ready != lease check is skipped only for ownerless (loose) leases, which have no publisher by design.
  • The lease is a single page and has the old overlap guard against both publications and other loose views (mesh_xmem_loose_views, expired entries pruned under mesh_xmem_mutex).
  • Scope: the lease only covers the one proved DWORD. The docs entry (docs/experiments.md) says a raw root descriptor gives no bounds for a larger allocation.
  • Tests: new CTest mode loose-root for both adapters. The fixture covers: green when the flag is on and the shader is proven, black for a missing proof, a misaligned address, an unmapped page, readable untracked memory, and a registered resource without a publisher. It also covers a CPU write after Close being seen, a stale recording refused after remap, and a fresh recording reading the replacement page. Log lines for the refusals are asserted. The negative control for the stale remap is in the test itself.
  • No other open or merged PR covers this slice (searched "loose XMem root SRV mesh").
  • The PR touches no .github, launcher or hook files.

Commands run (Linux, in a worktree of the exact head)

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: passed (19 files, 466 links)
  • python3 tests/bidi_controls_check.py: passed
  • I could not do a code mutation here. The changed code and its tests build only with MSVC/D3D12.

Windows / CI results, with the SHA each one covers

  • The author posted a 6/6 Release result (both loose-root adapter fixtures, single-page lease, WARP mesh-cache control, two PE startup tests) on this exact head ba2fb6e3. An earlier 24/24 run was on feature commit df1c3e13.
  • The PR's CI run on this head: Windows build and test, the Linux Python checks and the gfx1013 fixtures all pass. The /O2 job was skipped.
  • The branch is behind main. I did not update it, so the author's results stay tied to this SHA.

Notes for @R0Y00

  • This does not claim startup progress and I make no claim about it. No game result is posted for this head.
  • The "maintainer verification" in the body was done under the same repository account as the author, so it is not an independent review.
  • The flag-unset control (all pixels clear) is described in the body only. It is not a CTest case. Consider adding one if you want that guarded.

No blocking findings from the code and test review.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6062929285 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2474#pullrequestreview-6062929285). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:31:48Z. **Review:** COMMENTED --- Code review of head `ba2fb6e36301765b8e5dc4335a69c019ec33a111`. Comment only; I did not run Windows or the game. **Checked in the diff** - The new `XMemSectionBuffer` (`src/startup_stubs/xmem_section_buffer.h`) is a move of the old `MeshXMemLease` open/teardown code. It adds range checks before the map: `first_byte` and `bytes` must fit inside `window_bytes`, `section_offset + window_bytes` must not overflow, and `bytes > UINT64_MAX - address` is rejected. Teardown order is unchanged: resource, heap, section handle, then unmap, then release only if the unmap succeeded. - The new path is opt-in behind `X2W_MESH86_LOOSE_XMEM_SRV`. It applies only to slot 61 with `!placed.owner`. Registered-placement inputs keep the old published-writer path. `note_mesh_xmem_write` now gates on handoff/indirect only, so the new flag does not turn on write tracking. - The submit-time `lease->matches(address)` re-check is kept. The `ready != lease` check is skipped only for ownerless (loose) leases, which have no publisher by design. - The lease is a single page and has the old overlap guard against both publications and other loose views (`mesh_xmem_loose_views`, expired entries pruned under `mesh_xmem_mutex`). - Scope: the lease only covers the one proved DWORD. The docs entry (`docs/experiments.md`) says a raw root descriptor gives no bounds for a larger allocation. - Tests: new CTest mode `loose-root` for both adapters. The fixture covers: green when the flag is on and the shader is proven, black for a missing proof, a misaligned address, an unmapped page, readable untracked memory, and a registered resource without a publisher. It also covers a CPU write after Close being seen, a stale recording refused after remap, and a fresh recording reading the replacement page. Log lines for the refusals are asserted. The negative control for the stale remap is in the test itself. - No other open or merged PR covers this slice (searched "loose XMem root SRV mesh"). - The PR touches no `.github`, launcher or hook files. **Commands run (Linux, in a worktree of the exact head)** - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: passed (19 files, 466 links) - `python3 tests/bidi_controls_check.py`: passed - I could not do a code mutation here. The changed code and its tests build only with MSVC/D3D12. **Windows / CI results, with the SHA each one covers** - The author posted a 6/6 Release result (both loose-root adapter fixtures, single-page lease, WARP mesh-cache control, two PE startup tests) on this exact head `ba2fb6e3`. An earlier 24/24 run was on feature commit `df1c3e13`. - The PR's CI run on this head: Windows build and test, the Linux Python checks and the gfx1013 fixtures all pass. The `/O2` job was skipped. - The branch is behind `main`. I did not update it, so the author's results stay tied to this SHA. **Notes for @R0Y00** - This does not claim startup progress and I make no claim about it. No game result is posted for this head. - The "maintainer verification" in the body was done under the same repository account as the author, so it is not an independent review. - The flag-unset control (all pixels clear) is described in the body only. It is not a CTest case. Consider adding one if you want that guarded. No blocking findings from the code and test review. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 20:04:22 +00:00
ChazY11 commented 2026-11-25 20:04:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T20:03:01Z.


Post-merge audit at 396e7e2e: 6/6 and 2/2 pass, and the writer-trace ordinals have no assertion behind them

Not a review request — #2474 is merged. I ran it and mutated it the way I have been mutating open PRs, because the
paired-writer tracing is the kind of feature whose tests can pass while the feature itself is inert.

What passes here

ctest --preset dev -R 'mesh_xmem'
    1/6 startup_indirect_mesh_xmem_arguments_warp .................  Passed
    2/6 startup_indirect_mesh_xmem_arguments_skip_wait_warp .......  Passed
    3/6 startup_indirect_mesh_xmem_arguments_hardware .............  Passed
    4/6 startup_indirect_mesh_xmem_arguments_skip_wait_hardware ...  Passed
    5/6 startup_mesh_xmem_writer_warp .............................  Passed
    6/6 startup_mesh_xmem_writer_hardware .........................  Passed
    100% tests passed, 0 tests failed out of 6

ctest --preset dev -R 'startup_indirect_mesh_cache'
    1/2 startup_indirect_mesh_cache_warp .......  Passed   7.01 sec
    2/2 startup_indirect_mesh_cache_hardware ...  Passed  13.59 sec

Reproduction note: all six mesh_xmem cases report Not Run until startup_indirect_draw_indexed is built — they
reference the target by name, and ctest -N -V prints the command with an empty executable before it exists. That is a
missing artifact, not a failure; I hit it and checked before reporting.

Three mutations of src/startup_stubs/mesh_xmem_handoff.inl

mutation caught
if (!mesh_xmem_trace_ordinal()) return 0; → if (true) return 0; (tracing never records) survived
the digit check dropped (value[i] < '0' || value[i] > '9' → false) survived
the length bound relaxed (size >= sizeof(value) → size > sizeof(value)) survived

I first ran these against the six mesh_xmem cases alone, where they are inert by construction — those cases set only
X2W_MESH86_FIXTURE_XMEM, never X2W_MESH86_WRITER_TRACE. So I re-ran with startup_indirect_mesh_cache_* included,
which does set the variable:

for ordinal, changed_input in ((2, None), (3, None), (4, 'root-srv'), (6, 'arguments')):
    traced = dict(environment, X2W_MESH86_WRITER_TRACE=str(ordinal))
    result = subprocess.run(cmd, env=traced, stderr=subprocess.PIPE, ...)
    sys.stderr.write(result.stderr)
    if result.returncode:
        return result.returncode

Even there, return 0 from mesh_xmem_trace_ordinal() changes nothing. The reason is visible in that loop: the traced
run's stderr is forwarded and its exit code checked, but nothing asserts that a trace line was produced. So the
ordinal values 2/3/4/6 are exercised as "the program still passes with tracing requested", not as "ordinal N records
the paired writer I expect"
.

That is worth knowing for two reasons:

  • Deleting the tracing entirely (return 0) is currently invisible to CI. The feature could rot silently.
  • A wrong trace is also invisible: if ordinal 4 recorded the arguments writer instead of root-srv, no assertion here
    would notice.

If the trace output is meant as an operator diagnostic rather than a checked behaviour, saying so in
docs/experiments.md would settle it. If it is meant to be checked, the cheap version is one regex per ordinal on the
captured stderr — the loop already has result.stderr in hand and already knows which ordinal is supposed to name which
input.

What the six mesh_xmem cases do pin

They pass with two backends and with and without the extra wait, and they reference the fixture through
X2W_MESH86_FIXTURE_XMEM=$<TARGET_FILE:xmem_shim>, so the ordering assertions run against a real built shim rather
than a stub. That half of the PR is well covered — it is only the trace path that nothing constrains.

AI-assisted; Windows 11 build 26300.9974, WARP and the installed physical GPU, targets built individually.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173116983 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2474#issuecomment-7173116983). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T20:03:01Z. --- ## Post-merge audit at `396e7e2e`: 6/6 and 2/2 pass, and the writer-trace ordinals have no assertion behind them Not a review request — `#2474` is merged. I ran it and mutated it the way I have been mutating open PRs, because the paired-writer tracing is the kind of feature whose tests can pass while the feature itself is inert. ### What passes here ```text ctest --preset dev -R 'mesh_xmem' 1/6 startup_indirect_mesh_xmem_arguments_warp ................. Passed 2/6 startup_indirect_mesh_xmem_arguments_skip_wait_warp ....... Passed 3/6 startup_indirect_mesh_xmem_arguments_hardware ............. Passed 4/6 startup_indirect_mesh_xmem_arguments_skip_wait_hardware ... Passed 5/6 startup_mesh_xmem_writer_warp ............................. Passed 6/6 startup_mesh_xmem_writer_hardware ......................... Passed 100% tests passed, 0 tests failed out of 6 ctest --preset dev -R 'startup_indirect_mesh_cache' 1/2 startup_indirect_mesh_cache_warp ....... Passed 7.01 sec 2/2 startup_indirect_mesh_cache_hardware ... Passed 13.59 sec ``` Reproduction note: all six `mesh_xmem` cases report **`Not Run`** until `startup_indirect_draw_indexed` is built — they reference the target by name, and `ctest -N -V` prints the command with an empty executable before it exists. That is a missing artifact, not a failure; I hit it and checked before reporting. ### Three mutations of `src/startup_stubs/mesh_xmem_handoff.inl` | mutation | caught | |---|---| | `if (!mesh_xmem_trace_ordinal()) return 0;` → `if (true) return 0;` (tracing never records) | survived | | the digit check dropped (`value[i] < '0' \|\| value[i] > '9'` → `false`) | survived | | the length bound relaxed (`size >= sizeof(value)` → `size > sizeof(value)`) | survived | I first ran these against the six `mesh_xmem` cases alone, where they are inert by construction — those cases set only `X2W_MESH86_FIXTURE_XMEM`, never `X2W_MESH86_WRITER_TRACE`. So I re-ran with `startup_indirect_mesh_cache_*` included, which does set the variable: ```python for ordinal, changed_input in ((2, None), (3, None), (4, 'root-srv'), (6, 'arguments')): traced = dict(environment, X2W_MESH86_WRITER_TRACE=str(ordinal)) result = subprocess.run(cmd, env=traced, stderr=subprocess.PIPE, ...) sys.stderr.write(result.stderr) if result.returncode: return result.returncode ``` Even there, `return 0` from `mesh_xmem_trace_ordinal()` changes nothing. The reason is visible in that loop: the traced run's **stderr is forwarded and its exit code checked**, but nothing asserts that a trace line was produced. So the ordinal values 2/3/4/6 are exercised as *"the program still passes with tracing requested"*, not as *"ordinal N records the paired writer I expect"*. That is worth knowing for two reasons: - Deleting the tracing entirely (`return 0`) is currently invisible to CI. The feature could rot silently. - A wrong trace is also invisible: if ordinal 4 recorded the arguments writer instead of `root-srv`, no assertion here would notice. If the trace output is meant as an operator diagnostic rather than a checked behaviour, saying so in `docs/experiments.md` would settle it. If it is meant to be checked, the cheap version is one regex per ordinal on the captured stderr — the loop already has `result.stderr` in hand and already knows which ordinal is supposed to name which input. ### What the six `mesh_xmem` cases do pin They pass with two backends and with and without the extra wait, and they reference the fixture through `X2W_MESH86_FIXTURE_XMEM=$<TARGET_FILE:xmem_shim>`, so the ordering assertions run against a real built shim rather than a stub. That half of the PR is well covered — it is only the trace path that nothing constrains. AI-assisted; Windows 11 build 26300.9974, WARP and the installed physical GPU, targets built individually.
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!2466
No description provided.