Repository navigation
Runtime: validate Vulkan clock calibration against Win32 QPC - #1278
Conversation
whattheflop
left a comment
There was a problem hiding this comment.
AI-assisted independent native Windows verification of 158e3e94557f0843f2e8b16ecb113dec91251036 and its direct parent e7584c5207e44ed51472e6aa05c781f39ea975f6.
Windows 11 Pro x64 (build 26200), CMake 4.4.4, Ninja 1.13.2, MSVC 19.38.33145, Windows SDK 10.0.26100, uv-managed CPython 3.12.13. I built only d3d12_fence_timing_test in RelWithDebInfo and ran ctest -R '^d3d12_fence_timing$' --no-tests=error -V once per revision and GPU. I pinned one native ICD per run with VK_DRIVER_FILES and pointed VK_IMPLICIT_LAYER_PATH to an empty directory. The loader showed Khronos validation (SDK 1.4.363.0) on both Vulkan instances in each run. No validation errors were reported. No game files were used.
Stock runs (4/4 passed, zero skips). Cells show GPU / CPU interval in seconds and the absolute difference printed by the test.
| GPU and Windows driver | Revision | Explicit submitted fallback | Standalone queue |
|---|---|---|---|
| RTX 3080 (32.0.16.1664) | Parent | 0.050410 / 0.050729 (318.2 µs) | 0.050158 / 0.050160 (1.8 µs) |
| RTX 3080 (32.0.16.1664) | PR head | 0.050941 / 0.051006 (65.5 µs) | 0.050300 / 0.050302 (1.9 µs) |
| AMD Radeon(TM) Graphics (32.0.21030.2001) | Parent | 0.052603 / 0.052216 (387.0 µs) | 0.053554 / 0.053551 (3.0 µs) |
| AMD Radeon(TM) Graphics (32.0.21030.2001) | PR head | 0.060177 / 0.059832 (344.9 µs) | 0.051169 / 0.051167 (2.6 µs) |
Both drivers advertised calibrated timestamps and both standalone queues had the calibrated function available. The stock head passed the Win32 QPC bracket assertions for both calls on each queue (the parent asserts the first call only). The stock queue label reports capability; the choice to return a calibrated sample is made per call.
Separate diagnostic runs (2/2 passed). In a disposable build of the head, I logged the Vulkan result and the QPC bracket decision after the inner QPC readings, plus entry to the submitted fallback. Each GPU returned VK_SUCCESS and accepted both standalone samples (4/4 total). Each explicit fallback queue took the submitted-query path twice with the calibrated function absent (4/4 total). The instrumented samples came from the ordinary test inputs. The out-of-range Wine case did not occur on these Windows runs.
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): pass. |
|
Post-merge hardware verification from a run on PR head
The run used synthetic inputs with Vulkan validation layers disabled. |
|
Tested 158e3e9 on Windows 11 (native, MSVC 17.14, Vulkan SDK 1.4.363): pass
Review: looks correct. Two nits: under Wine every call now pays the submitted-query round trip because the mismatch isn't latched, so disabling the calibrated path after the first out-of-range sample (with a one-time log) would avoid that; and uses_calibrated_timestamps() stays true in that case, so the test's "used by the queue" line is misleading under Wine. |
Claimed in the coordination issue as: Wine clock calibration follow-up in #1218.
What and why
d3d12_fence_timingfails under Wine whenvkGetCalibratedTimestampsKHRsucceeds but returns a CPU timestamp outside the Win32QueryPerformanceCounter(QPC) interval around the call. On this Linux setup, Wine 11.22 maps Vulkan's QPC domain toCLOCK_MONOTONIC_RAWand converts the units to 100 ns ticks, while Wine's Win32 QPC usesCLOCK_BOOTTIME. A standalone Vulkan probe measured an offset of about 85 ms on this host.Check the Vulkan CPU timestamp against QPC before accepting the calibrated pair. If it falls outside the interval, use the existing submitted GPU timestamp query to obtain a fresh GPU/CPU pair. The fast path still serves valid calibrated samples. The test now checks the QPC interval around both calls. This follows up on the merged D3D-30 implementation in #423.
Tested
CachyOS x86_64 (kernel
7.3.4-1-cachyos-bore), Wine 11.22, AMD Radeon RX 7700 XT (RADV NAVI32, Mesa26.3.1-arch3.5), clang-cl 23.1.5, xwin 0.10.0, Windows SDK10.0.26100. No game files were used.e7584c52before <= cpu0 && cpu0 <= afterwith calibrated timestamps available.158e3e94To reproduce, run the commands below from the repository root on the base and on this branch, using a separate build directory for each. This assumes xwin, clang-cl/lld-link, Ninja, Wine, and Vulkan headers are installed.
AI-assisted (Codex).
Checklist
docs/design.md, with how it was confirmed. (N/A, runtime change.)