From 01aafa14d4f6c9dfd4e74d033dcd7c34a1a59b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Wed, 9 Aug 2023 10:06:28 -0700 Subject: [PATCH] anv: Reduce ifdefs in anv_GetCalibratedTimestampsEXT() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add anv_get_default_cpu_clock_id() to return the default cpu clock id to be used in the begin and end time captures of anv_GetCalibratedTimestampsEXT(). Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_device.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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);