Skip to content

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

Open
Kadamitas wants to merge 3 commits into
ProjectLeonida:mainfrom
Kadamitas:restore/queue-child-lifetime
Open

Kadamitas wants to merge 3 commits into
ProjectLeonida:mainfrom
Kadamitas:restore/queue-child-lifetime

Conversation

@Kadamitas

@Kadamitas Kadamitas commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #14 (comment)

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 8106179, 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.

@Snooozs

Snooozs commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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 3295055 without conflicts, targets rebuilt, CPU only, no game files. AI-assisted (Claude Code): I read the whole diff and ran this on that machine.

@Kadamitas
Kadamitas force-pushed the restore/queue-child-lifetime branch from 8106179 to fe9ee37 Compare November 24, 2026 20:17
@Kadamitas
Kadamitas marked this pull request as ready for review November 24, 2026 20:17
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
(cherry picked from commit f6586decf7e5e0b26c084825b3bd26a760bf6c67)
(cherry picked from commit 95621062dfe5a3d5337e9f7d789d25faea8b53cf)
@Kadamitas
Kadamitas force-pushed the restore/queue-child-lifetime branch from fe9ee37 to 53ed711 Compare November 27, 2026 18:56
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants