startup: wait on the GPU for console queue Wait (slot 17) #1341
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1348"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T08:52:28Z.
Change
The D3D12 stand-in (
src/startup_stubs/d3d12_xs_device.cpp) sends unknown console queue slots toqueue_dynamic, which picks an action from the argument shape. A (fence, value) call always became a desktopSignal. The comment there already noted that a Wait has the same shape, so a Wait completed its fence at once instead of waiting.The stand-in already handles two queue slots from the title's calls: slot 18 is
GetTimestampFrequencyand slot 32 is the console present. On the desktop queue,Signal,WaitandGetTimestampFrequencyare slots 14, 15 and 16. Slot 18 means the console queue has two more methods before them, which puts Signal at 16 and Wait at 17. That is an inference from the layout: no title call to slot 17 has been logged yet.Now:
ID3D12CommandQueue::Wait(fence, value). Any other argument shape still goes through the shape dispatch.X2W_D3D12_RENDER=1mode. Outside render mode a Signal used to complete on the CPU at once, so the wait would have had no visible effect.Fixture
tests/startup_queue_wait.cppcreates a device withD3D12XboxCreateDevice, then two queues and four fences through the stand-in, and calls the console queue slots directly.Wait(F, 1), slot 16Signal(G, 1)The control checks that the probe can detect a wait that signals. Against the stand-in on
main, the wait case fails with exit 10 on both adapters (wait: slot 17, G=1 before F is signalled).Verification
Tested
b5804f60(ond6cbd5d7) on Windows 10 22H219045.6456with a GTX 1060 6 GB (10de:1c03, driver32.0.15.6094) and in-box WARP (10.0.19041.5794). The D3D12 debug layer was enabled (X2W_D3D12_DEBUG=1).startup_queue_wait_*tests failed at device creation, because their CMake tests did not setX2W_D3D12_PERMISSIVE=1yet. With it set, which changed onlyCMakeLists.txt, they were rerun and passed 2/2.startup_queue_wait_*andstartup_stream_*.tests/docs_links_check.py: passed.Probe output, the same on both adapters:
CI runs
startup_queue_wait_warpin the Debug and Release Windows jobs; the_hardwaretest is local only.Not covered
Wait64BitValueX,Write64BitValueX) are not handled.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:06:40Z.
Review: COMMENTED
Technical peer-review at commit
b5804f60c91f65318e31ed646bd30fbc60db9ebb:Verification
git diff --check origin/main...HEAD: clean.tests/docs_links_check.py: passed (16 Markdown files, 299 links).tests/bidi_controls_check.py: passed (1120 tracked files).--preset dev):cmake --build --preset dev --target startup_queue_waitsucceeded (23.80s);ctest --preset dev -R '^startup_queue_wait_warp$'1/1 passed (0.64s)./O2(--preset release): build succeeded (35.58s);ctest --preset release -R '^startup_queue_wait_warp$'1/1 passed (0.64s).Code & Test Notes
src/startup_stubs/d3d12_xs_device.cpp:queue_waitattables[queue_kind][17]delegates non-fence arguments back toqueue_dynamic<17>, records the queue inwaiting_queuesunderwaiting_queues_lock, and forwards toID3D12CommandQueue::Wait.queue_dynamicchecksqueue_has_waited(self)so laterSignals on that queue complete viacomplete_when_reachedinstead of immediatefence_reached.tests/startup_queue_wait.cpp: covers both the slot-15 control (shape-dispatched immediate signal) and slot-17 GPU wait (verifyingGstays 0 andFstays 0 until CPUF->Signal(1), after whichGreaches 1).waiting_queuesstores rawWrapper*pointers without erasing on queue release; if a destroyed queue's address is later reused by a new queue wrapper,queue_has_waitedwould conservatively usecomplete_when_reachedfor its signals.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T09:05:45Z.
I pushed a small follow-up to the same branch. The wait flag now lives on the queue wrapper, so recording the wait takes no allocation or global pointer registry. A failed desktop Signal also no longer updates the visible fence value. On
f8ae5eb2, the queue-wait and stream-draw tests passed on RTX 4060 Laptop and WARP in Release (4/4). Waiting for CI on that exact head.