Queued fence rewind leaves the completion word at the previous higher value #3282
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#3282
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@wish131400 on GitHub · 2026-11-28 05:09 UTC · original
Queued fence rewind leaves the shim completion word at its prior value
The queued fence completion shadow assumes that fence values only increase. A queue signal that lowers the desktop fence value can complete while both the shim GetCompletedValue method and its cached completion address remain at the earlier larger value.
This is reproducible using only the source-built
startup_fence_valuesfixture. It does not require title inputs or SDK binaries.Reproduction
Use the source-built fixture in #3281, commit
a5a92ea1c8b36de70c19babebaf054ef639b3c6a. Configure and build normally, then run:The CPU signals establish value 7. The fixture blocks a queue on a different fence, enqueues Signal(3) and a separate queue completion marker, then releases the blocker. After the marker completes, it polls the completion address before calling the shim GetCompletedValue method.
Observed after the focused CPU correction:
The lower queue signal must not become visible before it executes, and after queue completion the desktop value, method result and completion word should agree.
Cause and limits of a simple fix
fence_reachedcurrently performs an atomic maximum. Merely changing the queued callback to assign its target, or sample the desktop fence, is insufficient: SetEventOnCompletion(3) is already satisfied while the current fence is 7, before the queue executes Signal(3). A separate queue-order completion marker, or equivalent independent mechanism, is needed to publish queued rewinds at the correct time.There is also a source-visible mixed CPU/queue interleaving: a callback retaining an older larger queue target can run after a successful CPU rewind and overwrite the lower shadow through
fence_reached. That interleaving was not induced in this run. The passing CPU fixture has no command queue and does not cover pending callbacks.The optional diagnostic deliberately returns failure and is excluded from passing CTest registrations. The focused CPU Signal fix does not claim to resolve this queued case. Concurrent producer ordering, callback setup failures and device removal need explicit handling in any general queue fix. The CPU patch leaves the shim completion method as a cached-word read and introduces no new lock there.
Environment
Base
240e0fb9c460f24d51683abe2d4cce2800b136c1with the focused CPU Signal correction; x64 Debug; Windows 10 Pro 10.0.19045; MSVC 19.43.34810; Microsoft Basic Render Driver (WARP), raw DXGI driver version 2814751014983330; D3D12 debug layer enabled. The queued diagnostic was measured on WARP. The passing CPU correction was separately verified on NVIDIA GeForce RTX 4070 Ti SUPER.Public D3D12 synchronization guidance explicitly permits fence rewinding: https://learn.microsoft.com/en-us/windows/win32/direct3d12/user-mode-heap-synchronization