Repository navigation
d3d12_xs: fence slot 12 returns the address of a completed value that stays live (retail executable, past the PC fence chain) - #7290
Conversation
The retail executable calls fence slot 12, one past ID3D12Fence1, as (value, descriptor, flags) and reads the return as a pointer to the fence's 64-bit completed value: it compares it with ~0 and subtracts the value it waits for. The proxy refused it with E_NOTIMPL, which the title then dereferenced. Each fence now gets a mirror on its first slot 12 call. A wait-thread callback reads the real fence's completed value into it and re-arms SetEventOnCompletion(value + 1), so it follows every completion without another call; slot 12 and the CPU Signal refresh it at once, under a lock. After device removal it holds ~0 and nothing is re-armed. The release of the proxy unregisters the wait before the real fence goes. The descriptor's code pointer is not called. Tests: xs_proxy_mock_test (mock fences now keep a completed value and arm one event) and queue_proxy_test (a real queue signal reaches the mirror). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows + GPU test of Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124 / 621.24), Vulkan SDK 1.4.363.1, no game files.
AI-assisted review/test. |
|
Tested 5ac4dea, merged with What this adds to @MartinIndra02's RTX 3080 run: an AMD driver (host D3D12 and Vulkan on an RDNA2 GPU), a Blackwell GPU, a negative control, and the other ctest forms. GPUs: NVIDIA GeForce RTX 5070 Ti Laptop GPU (driver 621.24) and AMD Radeon 610M (RDNA2 gfx1036, AMD 26.11.2). The host D3D12 hardware backend is the first adapter, the 610M, in both runs.
Not run: the retail executable on the AI-assisted (Claude Code). |
|
A separate measurement of the same stop, from a run that doesn't use #6982's set. Native Windows 11, RTX 4080 SUPER, MSVC 14.51 build of
|
|
Independent check of
D3D12 permits fence rewinds. The added test failed on this head in five of five runs. Follow-up commit with a regression test, based directly on this PR. It uses a thread-pool wait with a 10 ms timeout to refresh below the outstanding threshold. Timeout callbacks do not register another fence event. The regression also checks a rewind outside the proxy, progress below the threshold, then a signal that satisfies the original event. The full mock test passed five of five runs with the change. This is a synthetic check. I have not tested the retail executable, native Windows, or the polling overhead with many live fences. AI-assisted. |
Claimed in the coordination issue as: fence slot 12, past the PC chain (#7049 comment)
Depends on: none. Base
main8575d36ed.What and why
@simonbronk's run on #6982 (
boot-integrationplus #7115, #6891, #7163, #3777, #6935) reached fence slot 12, one pastID3D12Fence1. The title calls it as(value, &{0, callback, 0, 0}, flags)and reads the return as a pointer to the fence's 64-bit completed value: it compares*pwith~0(device removed) and subtracts the value it waits for.mainrefuses the slot withE_NOTIMPL, so the title dereferences0x80004001and crashes. Their local stand-in returned a per-fence value refreshed on each call, and the run went on to command-list recording. They noted that the real thing has to stay live, not only refresh when called.This PR makes the value stay live:
RegisterWaitForSingleObject,WT_EXECUTEINWAITTHREAD) reads the real fence's completed value into the mirror and re-armsSetEventOnCompletion(value + 1, event)on the real fence. So the mirror follows every completion, whether a queue signals it on the GPU or the CPU does.Signal(slot 10) refresh the mirror at once. A title that signals from the CPU and reads straight away sees its own value.~0, which is what the title tests for, and the callback stops re-arming.UnregisterWaitEx(INVALID_HANDLE_VALUE)waits out a callback in flight), then releases the real fence, then closes the event.Every other slot past the chain is still refused.
docs/d3d12_command_objects.mdand the header comment now name the exception.Tested
Cross-built with clang-cl 21 and xwin (MSVC CRT and Windows SDK headers), run under Wine 10 on Linux.
ctest -R "xs_proxy_mock|queue_proxy|device_proxy|allocator_proxy": 8 passed, 2 skipped (device_proxyanddevice_proxy_traceskip under Wine, as they do onmain).xs_proxy_mock_test. Mock fences now keep a completed value:Signalsets it, andSetEventOnCompletionarms one event. The newcheck_fence_completed_valueruns for fences with and withoutID3D12Fence1. It checks:Signalthrough the proxy is visible at once;~0and nothing is re-armed after it;check_tailstarts its refused range at 13.queue_proxy_teston the Vulkan layer (llvmpipe under Wine; host D3D12 skips under Wine): slot 12's value follows a realqueue->Signal(fence, 9)without another call, and a second call returns the same address. The refused-tail loop skips slot 12. Output:Vulkan: every public queue and fence slot forwarded and counted; fence slot 12 follows a queue signal; tail refused, andqueue_proxy_test: 1 backend(s) passed.Not run: the retail executable. I can't run it, so whether the title goes on past this slot with a live value is for someone on the
boot-integrationstack to confirm. Atried:line on Boot log for coding agents: where the executable stops and which PRs get past it #7154 would settle it.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code