From 1ebfa00bc5eedcddccc18c309d04681adbb231b9 Mon Sep 17 00:00:00 2001 From: Igor Torrente Date: Fri, 26 Aug 2022 11:22:55 -0300 Subject: [PATCH] venus: Fix dEQP-VK.pipeline.timestamp.calibrated.host_domain_test failure The current implementation is getting its clock value from the host and this value is not guaranteed to be the same as the VM guest. This commit implements the CLOCK_MONOTONIC[_RAW] natively. Signed-off-by: Igor Torrente Part-of: --- src/virtio/ci/venus-fails.txt | 1 - src/virtio/vulkan/vn_device.c | 51 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/virtio/ci/venus-fails.txt b/src/virtio/ci/venus-fails.txt index 543fcb6..8916f9e 100644 --- a/src/virtio/ci/venus-fails.txt +++ b/src/virtio/ci/venus-fails.txt @@ -13,4 +13,3 @@ dEQP-VK.pipeline.extended_dynamic_state.before_draw.enable_raster,Fail dEQP-VK.pipeline.extended_dynamic_state.between_pipelines.enable_raster,Fail dEQP-VK.pipeline.extended_dynamic_state.cmd_buffer_start.enable_raster,Fail dEQP-VK.pipeline.extended_dynamic_state.two_draws_dynamic.enable_raster,Fail -dEQP-VK.pipeline.timestamp.calibrated.host_domain_test,Fail \ No newline at end of file diff --git a/src/virtio/vulkan/vn_device.c b/src/virtio/vulkan/vn_device.c index 9f51f91..2cdc45e 100644 --- a/src/virtio/vulkan/vn_device.c +++ b/src/virtio/vulkan/vn_device.c @@ -547,8 +547,53 @@ vn_GetCalibratedTimestampsEXT( uint64_t *pMaxDeviation) { struct vn_device *dev = vn_device_from_handle(device); + uint64_t begin, end, max_clock_period = 0; + VkResult ret; + int domain; - return vn_call_vkGetCalibratedTimestampsEXT( - dev->instance, device, timestampCount, pTimestampInfos, pTimestamps, - pMaxDeviation); +#ifdef CLOCK_MONOTONIC_RAW + begin = vk_clock_gettime(CLOCK_MONOTONIC_RAW); +#else + begin = vk_clock_gettime(CLOCK_MONOTONIC); +#endif + + for (domain = 0; domain < timestampCount; domain++) { + switch (pTimestampInfos[domain].timeDomain) { + case VK_TIME_DOMAIN_DEVICE_EXT: { + uint64_t device_max_deviation = 0; + + ret = vn_call_vkGetCalibratedTimestampsEXT( + dev->instance, device, 1, &pTimestampInfos[domain], + &pTimestamps[domain], &device_max_deviation); + + if (ret != VK_SUCCESS) + return vn_error(dev->instance, ret); + + max_clock_period = MAX2(max_clock_period, device_max_deviation); + break; + } + case VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT: + pTimestamps[domain] = vk_clock_gettime(CLOCK_MONOTONIC); + max_clock_period = MAX2(max_clock_period, 1); + break; +#ifdef CLOCK_MONOTONIC_RAW + case VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT: + pTimestamps[domain] = begin; + break; +#endif + default: + pTimestamps[domain] = 0; + break; + } + } + +#ifdef CLOCK_MONOTONIC_RAW + end = vk_clock_gettime(CLOCK_MONOTONIC_RAW); +#else + end = vk_clock_gettime(CLOCK_MONOTONIC); +#endif + + *pMaxDeviation = vk_time_max_deviation(begin, end, max_clock_period); + + return VK_SUCCESS; } -- 2.7.4