Module: Mesa Branch: main Commit: 01aafa14d4f6c9dfd4e74d033dcd7c34a1a59b33 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=01aafa14d4f6c9dfd4e74d033dcd7c34a1a59b33
Author: José Roberto de Souza <jose.so...@intel.com> Date: Wed Aug 9 10:06:28 2023 -0700 anv: Reduce ifdefs in anv_GetCalibratedTimestampsEXT() 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 <jose.so...@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24591> --- 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);