mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 13:48:06 +02:00
vulkan/runtime: Implement VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR
This change adds win32 VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR support to vk_device_get_timestamp. Meanwhile, vk_clock_gettime is left untouched preparing for deprecation (anv is the only user). The latter also only has the host clock part and doesn't handle error cases in a robust manner. v2 (zzyiwei): - vk_device_get_timestamp updates - use DETECT_OS_WINDOWS - add commit messages Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Yonggang Luo <luoyonggang@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40582>
This commit is contained in:
parent
b5e023777c
commit
8982056fa8
2 changed files with 13 additions and 2 deletions
|
|
@ -35,6 +35,7 @@
|
|||
#include "vk_sync_timeline.h"
|
||||
#include "vk_util.h"
|
||||
#include "util/compiler.h"
|
||||
#include "util/detect_os.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/hash_table.h"
|
||||
#include "util/perf/cpu_trace.h"
|
||||
|
|
@ -250,6 +251,7 @@ vk_device_init(struct vk_device *device,
|
|||
const VkTimeDomainKHR calibrate_domains[] = {
|
||||
VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR,
|
||||
VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR,
|
||||
VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR,
|
||||
};
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(calibrate_domains); i++) {
|
||||
const VkTimeDomainKHR domain = calibrate_domains[i];
|
||||
|
|
@ -810,7 +812,15 @@ vk_device_get_timestamp(struct vk_device *device, VkTimeDomainKHR domain,
|
|||
}
|
||||
|
||||
/* device is not used for host time domains */
|
||||
#ifndef _WIN32
|
||||
#if DETECT_OS_WINDOWS
|
||||
if (domain == VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR) {
|
||||
LARGE_INTEGER ts;
|
||||
if (QueryPerformanceCounter(&ts)) {
|
||||
*timestamp = ts.QuadPart;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
}
|
||||
#else /* !DETECT_OS_WINDOWS */
|
||||
clockid_t clockid;
|
||||
struct timespec ts;
|
||||
|
||||
|
|
@ -840,7 +850,7 @@ vk_device_get_timestamp(struct vk_device *device, VkTimeDomainKHR domain,
|
|||
return VK_SUCCESS;
|
||||
|
||||
fail:
|
||||
#endif /* _WIN32 */
|
||||
#endif /* DETECT_OS_WINDOWS */
|
||||
return VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ vk_common_GetPhysicalDeviceCalibrateableTimeDomainsKHR(
|
|||
const VkTimeDomainKHR host_time_domains[] = {
|
||||
VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR,
|
||||
VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR,
|
||||
VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR,
|
||||
};
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(host_time_domains); i++) {
|
||||
const VkTimeDomainKHR domain = host_time_domains[i];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue