d3d12: allow queue submissions during fallback clock calibration #1720
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1720"
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 ubiquitarianism/leonida. Originally posted by PyZikYG on 2026-11-25T09:34:04Z.
Claimed as D3D-CLOCK-CALIBRATION-SUBMIT.
Summary
Fallback
GetClockCalibrationused to hold the device-wide Vulkan submission lock across queue-idle waits. A slow calibration could block submissions from every D3D12 queue on the device.Drain prior work with an empty submission and wait for that marker and the timestamp sample on a private timeline outside the submission lock. The timestamp submission remains bracketed by QPC reads. If a host wait fails, the next call retires the outstanding sample before reusing the command buffer.
Verification
Checked clock pairing, queue submissions while a calibration wait is paused, and retry after an injected host wait failure. Also ran the fence event coverage.
AI-assisted: yes.
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-25T09:45:26Z.
Review: COMMENTED
Review (read-only, not run). Taking the waits out of the submit lock is the right fix, and the teardown and retry handling look correct. One accuracy point:
The calibration bracket is no longer exclusive. The old code held
submit_mutex()fromvkQueueWaitIdlethrough the timestamp submit and its wait, so the queue was idle and the GPU stamp ran right afterbefore. Now:beforeis read and the stamp submitted under the lock;Between 1 and 2, another D3D12 queue that maps to the same
VkQueuecan submit work. TheTOP_OF_PIPEtimestamp then runs only after that work starts, andbeforeis no longer close to it. The midpoint(before + after) / 2can then be off by up to the duration of the interleaved work, not the tens of microseconds the doc text promises. The test does not see this because nothing else is submitted between the drain and the stamp.Cheap options:
after - beforeexceeds a bound (for example retry up to N times and keep the narrowest bracket), and say indocs/d3d12_vulkan.mdthat the fallback's error is bounded by that;submit_mutex()only from the drain wait's completion to the stamp submit. That is a short window and no GPU wait.Minor:
calibration_driver::fail_wait_number = 2depends on the exact number ofvkWaitSemaphorescalls per calibration (the drain, then the stamp). A comment saying so would help the next person who changes the sequence.AI-assisted review (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T11:46:11Z.
Tested
c6817c3d5merged ontomainbcaa13dad(clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14, VS 2022 RelWithDebInfo + Ninja.d3d12_fence_timingpasses. Fullctest -j 6: 409 of 409 passed, same asmain.run_gpu_tests.py: 209/263, identical tomain.AI-assisted testing (non-developer tester).
Imported from ubiquitarianism/leonida. Originally posted by adrianmjim on 2026-11-25T12:00:49Z.
Tested
c6817c3d5applied ontomain42537e7b6on AMD: Radeon RX 7900 XT, driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, VS 2022 RelWithDebInfo. This driver has calibrated timestamps, so the test exercises both the calibration-capable queue and the fallback. No game files.d3d12_fence_timing: passes 30 of 30 with--repeat until-fail:30, and 5 of 5 withLEONIDA_VK_VALIDATION=1(no messages).main42537e7b6So at idle the fallback is in the same range as before on this card. The run-to-run spread is larger than any difference between the two. I didn't measure it under concurrent submissions. That is where waiting outside the submission lock could widen the gap: work another thread queues on the same VkQueue after the marker drains runs ahead of the timestamp write.
ctest -j 6: 398 of 402 pass or skip. The failures ared3d12_texture_tiles,d3d12_clearandd3d12_geometry_views, the same as onmain.d3d12_indirect_rtfailed once under-j 6and passes 3 of 3 alone; it has done that on other trees here too.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T09:52:53Z.
Red/green: the PR's test fails on main and passes with this PR (checked by OreoFR).
Runtime batch of 20 PRs tested by OreoFR (full build, ctest without the game, Python suite, translator): same results as main
09c153948, RTX 4070 Laptop / Windows 11.AI-assisted (Claude Code, Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:53:32Z.
Verified by OreoFR
09c153948+ PR headc6817c3d5; integration package 1 of 6 (20 PRs, merged without conflict)AI-assisted (Claude Code, Claude Opus 5.5).