mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
venus: adopt vk_common_GetCalibratedTimestampsKHR
Venus driver already has to query host time domains within the guest to be monotonic, so we can rely on the common impl as well and only query device domain from the renderer. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38963>
This commit is contained in:
parent
36c52644fa
commit
166923bf0e
1 changed files with 17 additions and 60 deletions
|
|
@ -434,6 +434,22 @@ vn_device_update_shader_cache_id(struct vn_device *dev)
|
|||
#endif
|
||||
}
|
||||
|
||||
static VkResult
|
||||
vn_get_timestamp(struct vk_device *device, uint64_t *timestamp)
|
||||
{
|
||||
VkDevice dev_handle = vk_device_to_handle(device);
|
||||
struct vn_device *dev = vn_device_from_handle(dev_handle);
|
||||
UNUSED uint64_t device_max_deviation;
|
||||
|
||||
const VkCalibratedTimestampInfoKHR ts_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_KHR,
|
||||
.timeDomain = VK_TIME_DOMAIN_DEVICE_KHR,
|
||||
};
|
||||
return vn_call_vkGetCalibratedTimestampsKHR(dev->primary_ring, dev_handle,
|
||||
1, &ts_info, timestamp,
|
||||
&device_max_deviation);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
vn_device_init(struct vn_device *dev,
|
||||
struct vn_physical_device *physical_dev,
|
||||
|
|
@ -447,6 +463,7 @@ vn_device_init(struct vn_device *dev,
|
|||
VkDeviceCreateInfo local_create_info;
|
||||
VkResult result;
|
||||
|
||||
dev->base.vk.get_timestamp = vn_get_timestamp;
|
||||
dev->instance = instance;
|
||||
dev->physical_device = physical_dev;
|
||||
dev->device_mask = 1;
|
||||
|
|
@ -655,63 +672,3 @@ vn_GetDeviceGroupPeerMemoryFeatures(
|
|||
dev->primary_ring, device, heapIndex, localDeviceIndex,
|
||||
remoteDeviceIndex, pPeerMemoryFeatures);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
vn_GetCalibratedTimestampsKHR(
|
||||
VkDevice device,
|
||||
uint32_t timestampCount,
|
||||
const VkCalibratedTimestampInfoKHR *pTimestampInfos,
|
||||
uint64_t *pTimestamps,
|
||||
uint64_t *pMaxDeviation)
|
||||
{
|
||||
struct vn_device *dev = vn_device_from_handle(device);
|
||||
uint64_t begin, end, max_clock_period = 0;
|
||||
VkResult ret;
|
||||
int domain;
|
||||
|
||||
#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_KHR: {
|
||||
uint64_t device_max_deviation = 0;
|
||||
|
||||
ret = vn_call_vkGetCalibratedTimestampsKHR(
|
||||
dev->primary_ring, 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_KHR:
|
||||
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_KHR:
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue