[PATCH] winevulkan: Don't hardcode performance frequency.
Paul Gofman
pgofman at codeweavers.com
Mon Apr 19 07:35:08 CDT 2021
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
This only real problem that the hardcoded value currently causes is broken
convert_monotonic_timestamp in Proton Experimental where performance
frequency is currently different. While this is not an upstream issue and we may
even want to change that in Proton it doesn't seem right for winevulkan
to depend on this implementation detail.
dlls/winevulkan/vulkan.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c
index 1070ccec115..f793b907dad 100644
--- a/dlls/winevulkan/vulkan.c
+++ b/dlls/winevulkan/vulkan.c
@@ -1355,7 +1355,6 @@ VkResult WINAPI unix_vkGetPhysicalDeviceImageFormatProperties2KHR(VkPhysicalDevi
/* From ntdll/unix/sync.c */
#define NANOSECONDS_IN_A_SECOND 1000000000
-#define TICKSPERSEC 10000000
static inline VkTimeDomainEXT get_performance_counter_time_domain(void)
{
@@ -1382,7 +1381,17 @@ static VkTimeDomainEXT map_to_host_time_domain(VkTimeDomainEXT domain)
static inline uint64_t convert_monotonic_timestamp(uint64_t value)
{
- return value / (NANOSECONDS_IN_A_SECOND / TICKSPERSEC);
+ static LARGE_INTEGER freq;
+
+ if (!freq.QuadPart)
+ {
+ LARGE_INTEGER temp;
+
+ RtlQueryPerformanceFrequency(&temp);
+ InterlockedCompareExchange64(&freq.QuadPart, temp.QuadPart, 0);
+ }
+
+ return value * freq.QuadPart / NANOSECONDS_IN_A_SECOND;
}
static inline uint64_t convert_timestamp(VkTimeDomainEXT host_domain, VkTimeDomainEXT target_domain, uint64_t value)
--
2.30.2
More information about the wine-devel
mailing list