d3d12_xs: retain queue and fence wrappers through forwarded calls #958

Merged
Kadamitas merged 3 commits from upstream-pr/958 into main 2026-11-28 09:52:04 +00:00
Kadamitas commented 2026-11-24 15:42:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kadamitas on 2026-11-24T15:42:48Z.


Claimed in the coordination issue as: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136476546

What and why

Restore two changes originally proposed in ItsNotRexed/Leonida PR 9475. A forwarded queue operation now keeps its wrapper alive until the backend returns. Signal and Wait also retain the fence wrapper while using its underlying object. The live-child index uses 256 address buckets and performs identity checks without allocating during lookup. The registry lock is released before calling the backend or releasing an underlying COM object.

The rebase preserves main's command-list, presentation, and queue-order routes. It retains the fence in the shifted Signal and Wait slots and in SignalX. The mock checks both reference counts during forwarding and after return. A reentrant AddRef or Release can observe the internal reference in its return count. Credit to VibeClauding for reviewing the original change and identifying the need to check ownership during the call.

The claim uses the unlisted-work route in CONTRIBUTING.md. A board ID can be added if the maintainers assign one.

Tested

  • Nov 27 rebase onto 43a9d562d: all nine CMake xs_proxy_mock cases passed on Windows, including original and shifted Signal/Wait plus SignalX ownership checks.

Earlier verification:

On Windows 11 Pro 25H2 (26200.9974), Visual Studio 2022 MSVC toolset 14.36.32532, x64. All six existing mock modes passed on 8106179d6, including the new in-call ownership assertions. The default run also checked presentation and command-list forwarding.

The normal CMake target stopped in the separate CRT timed-wait shim on this older toolset. The proxy mock's two source files compiled directly from an x64 developer prompt:

cl /nologo /std:c++20 /EHsc /O2 /MD /utf-8 /permissive- /DWIN32_LEAN_AND_MEAN /DNOMINMAX runtime/test/xs_proxy_mock_test.cpp runtime/shims/d3d12_xs_device.cpp /Fe:xs_proxy_mock_test.exe

Ran the executable with no arguments and with each of --fail-virtualalloc, --fail-virtualprotect, --fail-veh, --env-slots, and --env-slots-invalid. The repository content guard and git diff --check also passed.

GPUs tested: n/a, synthetic COM backend.
AI-assisted: yes.

Checklist

  • Based on main at 43a9d562d.
  • Focused on queue/fence lifetime and the corresponding mock coverage.
  • Contains source code only.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5475413792 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/958). Originally posted by [Kadamitas](https://github.com/Kadamitas) on 2026-11-24T15:42:48Z. --- Claimed in the coordination issue as: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7136476546 ### What and why Restore two changes originally proposed in ItsNotRexed/Leonida PR 9475. A forwarded queue operation now keeps its wrapper alive until the backend returns. Signal and Wait also retain the fence wrapper while using its underlying object. The live-child index uses 256 address buckets and performs identity checks without allocating during lookup. The registry lock is released before calling the backend or releasing an underlying COM object. The rebase preserves main's command-list, presentation, and queue-order routes. It retains the fence in the shifted Signal and Wait slots and in SignalX. The mock checks both reference counts during forwarding and after return. A reentrant AddRef or Release can observe the internal reference in its return count. Credit to VibeClauding for reviewing the original change and identifying the need to check ownership during the call. The claim uses the unlisted-work route in CONTRIBUTING.md. A board ID can be added if the maintainers assign one. ### Tested - Nov 27 rebase onto `43a9d562d`: all nine CMake `xs_proxy_mock` cases passed on Windows, including original and shifted Signal/Wait plus SignalX ownership checks. Earlier verification: On Windows 11 Pro 25H2 (26200.9974), Visual Studio 2022 MSVC toolset 14.36.32532, x64. All six existing mock modes passed on 8106179d6, including the new in-call ownership assertions. The default run also checked presentation and command-list forwarding. The normal CMake target stopped in the separate CRT timed-wait shim on this older toolset. The proxy mock's two source files compiled directly from an x64 developer prompt: ``` cl /nologo /std:c++20 /EHsc /O2 /MD /utf-8 /permissive- /DWIN32_LEAN_AND_MEAN /DNOMINMAX runtime/test/xs_proxy_mock_test.cpp runtime/shims/d3d12_xs_device.cpp /Fe:xs_proxy_mock_test.exe ``` Ran the executable with no arguments and with each of `--fail-virtualalloc`, `--fail-virtualprotect`, `--fail-veh`, `--env-slots`, and `--env-slots-invalid`. The repository content guard and `git diff --check` also passed. GPUs tested: n/a, synthetic COM backend. AI-assisted: yes. ### Checklist - [x] Based on main at `43a9d562d`. - [x] Focused on queue/fence lifetime and the corresponding mock coverage. - [x] Contains source code only.
Snooozs commented 2026-11-24 17:39:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Snooozs on 2026-11-24T17:39:21Z.


Independent check: all six xs_proxy_mock* CTests pass; the new test with main's d3d12_xs_device.cpp fails at line 1216 (observed_queue_refs == 2 && observed_fence_refs == 2), so it does check the pins. It also merges with #968, and the combined tree passes xs_proxy_mock* and xmem (7/7).

Reading note, not a blocker: the comment says the pins do not change the guest-visible counters. A Release that re-enters during a forwarded call still returns the count including the pin (1 instead of 0 for the caller's last reference), and the same for AddRef. Nothing here depends on it, but the comment could say so.

Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, merged onto main 32950551e without conflicts, targets rebuilt, CPU only, no game files. AI-assisted (Claude Code): I read the whole diff and ran this on that machine.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7139512351 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/958#issuecomment-7139512351). Originally posted by [Snooozs](https://github.com/Snooozs) on 2026-11-24T17:39:21Z. --- Independent check: all six `xs_proxy_mock*` CTests pass; the new test with `main`'s `d3d12_xs_device.cpp` fails at line 1216 (`observed_queue_refs == 2 && observed_fence_refs == 2`), so it does check the pins. It also merges with #968, and the combined tree passes `xs_proxy_mock*` and `xmem` (7/7). Reading note, not a blocker: the comment says the pins do not change the guest-visible counters. A `Release` that re-enters during a forwarded call still returns the count including the pin (1 instead of 0 for the caller's last reference), and the same for `AddRef`. Nothing here depends on it, but the comment could say so. Windows 10 Pro 22H2 (19045), VS 2022 RelWithDebInfo, merged onto `main` 32950551e without conflicts, targets rebuilt, CPU only, no game files. AI-assisted (Claude Code): I read the whole diff and ran this on that machine.
MoonEyes commented 2026-11-28 09:51:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T09:51:58Z.


Red/green: the PR's test fails on main and passes with this PR (checked by OreoFR).
Runtime batch of 20 PRs tested by OreoFR (full build, ctest without the game, Python suite, translator): same results as main 09c153948, RTX 4070 Laptop / Windows 11.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237517224 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/958#issuecomment-7237517224). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T09:51:58Z. --- Red/green: the PR's test fails on main and passes with this PR (checked by OreoFR). Runtime batch of 20 PRs tested by OreoFR (full build, ctest without the game, Python suite, translator): same results as main 09c153948, RTX 4070 Laptop / Windows 11. AI-assisted (Claude Code, Claude Opus 5.5)
OreoFR commented 2026-11-28 21:45:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:45:38Z.


Verified by OreoFR

  • Base: main 09c153948 + PR head 53ed711b8; integration package 1 of 6 (20 PRs, merged without conflict)
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; full Python suite; translator suite
  • Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps)
  • Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main; Python: the same 7 failing files as main, the PRs' 11 test files pass; translator: 0 failures
  • Verdict: CLEAN PACKAGE (no new failure vs main)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246251572 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/958#issuecomment-7246251572). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:45:38Z. --- **Verified by OreoFR** - Base: main `09c153948` + PR head `53ed711b8`; integration package 1 of 6 (20 PRs, merged without conflict) - Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; full Python suite; translator suite - Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps) - Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main; Python: the same 7 failing files as main, the PRs' 11 test files pass; translator: 0 failures - Verdict: CLEAN PACKAGE (no new failure vs main) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
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!958
No description provided.