docs: queue slot 31 remaps in queue order; test two deferred remaps (RT-SLOT31-QUEUE-ORDER-DOCS) #2808

Closed
ubiquitarianism wants to merge 2 commits from upstream-pr/2808 into main
ubiquitarianism commented 2026-12-01 00:31:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ubiquitarianism on 2026-12-01T00:31:52Z.


Claimed in the coordination issue as: RT-SLOT31-QUEUE-ORDER-DOCS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7296419849)

What and why

The queue slot 31 (CopyPageMappingsBatchX) row in docs/d3d12_vulkan.md still ends with a Known gap: the mappings change when the call is made, not when the queue reaches the batch. docs/linux_proton.md says the same. The code already orders the remap on the queue (runtime/shims/d3d12_xs_device.cpp): the call signals the queue's write fence, waits up to 16 ms (kPageMappingWaitMs) for earlier work and remaps under the queue's order lock; past that it queues a Wait on a gate fence, and the list-value releaser remaps once the write fence passes the call's point, then signals the gate (Pump::add_action). LEONIDA_SLOT31_ASYNC=1 gives the order up.

  • Both docs now describe that ordering, and what is still open: whether the console's CPU also sees the old mapping until the queue reaches the call, and how many calls of a boot are deferred (remaps_deferred), are not measured.
  • xs_proxy_mock_test checks that two deferred remaps run in call order, and asserts each remap before its gate is signalled.

Not run in game.

Tested

Windows 11 (26200), Visual Studio 18 (2026) MSVC, AMD Radeon RX 6800 (driver 32.0.21030.2001), rebased on main at 66b5d0433:

  • runtime RelWithDebInfo build with the Windows SDK's d3d12.lib/dxgi.lib; ctest -R "xs_proxy_mock|device_proxy": 12 of 12 passed; full ctest: 205 of 205 passed
  • scripts/check_no_game_data.py on the changed files: OK

The rebase conflicted with a newer main edit to the slot 81 row next to it; the slot 81 row is main's, unchanged.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5576410735 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2808). Originally posted by [ubiquitarianism](https://github.com/ubiquitarianism) on 2026-12-01T00:31:52Z. --- Claimed in the coordination issue as: RT-SLOT31-QUEUE-ORDER-DOCS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7296419849) ### What and why The queue slot 31 (`CopyPageMappingsBatchX`) row in `docs/d3d12_vulkan.md` still ends with a **Known gap**: the mappings change when the call is made, not when the queue reaches the batch. `docs/linux_proton.md` says the same. The code already orders the remap on the queue (`runtime/shims/d3d12_xs_device.cpp`): the call signals the queue's write fence, waits up to 16 ms (`kPageMappingWaitMs`) for earlier work and remaps under the queue's order lock; past that it queues a `Wait` on a gate fence, and the list-value releaser remaps once the write fence passes the call's point, then signals the gate (`Pump::add_action`). `LEONIDA_SLOT31_ASYNC=1` gives the order up. - Both docs now describe that ordering, and what is still open: whether the console's CPU also sees the old mapping until the queue reaches the call, and how many calls of a boot are deferred (`remaps_deferred`), are not measured. - `xs_proxy_mock_test` checks that two deferred remaps run in call order, and asserts each remap before its gate is signalled. Not run in game. ### Tested Windows 11 (26200), Visual Studio 18 (2026) MSVC, AMD Radeon RX 6800 (driver 32.0.21030.2001), rebased on `main` at `66b5d0433`: - runtime RelWithDebInfo build with the Windows SDK's `d3d12.lib`/`dxgi.lib`; `ctest -R "xs_proxy_mock|device_proxy"`: 12 of 12 passed; full `ctest`: 205 of 205 passed - `scripts/check_no_game_data.py` on the changed files: OK The rebase conflicted with a newer `main` edit to the slot 81 row next to it; the slot 81 row is `main`'s, unchanged.
fiestorra commented 2026-12-01 01:23:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T01:23:57Z.


Verified on Windows: it builds and the test passes, and the assertions it adds are the substantial kind - a deferred remap's order, its wait, and the counters that prove both.

main d920d850d plus this pull request, MSVC 19.44.35226, Release:

cmake --build runtime/build --target xs_proxy_mock_test     exit 0
runtime\build\xs_proxy_mock_test.exe                        exit 0
  [rt] d3d12_xs: CopyPageMappingsBatchX waits behind held queue work: the remap runs when the queue gets there (1 ...)
  [rt] d3d12_xs: CopyPageMappingsBatchX waits behind held queue work: the remap runs when the queue gets there (2 ...)
  xs_proxy_mock_test: PASS (12 allocations refused on purpose)

What the 33 added lines actually check, since "the test passes" says nothing about that: two CopyPageMappingsBatchX calls behind work the queue has not done, each queuing its own Wait on the new fence, then the first signalled - expect g_queue_call_count == 4 with each call named by kind and value, !list_values_idle(30) while the second remap is still held, the first destination recorded in order[0], and after the second signal stats.remaps_deferred == 3 && stats.remaps_now == 1 && stats.remaps_failed == 0. That is a sequence, not a smoke test.

What I did not do, and it is the control this would want: I did not break the deferral to watch it fail. The change is in the mock and the assertions, so there is no source line of this pull request to mutate - the line to mutate is in the proxy's queue path, and a reviewer who knows it should. My check is execution, not mutation, and I would rather label it.

The docs half (docs/d3d12_vulkan.md, docs/linux_proton.md, 2 and 6 lines) reads consistently with the test: the queue slot 31 remap "applied in queue order" is what the four queued calls assert.

AI-assisted: yes - DeepSeek v4.1 (flash), built and ran it on the machine above.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7297452750 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2808#issuecomment-7297452750). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-01T01:23:57Z. --- **Verified on Windows: it builds and the test passes, and the assertions it adds are the substantial kind - a deferred remap's order, its wait, and the counters that prove both.** **`main` `d920d850d` plus this pull request, MSVC 19.44.35226, Release:** ``` cmake --build runtime/build --target xs_proxy_mock_test exit 0 runtime\build\xs_proxy_mock_test.exe exit 0 [rt] d3d12_xs: CopyPageMappingsBatchX waits behind held queue work: the remap runs when the queue gets there (1 ...) [rt] d3d12_xs: CopyPageMappingsBatchX waits behind held queue work: the remap runs when the queue gets there (2 ...) xs_proxy_mock_test: PASS (12 allocations refused on purpose) ``` **What the 33 added lines actually check**, since "the test passes" says nothing about that: **two `CopyPageMappingsBatchX` calls behind work the queue has not done**, **each queuing its own Wait on the new fence**, **then the first signalled** - **expect `g_queue_call_count == 4` with each call named by kind and value**, **`!list_values_idle(30)` while the second remap is still held**, **the first destination recorded in `order[0]`**, **and after the second signal `stats.remaps_deferred == 3 && stats.remaps_now == 1 && stats.remaps_failed == 0`.** **That is a sequence, not a smoke test.** **What I did not do, and it is the control this would want**: **I did not break the deferral to watch it fail.** **The change is in the mock and the assertions, so there is no source line of this pull request to mutate** - **the line to mutate is in the proxy's queue path, and a reviewer who knows it should.** **My check is execution, not mutation, and I would rather label it.** **The docs half** (`docs/d3d12_vulkan.md`, `docs/linux_proton.md`, 2 and 6 lines) **reads consistently with the test**: **the queue slot 31 remap "applied in queue order" is what the four queued calls assert.** **AI-assisted:** yes - DeepSeek v4.1 (flash), built and ran it on the machine above. Written with an AI assistant.
KelboLive commented 2026-12-01 04:40:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T04:40:54Z.

Review: COMMENTED


Claim checks out against the code, clause by clause: the call signals the queue's write fence (d3d12_xs_device.cpp:2448), the 16 ms wait and the remap under queue_order (kPageMappingWaitMs at :2358, lock at :2663 — queue_slot_orders_work(31) is true), past that the gate Wait plus pump.add_action(values, gate, point, …) (:2497-2500), the releaser opening it on written >= gate.after (d3d12_xs_list_values.h:1102) and running the action before signalling the gate (:973-974), and the fallbacks at :2479-2481 / :2519-2525. Removing the "Known gap" is right.

The test tests order, not just that both remaps land: each call gets its own point (3 then 4), only point 3 being passed leaves count == 1 with order[0] == 0x9100000000 and the pump not idle (xs_proxy_mock_test.cpp:4796-4797), and only then does point 4 give order[1]. I proved it can fail: making Pump::add_action LIFO (push_front, d3d12_xs_list_values.h:569 locally, reverted afterwards) fails the test at line 4796; restored, xs_proxy_mock passes again (4.35 s, VS 18 2026 / MSVC 14.52, RelWithDebInfo).

One robustness suggestion: "the remap happened before its gate opened" is judged by polling fence_completed(c_gate) at 1 ms and then reading the count, so a mutant that signalled the gate first and remapped immediately after could occasionally slip through. Recording fence_completed(gate) inside record_page_mapping and asserting it is still the old value would make the check deterministic and timing-free.

Two doc nits: docs/d3d12_xs_console_abi.md:287 still states as fact that the console's CPU does not wait either ("the console's CPU does not either"), while the new slot-31 row lists exactly that as Open — one of the two should be softened. And ctest -R "xs_proxy_mock|device_proxy" gives 11 tests on my build rather than the 12 in the body; worth checking that nothing is silently skipped by a missing target.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6125216659 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2808#pullrequestreview-6125216659). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T04:40:54Z. **Review:** COMMENTED --- Claim checks out against the code, clause by clause: the call signals the queue's write fence (`d3d12_xs_device.cpp:2448`), the 16 ms wait and the remap under `queue_order` (`kPageMappingWaitMs` at `:2358`, lock at `:2663` — `queue_slot_orders_work(31)` is true), past that the gate `Wait` plus `pump.add_action(values, gate, point, …)` (`:2497-2500`), the releaser opening it on `written >= gate.after` (`d3d12_xs_list_values.h:1102`) and running the action before signalling the gate (`:973-974`), and the fallbacks at `:2479-2481` / `:2519-2525`. Removing the "Known gap" is right. The test tests **order**, not just that both remaps land: each call gets its own point (3 then 4), only point 3 being passed leaves `count == 1` with `order[0] == 0x9100000000` and the pump not idle (`xs_proxy_mock_test.cpp:4796-4797`), and only then does point 4 give `order[1]`. I proved it can fail: making `Pump::add_action` LIFO (`push_front`, `d3d12_xs_list_values.h:569` locally, reverted afterwards) fails the test at line 4796; restored, `xs_proxy_mock` passes again (4.35 s, VS 18 2026 / MSVC 14.52, RelWithDebInfo). One robustness suggestion: "the remap happened before its gate opened" is judged by polling `fence_completed(c_gate)` at 1 ms and then reading the count, so a mutant that signalled the gate first and remapped immediately after could occasionally slip through. Recording `fence_completed(gate)` inside `record_page_mapping` and asserting it is still the old value would make the check deterministic and timing-free. Two doc nits: `docs/d3d12_xs_console_abi.md:287` still states as fact that the console's CPU does not wait either ("the console's CPU does not either"), while the new slot-31 row lists exactly that as **Open** — one of the two should be softened. And `ctest -R "xs_proxy_mock|device_proxy"` gives 11 tests on my build rather than the 12 in the body; worth checking that nothing is silently skipped by a missing target.
merzleckeier commented 2026-12-01 12:44:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T12:44:01Z.


Observed the gate value inside each deferred-remap callback on 17c548d61 + 6c7f6b60c under Wine. The stock xs_proxy_mock_test passed. For a second build I added a read of the mock gate to the existing remap hook. In all three runs the first callback saw gate value 2 and the second saw 3. After both callbacks the gate reached 4. This verifies directly that the two deferred remaps run in order and each callback sees its own gate still closed. Synthetic COM queue and fences only.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311566975 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2808#issuecomment-7311566975). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T12:44:01Z. --- Observed the gate value inside each deferred-remap callback on `17c548d61` + `6c7f6b60c` under Wine. The stock `xs_proxy_mock_test` passed. For a second build I added a read of the mock gate to the existing remap hook. In all three runs the first callback saw gate value 2 and the second saw 3. After both callbacks the gate reached 4. This verifies directly that the two deferred remaps run in order and each callback sees its own gate still closed. Synthetic COM queue and fences only. AI-assisted with OpenAI Codex.
aslan2142 commented 2026-12-01 17:26:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:26:36Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319306043 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2808#issuecomment-7319306043). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:26:36Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!2808
No description provided.