From 1f333ac9fa9b6d168562a5c8a56008c0124c7918 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 17 Dec 2024 11:49:10 -0800 Subject: [PATCH] hk: remove calibrated timestamp support We don't advertise KHR_calibrated_timestamps yet. When we do, we can use the common implementation. Part-of: --- src/asahi/vulkan/hk_device.c | 63 +++++---------------------- src/asahi/vulkan/hk_physical_device.c | 28 +----------- 2 files changed, 12 insertions(+), 79 deletions(-) diff --git a/src/asahi/vulkan/hk_device.c b/src/asahi/vulkan/hk_device.c index 5e7e4d824ea..3c199046685 100644 --- a/src/asahi/vulkan/hk_device.c +++ b/src/asahi/vulkan/hk_device.c @@ -287,6 +287,15 @@ hk_check_status(struct vk_device *device) dev->dev.libagx->printf_info_count); } +static VkResult +hk_get_timestamp(struct vk_device *device, uint64_t *timestamp) +{ + struct hk_device *dev = container_of(device, struct hk_device, vk); + unreachable("todo"); + // *timestamp = agx_get_gpu_timestamp(dev); + return VK_SUCCESS; +} + /* * To implement nullDescriptor, the descriptor set code will reference * preuploaded null descriptors at fixed offsets in the image heap. Here we @@ -399,6 +408,7 @@ hk_CreateDevice(VkPhysicalDevice physicalDevice, vk_device_set_drm_fd(&dev->vk, dev->dev.fd); dev->vk.command_buffer_ops = &hk_cmd_buffer_ops; dev->vk.check_status = hk_check_status; + dev->vk.get_timestamp = hk_get_timestamp; result = hk_descriptor_table_init(dev, &dev->images, AGX_TEXTURE_LENGTH, 1024, 1024 * 1024); @@ -531,56 +541,3 @@ hk_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator) agx_close_device(&dev->dev); vk_free(&dev->vk.alloc, dev); } - -VKAPI_ATTR VkResult VKAPI_CALL -hk_GetCalibratedTimestampsKHR( - VkDevice _device, uint32_t timestampCount, - const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps, - uint64_t *pMaxDeviation) -{ - // VK_FROM_HANDLE(hk_device, dev, _device); - // struct hk_physical_device *pdev = hk_device_physical(dev); - uint64_t max_clock_period = 0; - uint64_t begin, end; - int d; - -#ifdef CLOCK_MONOTONIC_RAW - begin = vk_clock_gettime(CLOCK_MONOTONIC_RAW); -#else - begin = vk_clock_gettime(CLOCK_MONOTONIC); -#endif - - for (d = 0; d < timestampCount; d++) { - switch (pTimestampInfos[d].timeDomain) { - case VK_TIME_DOMAIN_DEVICE_KHR: - unreachable("todo"); - // pTimestamps[d] = agx_get_gpu_timestamp(&pdev->dev); - max_clock_period = MAX2( - max_clock_period, 1); /* FIXME: Is timestamp period actually 1? */ - break; - case VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR: - pTimestamps[d] = 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_KHR: - pTimestamps[d] = begin; - break; -#endif - default: - pTimestamps[d] = 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; -} diff --git a/src/asahi/vulkan/hk_physical_device.c b/src/asahi/vulkan/hk_physical_device.c index d0a9cafca0a..8dcbd15c2b7 100644 --- a/src/asahi/vulkan/hk_physical_device.c +++ b/src/asahi/vulkan/hk_physical_device.c @@ -719,7 +719,8 @@ hk_get_device_properties(const struct agx_device *dev, .storageImageSampleCounts = sample_counts, .maxSampleMaskWords = 1, .timestampComputeAndGraphics = agx_supports_timestamps(dev), - .timestampPeriod = 1, + /* FIXME: Is timestamp period actually 1? */ + .timestampPeriod = 1.0f, .maxClipDistances = 8, .maxCullDistances = 8, .maxCombinedClipAndCullDistances = 8, @@ -1404,31 +1405,6 @@ hk_GetPhysicalDeviceQueueFamilyProperties2( } } -static const VkTimeDomainKHR hk_time_domains[] = { - VK_TIME_DOMAIN_DEVICE_KHR, - VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR, -#ifdef CLOCK_MONOTONIC_RAW - VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR, -#endif -}; - -VKAPI_ATTR VkResult VKAPI_CALL -hk_GetPhysicalDeviceCalibrateableTimeDomainsKHR(VkPhysicalDevice physicalDevice, - uint32_t *pTimeDomainCount, - VkTimeDomainKHR *pTimeDomains) -{ - VK_OUTARRAY_MAKE_TYPED(VkTimeDomainKHR, out, pTimeDomains, pTimeDomainCount); - - for (int d = 0; d < ARRAY_SIZE(hk_time_domains); d++) { - vk_outarray_append_typed(VkTimeDomainKHR, &out, i) - { - *i = hk_time_domains[d]; - } - } - - return vk_outarray_status(&out); -} - VKAPI_ATTR void VKAPI_CALL hk_GetPhysicalDeviceMultisamplePropertiesEXT( VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples,