[PATCH v4 0/1] MR9859: Draft: winevulkan: Use correct time domain for calibrated timestamps
I am not sure how to address this fully, but the following patch should at least make it accurate before the machine suspends. -- v4: winevulkan: Use correct time domain for calibrated timestamps https://gitlab.winehq.org/wine/wine/-/merge_requests/9859
From: Etaash Mathamsetty <etaash.mathamsetty@gmail.com> --- dlls/winevulkan/vulkan.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 0f49148ee15..498a6a42c7b 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -585,11 +585,7 @@ void wine_vkGetPhysicalDeviceExternalFencePropertiesKHR(VkPhysicalDevice client_ static inline VkTimeDomainEXT get_performance_counter_time_domain(void) { #if !defined(__APPLE__) && defined(HAVE_CLOCK_GETTIME) -# ifdef CLOCK_MONOTONIC_RAW - return VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT; -# else return VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT; -# endif #else FIXME("No mapping for VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT on this platform.\n"); return VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT; @@ -616,7 +612,7 @@ static inline uint64_t convert_timestamp(VkTimeDomainEXT host_domain, VkTimeDoma return value; /* Convert between MONOTONIC time in ns -> QueryPerformanceCounter */ - if ((host_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT || host_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT) + if (host_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT && target_domain == VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT) return convert_monotonic_timestamp(value); @@ -663,7 +659,7 @@ static VkResult wine_vk_get_time_domains(struct vulkan_physical_device *physical VkTimeDomainEXT *time_domains, VkResult (*get_domains)(VkPhysicalDevice, uint32_t *, VkTimeDomainEXT *)) { - BOOL supports_device = FALSE, supports_monotonic = FALSE, supports_monotonic_raw = FALSE; + BOOL supports_device = FALSE, supports_monotonic = FALSE; const VkTimeDomainEXT performance_counter_domain = get_performance_counter_time_domain(); VkTimeDomainEXT *host_time_domains; uint32_t host_time_domain_count; @@ -693,8 +689,6 @@ static VkResult wine_vk_get_time_domains(struct vulkan_physical_device *physical supports_device = TRUE; else if (host_time_domains[i] == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT) supports_monotonic = TRUE; - else if (host_time_domains[i] == VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT) - supports_monotonic_raw = TRUE; else FIXME("Unknown time domain %d\n", host_time_domains[i]); } @@ -704,9 +698,7 @@ static VkResult wine_vk_get_time_domains(struct vulkan_physical_device *physical out_time_domain_count = 0; /* Map our monotonic times -> QPC */ - if (supports_monotonic_raw && performance_counter_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT) - out_time_domains[out_time_domain_count++] = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT; - else if (supports_monotonic && performance_counter_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT) + if (supports_monotonic && performance_counter_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT) out_time_domains[out_time_domain_count++] = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT; else FIXME("VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT not supported on this platform.\n"); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9859
On Wed Jan 7 22:53:47 2026 +0000, Rémi Bernon wrote:
Is this because we don't use CLOCK_MONOTONIC_RAW in ntdll for QPC when we need to make sure both QPC / vulkan clock source match? Yes, similar fix needs to be applied to vkd3d as well.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9859#note_126521
On Wed Jan 7 22:55:25 2026 +0000, Rémi Bernon wrote:
If that's the case, isn't this actually a regression from https://gitlab.winehq.org/wine/wine/-/merge_requests/8916? If we cannot have a BOOTTIME clock source here, IMO we should revert that MR instead. I have an approach that should alleviate most of the issues. Essentially it is QueryPerformanceCounter and clock_gettime(monotonic) and then computing the difference. This would be inaccurate on a stale timestamp before suspend, but Paul Gofman said that this isn't too much of an issue (unless proven otherwise in some application).
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9859#note_126523
On Wed Jan 7 22:55:39 2026 +0000, Etaash Mathamsetty wrote:
I have an approach that should alleviate most of the issues. Essentially it is QueryPerformanceCounter and clock_gettime(monotonic) and then computing the difference. This would be inaccurate on a stale timestamp before suspend, but Paul Gofman said that this isn't too much of an issue (unless proven otherwise in some application). Meanwhile, if we can reconsider using BOOTTIME for QPC, I'd also think (as Rémi suggested) that would be a cleaner solution.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9859#note_126524
participants (3)
-
Etaash Mathamsetty -
Etaash Mathamsetty (@etaash.mathamsetty) -
Paul Gofman (@gofman)