diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 085dad1cc9f..2e59bc75bd1 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -4804,6 +4804,16 @@ VkResult anv_GetPhysicalDeviceCalibrateableTimeDomainsEXT( return vk_outarray_status(&out); } +static inline clockid_t +anv_get_default_cpu_clock_id(void) +{ +#ifdef CLOCK_MONOTONIC_RAW + return CLOCK_MONOTONIC_RAW; +#else + return CLOCK_MONOTONIC; +#endif +} + VkResult anv_GetCalibratedTimestampsEXT( VkDevice _device, uint32_t timestampCount, @@ -4817,11 +4827,7 @@ VkResult anv_GetCalibratedTimestampsEXT( uint64_t begin, end; uint64_t max_clock_period = 0; -#ifdef CLOCK_MONOTONIC_RAW - begin = vk_clock_gettime(CLOCK_MONOTONIC_RAW); -#else - begin = vk_clock_gettime(CLOCK_MONOTONIC); -#endif + begin = vk_clock_gettime(anv_get_default_cpu_clock_id()); for (d = 0; d < timestampCount; d++) { switch (pTimestampInfos[d].timeDomain) { @@ -4851,11 +4857,7 @@ VkResult anv_GetCalibratedTimestampsEXT( } } -#ifdef CLOCK_MONOTONIC_RAW - end = vk_clock_gettime(CLOCK_MONOTONIC_RAW); -#else - end = vk_clock_gettime(CLOCK_MONOTONIC); -#endif + end = vk_clock_gettime(anv_get_default_cpu_clock_id()); *pMaxDeviation = vk_time_max_deviation(begin, end, max_clock_period);