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

Open
github-bot wants to merge 3 commits from github-bot/gh-958 into main AGit
Owner

@⁠Kadamitas on GitHub · 2026-11-24 15:42 UTC · original
Kadamitas:restore/queue-child-lifetime → main · +113 −11 · 2 files · 3 commits · open

Claimed in the coordination issue as: #14

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 current main's command-list unwrapping and presentation routes. The mock samples the queue and fence ownership counts inside Signal and Wait, then checks that both return to their initial counts. 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

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 current main (a28927849).
  • Focused on queue/fence lifetime and the corresponding mock coverage.
  • Contains source code only.
**@⁠Kadamitas** on GitHub · 2026-11-24 15:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/958) `Kadamitas:restore/queue-child-lifetime` → `main` · +113 −11 · 2 files · 3 commits · open Claimed in the coordination issue as: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 ### 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 current main's command-list unwrapping and presentation routes. The mock samples the queue and fence ownership counts inside Signal and Wait, then checks that both return to their initial counts. 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 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 current main (a28927849). - [x] Focused on queue/fence lifetime and the corresponding mock coverage. - [x] Contains source code only.
(cherry picked from commit f6586decf7e5e0b26c084825b3bd26a760bf6c67)
(cherry picked from commit 95621062dfe5a3d5337e9f7d789d25faea8b53cf)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:30:28 +00:00
Author
Owner

@⁠Snooozs on GitHub · 2026-11-24 17:39 UTC · original

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.

**@⁠Snooozs** on GitHub · 2026-11-24 17:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/958#issuecomment-7139512351) 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.
This pull request has changes conflicting with the target branch.
  • runtime/shims/d3d12_xs_device.cpp
  • runtime/test/xs_proxy_mock_test.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/958/head:github-bot/gh-958'
git switch 'github-bot/gh-958'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-958'
git switch 'github-bot/gh-958'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-958'
git switch 'github-bot/gh-958'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-958'
git switch 'main'
git merge --squash 'github-bot/gh-958'
git switch 'main'
git merge --ff-only 'github-bot/gh-958'
git switch 'main'
git merge 'github-bot/gh-958'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.