gpu: hand off leased XMem DispatchMesh arguments across queues #2324

Merged
sydney-0o merged 1 commit from upstream-pr/2332 into main 2026-11-25 13:02:22 +00:00
sydney-0o commented 2026-11-25 12:41:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by sydney-0o on 2026-11-25T12:41:16Z.


Refs #870, #1759 and #1914. Builds on #1916 (desktop single-record DispatchMesh), #2280 (physical XMem page leases), and #2303 (queue waits and fence-based lease retirement for a mesh root SRV).

DispatchMesh arguments

X2W_MESH_INDIRECT_XMEM=1 enables a single rootless 12-byte DISPATCH_MESH record for the desktop mesh pipeline and a mirrored slot-133 placement. A source-built compute shader from #1916 writes {2,1,1} into a default-heap UAV. Slot 15 copies the record into the leased XMem view on the COMPUTE queue and submission publishes the copied range and its completion fence. Slot 61 verifies the live physical page and the full byte range at recording and submission. The DIRECT queue waits on the writer's fence, executes against that leased buffer in INDIRECT_ARGUMENT state, and retains the lease until its own completion.

The fixture identifies the compute producer. The runtime establishes provenance at the submitted slot-15 copy. The producer behind the observed application calls remains open in #1412.

Source-built controls

Case WARP result
Writer pending, queue wait enabled The DIRECT consumer stayed pending until the writer gate opened and painted 8/8 pixels using two groups.
Writer pending, queue wait omitted The DIRECT consumer painted 4/8 pixels using the seeded one-group record.
Writer recorded, not submitted Runtime refused the record and 0/8 pixels were painted.
Different page in same placement or shifted byte range Runtime refused both and 0/8 pixels were painted in each case.
Guest unmapped after gated consumer submission The consumer still painted 8/8 pixels. The allocator reused the original slot only after completion.

The mirrored CPU view held {2,1,1} and both guard words survived after the writer fence.

Validation

Release at local commit 0814a66a with the same tree as this PR head. Windows 10 19045.6456, Microsoft Basic Render Driver app-local WARP 1.0.22.0, Agility SDK 1.620.2, and the D3D12 debug layer enabled. Both WARP controls reported zero D3D12 warnings or errors. The GTX 1080 Ti (32.0.15.8278) returned capability skips for mesh shader cases.

$warp and $agility point to the local x64 runtime directories. $python and $dxc point to the test interpreter and the Windows SDK 10.0.26100.0 DXC.

.\tools\dev.ps1
cmake --preset release -B out/build/mesh-agility "-DOFFSCREEN_WARP_DIR=$warp" "-DOFFSCREEN_AGILITY_620_DIR=$agility" "-DINTAKE_PYTHON=$python" "-DDXC_EXECUTABLE=$dxc"
cmake --build out/build/mesh-agility --target startup_indirect_draw_indexed startup_list_copy_check xmem_section_lease_check --parallel 4
ctest --test-dir out/build/mesh-agility --no-tests=error -j1 -R '^(startup_indirect_(draw(_indexed)?|mesh(_console|_amplified|_xmem_arguments(_skip_wait)?)?)_(warp|hardware)$|startup_indirect_mesh_(cache|lease)_|startup_mesh_xmem_writer_|startup_mesh86_srv_proof$|startup_list_copy_validation|xmem_section_lease_)' --output-on-failure
ctest --test-dir out/build/mesh-agility --no-tests=error -j1 -R '^startup_indirect_mesh_xmem_arguments.*_warp$' --repeat until-fail:10 --output-on-failure

24 passed, 0 failed, and 9 capability skips. Both new WARP cases passed 10 consecutive runs each and are selected by the Windows pull request smoke preset. git diff --check, the mesh86 Python proof, documentation link check, and bidi check also passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6604707607 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2332). Originally posted by [sydney-0o](https://github.com/sydney-0o) on 2026-11-25T12:41:16Z. --- Refs #870, #1759 and #1914. Builds on #1916 (desktop single-record `DispatchMesh`), #2280 (physical XMem page leases), and #2303 (queue waits and fence-based lease retirement for a mesh root SRV). ### DispatchMesh arguments `X2W_MESH_INDIRECT_XMEM=1` enables a single rootless 12-byte `DISPATCH_MESH` record for the desktop mesh pipeline and a mirrored slot-133 placement. A source-built compute shader from #1916 writes `{2,1,1}` into a default-heap UAV. Slot 15 copies the record into the leased XMem view on the COMPUTE queue and submission publishes the copied range and its completion fence. Slot 61 verifies the live physical page and the full byte range at recording and submission. The DIRECT queue waits on the writer's fence, executes against that leased buffer in `INDIRECT_ARGUMENT` state, and retains the lease until its own completion. The fixture identifies the compute producer. The runtime establishes provenance at the submitted slot-15 copy. The producer behind the observed application calls remains open in #1412. ### Source-built controls | Case | WARP result | | --- | --- | | Writer pending, queue wait enabled | The DIRECT consumer stayed pending until the writer gate opened and painted 8/8 pixels using two groups. | | Writer pending, queue wait omitted | The DIRECT consumer painted 4/8 pixels using the seeded one-group record. | | Writer recorded, not submitted | Runtime refused the record and 0/8 pixels were painted. | | Different page in same placement or shifted byte range | Runtime refused both and 0/8 pixels were painted in each case. | | Guest unmapped after gated consumer submission | The consumer still painted 8/8 pixels. The allocator reused the original slot only after completion. | The mirrored CPU view held `{2,1,1}` and both guard words survived after the writer fence. ### Validation Release at local commit `0814a66a` with the same tree as this PR head. Windows 10 19045.6456, Microsoft Basic Render Driver app-local WARP 1.0.22.0, Agility SDK 1.620.2, and the D3D12 debug layer enabled. Both WARP controls reported zero D3D12 warnings or errors. The GTX 1080 Ti (32.0.15.8278) returned capability skips for mesh shader cases. `$warp` and `$agility` point to the local x64 runtime directories. `$python` and `$dxc` point to the test interpreter and the Windows SDK 10.0.26100.0 DXC. ```powershell .\tools\dev.ps1 cmake --preset release -B out/build/mesh-agility "-DOFFSCREEN_WARP_DIR=$warp" "-DOFFSCREEN_AGILITY_620_DIR=$agility" "-DINTAKE_PYTHON=$python" "-DDXC_EXECUTABLE=$dxc" cmake --build out/build/mesh-agility --target startup_indirect_draw_indexed startup_list_copy_check xmem_section_lease_check --parallel 4 ctest --test-dir out/build/mesh-agility --no-tests=error -j1 -R '^(startup_indirect_(draw(_indexed)?|mesh(_console|_amplified|_xmem_arguments(_skip_wait)?)?)_(warp|hardware)$|startup_indirect_mesh_(cache|lease)_|startup_mesh_xmem_writer_|startup_mesh86_srv_proof$|startup_list_copy_validation|xmem_section_lease_)' --output-on-failure ctest --test-dir out/build/mesh-agility --no-tests=error -j1 -R '^startup_indirect_mesh_xmem_arguments.*_warp$' --repeat until-fail:10 --output-on-failure ``` 24 passed, 0 failed, and 9 capability skips. Both new WARP cases passed 10 consecutive runs each and are selected by the Windows pull request smoke preset. `git diff --check`, the mesh86 Python proof, documentation link check, and bidi check also passed.
tedin7 commented 2026-11-25 13:00:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:45:57Z.

Review: COMMENTED


Review of head 4f7ea51e046988c3cc879e2cf6a49434f4d3820c (comment only).

Summary: No P1 or P2 findings. The change generalizes the single-word SRV lease to a sized lease (4-byte SRV word or 12-byte DISPATCH_MESH record) and adds a read path for ExecuteIndirect. The logic reads consistently.

Checked by reading the diff

  • src/startup_stubs/mesh_xmem_handoff.inl: the lease now carries bytes. pin, matches, the overlap tests, placed_buffer_range at submit, and the log lines all use it. I found no leftover sizeof(UINT) that should have been bytes.
  • record_mesh_xmem_read keeps the old SRV checks. These are the writer-in-same-recording refusal, the overlap refusal, the reserve-before-barrier ordering, and the size and alignment checks (4 bytes for a raw SRV, 4 for a record). bind_mesh_xmem_srv is now a thin wrapper, so the old caller behaves the same.
  • src/startup_stubs/d3d12_xs_device.cpp:2694: the new branch is gated on mesh_xmem_indirect(), a non-cached mesh pass, and a copied_buffer placement. A refusal returns before ExecuteIndirect. With the flag off, the old require_state path runs unchanged.
  • src/startup_stubs/list_copy.inl:199: the record is only tracked from a COMPUTE list, from a default-heap UAV-capable source, and with an exact 12-byte size. srv_word still needs mesh_xmem_handoff() plus an upload source. The two modes do not capture each other's copies.
  • queue_execute and the drop/discard hooks now use mesh_xmem_tracking(), so the lease bookkeeping runs under either flag.
  • Title and body are neutral and cite public issues and PRs only. Docs and the CMake and preset test entries match the new test names.

Commands run locally on the PR head (Linux)

  • python3 tests/docs_links_check.py -> Checked 18 Markdown files and 451 links.
  • python3 tests/bidi_controls_check.py -> Checked 1615 tracked source, script and build/CI files: no bidirectional controls.
  • git diff --check origin/main...HEAD -> clean.
  • gh pr checks 2332: Windows build and test, gfx1013 fixtures, and the Linux Python checks all pass. The CI log shows startup_indirect_mesh_xmem_arguments_warp and ..._skip_wait_warp as Passed. The PR is mergeable.

Nits (non-blocking)

  • N1: With both X2W_MESH_HANDOFF and X2W_MESH_INDIRECT_XMEM on, a write whose size differs from the active lease (lease->bytes != bytes, mesh_xmem_handoff.inl near line 207) returns silently. It is safe, since no publication happens, but a one-line log would help diagnose a mixed configuration. A small test for that case would help too.
  • N2: The startup_indirect_mesh_xmem_arguments* tests are C++ and D3D12 only. I did not run a source mutation of the new lease logic locally, because this Linux worktree cannot build or run them. The PR's own skip-wait control already shows the 4/8 vs 8/8 difference for the queue wait. I did not run Windows WARP for this review. The CI Windows job already ran both new tests.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6057854029 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2332#pullrequestreview-6057854029). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:45:57Z. **Review:** COMMENTED --- Review of head `4f7ea51e046988c3cc879e2cf6a49434f4d3820c` (comment only). **Summary:** No P1 or P2 findings. The change generalizes the single-word SRV lease to a sized lease (4-byte SRV word or 12-byte `DISPATCH_MESH` record) and adds a read path for `ExecuteIndirect`. The logic reads consistently. **Checked by reading the diff** - `src/startup_stubs/mesh_xmem_handoff.inl`: the lease now carries `bytes`. `pin`, `matches`, the overlap tests, `placed_buffer_range` at submit, and the log lines all use it. I found no leftover `sizeof(UINT)` that should have been `bytes`. - `record_mesh_xmem_read` keeps the old SRV checks. These are the writer-in-same-recording refusal, the overlap refusal, the reserve-before-barrier ordering, and the size and alignment checks (4 bytes for a raw SRV, 4 for a record). `bind_mesh_xmem_srv` is now a thin wrapper, so the old caller behaves the same. - `src/startup_stubs/d3d12_xs_device.cpp:2694`: the new branch is gated on `mesh_xmem_indirect()`, a non-cached mesh pass, and a `copied_buffer` placement. A refusal returns before `ExecuteIndirect`. With the flag off, the old `require_state` path runs unchanged. - `src/startup_stubs/list_copy.inl:199`: the record is only tracked from a COMPUTE list, from a default-heap UAV-capable source, and with an exact 12-byte size. `srv_word` still needs `mesh_xmem_handoff()` plus an upload source. The two modes do not capture each other's copies. - `queue_execute` and the drop/discard hooks now use `mesh_xmem_tracking()`, so the lease bookkeeping runs under either flag. - Title and body are neutral and cite public issues and PRs only. Docs and the CMake and preset test entries match the new test names. **Commands run locally on the PR head (Linux)** - `python3 tests/docs_links_check.py` -> `Checked 18 Markdown files and 451 links.` - `python3 tests/bidi_controls_check.py` -> `Checked 1615 tracked source, script and build/CI files: no bidirectional controls.` - `git diff --check origin/main...HEAD` -> clean. - `gh pr checks 2332`: Windows build and test, gfx1013 fixtures, and the Linux Python checks all pass. The CI log shows `startup_indirect_mesh_xmem_arguments_warp` and `..._skip_wait_warp` as Passed. The PR is mergeable. **Nits (non-blocking)** - N1: With both `X2W_MESH_HANDOFF` and `X2W_MESH_INDIRECT_XMEM` on, a write whose size differs from the active lease (`lease->bytes != bytes`, `mesh_xmem_handoff.inl` near line 207) returns silently. It is safe, since no publication happens, but a one-line log would help diagnose a mixed configuration. A small test for that case would help too. - N2: The `startup_indirect_mesh_xmem_arguments*` tests are C++ and D3D12 only. I did not run a source mutation of the new lease logic locally, because this Linux worktree cannot build or run them. The PR's own skip-wait control already shows the 4/8 vs 8/8 difference for the queue wait. I did not run Windows WARP for this review. The CI Windows job already ran both new tests. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 14:04:47 +00:00
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!2324
No description provided.