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. |
Refresh the slot 12 mirror when the completion wait times out. Keep the existing pending fence event so a rewind cannot accumulate duplicate registrations. The mock test covers a CPU rewind followed by progress below the old threshold and a rewind from outside the proxy. Original fails and patched passes in five runs each on Wine 11.20. AI-assisted.
|
@rison1337 thanks, that is a real hole: a rewind below the armed threshold left the mirror stale until the fence climbed past it. I picked your commit onto the branch unchanged, with your authorship (04fdf37). The 10 ms timeout refresh only reads @MartinIndra02 @Etr0p your passes were on 5ac4dea, before this commit. CI is re-running on the new head. |
|
Follow-up to my comment above: I cherry-picked |
|
AI-assisted. No game files used. Tested
|
|
Retail data point for this (my own 1.0.2.1 copy, Windows 11 + RTX 3060, integration tree with the boot PRs; #7496 comment 7107949979). Statically, the caller takes the returned pointer and spins on the word it points to: it compares the value with |
|
Tested on the retail executable: pass. Windows 11, i7-14700K, RTX 4070 SUPER, MSVC RelWithDebInfo, |
|
AI-assisted boot A/B on Wine 11.22, RTX 4070/NVIDIA 620.73.04. I adapted the slot-12 mirror from this PR's current diff (including rewind polling) onto a local boot stack. Baseline stopped making progress after refusing slot 12, with one swapchain present. With the mirror it submitted another command list, reached Bink setup and recorded two swapchain presents. Movie open and decode were still unobserved. |
|
@rafaelpssz both of your points are covered on the current head,
Retail passes so far: jacksonslab (Windows, RTX 4070 SUPER, on |
The fork keeps the console queue tail answering S_OK; fence slot 12 joins it as the one fence slot past the public chain that is served. The mock fence keeps the queue-frequency and heap cases next to ItsNotRexed#7290's fence switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
checked: #7290d5fa829 | with: head-vs-forge-main comparison of the Import status:
Runs (base
Audit: agent: yes |
|
Tested Merged onto @tibzejoker's
Traces stay local; only outcomes, slot numbers and public formats here. AI-assisted (Claude Code). |
|
Source-only integration note for In The existing #6243 at This is a source-level ordering finding. No event-handle lifetime reproducer was executed, and no runtime failure of this ordering is claimed. |
|
Retail test report (local integration, AI-assisted with Claude Code; RTX 5070, driver 621.24, Windows 11): the idea here fixes a real stop. Without a live mirror, the main thread spins on fence slot 12's value, one short of the target, and the title watchdog fires at about 62 s. A local port (a thread-pool wait per fence proxy that refreshes the mirror and re-arms SetEventOnCompletion(v+1)) clears it. The boot then goes on to the first command lists. |
|
checked: #7290 | with: applied the diff on main 6312c05, built xs_proxy_mock_test and queue_proxy_test (MSVC 14.44, Ninja RelWithDebInfo) | on: Windows 11, RX 9060 XT | result: PASS — xs_proxy_mock_test PASS (11 allocations refused on purpose), queue_proxy_test 3 backend(s) passed covering all 64 fence slots on WARP and Vulkan Code read: slot 12 returns the address of a per-fence mirror kept live by a thread-pool wait that re-arms SetEventOnCompletion(value+1) on the real fence, refreshes on slot-12 calls and CPU Signal, takes a lock for ordering, propagates ~0 on device removal, and WaitForThreadpoolWaitCallbacks drains callbacks before teardown. The 10 ms wait timeout covers fence rewind. Matches the title's (value, &{0, callback, 0, 0}, flags) call shape and its *p vs ~0 / value-subtraction reads. AI-assisted check. |
|
Tested d5fa829 (merged into a local tree: |
…ress of a completed value that stays live (retail executable, past the PC fence chain) Squashed from ItsNotRexed#7290 by TreXito, head 04fdf37 (security scan PASS). Conflicts in xs_proxy_mock_test only: the Mock struct keeps ItsNotRexed#7235's allocation_size/private_data next to this PR's fence fields; the fence switch replaces the fixed GetCompletedValue line, with the resource SetPrivateDataInterface and heap 9/10 cases kept after it; the check list takes the union.
…o ExecuteCommandLists Squashed from ItsNotRexed#7286 by Vadson159, head e925b63 (security scan PASS). Conflicts with ItsNotRexed#7290 (fence slot 12): the queue and fence slot constants are both kept, the header's queue/fence paragraph names slot 35 and fence slot 12, and the refused-tail loops skip both (queue_slot_overridden, fence slot 12). Reviewers' unwrapping bug (a list proxy reaching ExecuteCommandListsX) does not apply here: command lists are not wrapped in this tree (ItsNotRexed#2490 is not in).
… slot 9 (SetAllocatorCallbackX) on allocator proxy Squashed from ItsNotRexed#7949 by DevilNine, head e29e989 (security scan PASS). Conflicts with ItsNotRexed#7290/ItsNotRexed#7286 in the child proxy: the allocator-callback fields sit next to the fence mirror, and the allocator slot-9 branch follows the queue slot-35 branch.
…load arena, PC-list fixture path Squashed from ItsNotRexed#2490 by NolanCotter, head ef9d075 (security scan PASS). Taken at ef9d075, after upstream's revert (57c1753): this head keeps device proxies made by direct callers on PC-shaped lists (the run_tiny_frame regression), maps the console list IID, wraps slot-73 lists, and routes console list slot 139 (Reset) to PC slot 10. Security: prescan no flags, Haiku read PASS; the IID header cites a GPL-3.0 project as a second source for one GUID value measured from the executable (provenance note, no code taken). Conflicts with Wave 2: the queue proxy keeps ItsNotRexed#7286's ExecuteCommandListsX (slot 35) ahead of this PR's console-layout detection, SignalX and PresentX, and queue_execute_command_lists now unwraps list proxies the way this PR's slot-10 path does (with list proxies in play, ItsNotRexed#7286's early return would have handed the real queue proxies, as ItsNotRexed#7286's reviewers predicted); fence slot 12 (ItsNotRexed#7290) and allocator slot 9 (ItsNotRexed#7949) stay in front of the queue block; device_slot_overridden takes slot 12 with the Wave 2 slots. Tests: queue_proxy_test and the mock's check_tail keep fence slot 12 and expect this PR's S_OK queue tail except overridden slots (35); the mock Kind enum keeps heap and list; the check list takes the union.
|
Tested the complete source of #7290 ( Windows x64, MSVC, RTX 4080, driver 610.62:
These are synthetic test results. They do not verify the retained-real-fence lifetime fixture, every concurrency interleaving, the unused descriptor callback, or actual title pixels. The documented retained-reference event-handle leak is unchanged. |
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:
SetEventOnCompletion(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. A 10 ms wait timeout also refreshes it when the fence rewinds below the armed threshold (@rison1337's commit).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.WaitForThreadpoolWaitCallbackswaits out a callback in flight), then releases the real fence. The event is closed only when that release destroyed the fence. The lastSetEventOnCompletioncan still be pending on it, and no call cancels one, so when another reference keeps the real fence alive the event stays open (one handle per such fence) instead of leaving the fence to set a closed or reused handle (@Hiiva's review).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