radv: use common calibrated timestamp support
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32689>
This commit is contained in:
@@ -802,6 +802,14 @@ init_dispatch_tables(struct radv_device *device, struct radv_physical_device *pd
|
||||
add_entrypoints(&b, &vk_common_device_entrypoints, RADV_DISPATCH_TABLE_COUNT);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
get_timestamp(struct vk_device *_device, uint64_t *timestamp)
|
||||
{
|
||||
struct radv_device *device = container_of(_device, struct radv_device, vk);
|
||||
*timestamp = device->ws->query_value(device->ws, RADEON_TIMESTAMP);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
capture_trace(VkQueue _queue)
|
||||
{
|
||||
@@ -1147,6 +1155,7 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr
|
||||
return result;
|
||||
}
|
||||
|
||||
device->vk.get_timestamp = get_timestamp;
|
||||
device->vk.capture_trace = capture_trace;
|
||||
|
||||
device->vk.command_buffer_ops = &radv_cmd_buffer_ops;
|
||||
@@ -1744,62 +1753,6 @@ radv_GetMemoryFdPropertiesKHR(VkDevice _device, VkExternalMemoryHandleTypeFlagBi
|
||||
}
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
radv_GetCalibratedTimestampsKHR(VkDevice _device, uint32_t timestampCount,
|
||||
const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps,
|
||||
uint64_t *pMaxDeviation)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
VK_FROM_HANDLE(radv_device, device, _device);
|
||||
const struct radv_physical_device *pdev = radv_device_physical(device);
|
||||
uint32_t clock_crystal_freq = pdev->info.clock_crystal_freq;
|
||||
int d;
|
||||
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
|
||||
|
||||
for (d = 0; d < timestampCount; d++) {
|
||||
switch (pTimestampInfos[d].timeDomain) {
|
||||
case VK_TIME_DOMAIN_DEVICE_KHR:
|
||||
pTimestamps[d] = device->ws->query_value(device->ws, RADEON_TIMESTAMP);
|
||||
uint64_t device_period = DIV_ROUND_UP(1000000, clock_crystal_freq);
|
||||
max_clock_period = MAX2(max_clock_period, device_period);
|
||||
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;
|
||||
#else
|
||||
return VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
radv_device_set_pstate(struct radv_device *device, bool enable)
|
||||
{
|
||||
|
@@ -2680,31 +2680,6 @@ radv_GetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice,
|
||||
radv_get_memory_budget_properties(physicalDevice, memory_budget);
|
||||
}
|
||||
|
||||
static const VkTimeDomainKHR radv_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
|
||||
radv_GetPhysicalDeviceCalibrateableTimeDomainsKHR(VkPhysicalDevice physicalDevice, uint32_t *pTimeDomainCount,
|
||||
VkTimeDomainKHR *pTimeDomains)
|
||||
{
|
||||
int d;
|
||||
VK_OUTARRAY_MAKE_TYPED(VkTimeDomainKHR, out, pTimeDomains, pTimeDomainCount);
|
||||
|
||||
for (d = 0; d < ARRAY_SIZE(radv_time_domains); d++) {
|
||||
vk_outarray_append_typed(VkTimeDomainKHR, &out, i)
|
||||
{
|
||||
*i = radv_time_domains[d];
|
||||
}
|
||||
}
|
||||
|
||||
return vk_outarray_status(&out);
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
radv_GetPhysicalDeviceMultisamplePropertiesEXT(VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples,
|
||||
VkMultisamplePropertiesEXT *pMultisampleProperties)
|
||||
|
@@ -29,11 +29,6 @@
|
||||
#include <xf86drm.h>
|
||||
#endif
|
||||
|
||||
/* The "RAW" clocks on Linux are called "FAST" on FreeBSD */
|
||||
#if !defined(CLOCK_MONOTONIC_RAW) && defined(CLOCK_MONOTONIC_FAST)
|
||||
#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_FAST
|
||||
#endif
|
||||
|
||||
struct radv_binning_settings {
|
||||
unsigned context_states_per_bin; /* allowed range: [1, 6] */
|
||||
unsigned persistent_states_per_bin; /* allowed range: [1, 32] */
|
||||
|
@@ -761,8 +761,8 @@ radv_get_calibrated_timestamps(struct radv_device *device, uint64_t *cpu_timesta
|
||||
.timeDomain = VK_TIME_DOMAIN_DEVICE_KHR,
|
||||
}};
|
||||
|
||||
result =
|
||||
radv_GetCalibratedTimestampsKHR(radv_device_to_handle(device), 2, timestamp_infos, timestamps, &max_deviation);
|
||||
result = device->vk.dispatch_table.GetCalibratedTimestampsKHR(radv_device_to_handle(device), 2, timestamp_infos,
|
||||
timestamps, &max_deviation);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
Reference in New Issue
Block a user