mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 11:08:03 +02:00
vulkan: add vk_device_get_timestamp
vk_device_get_timestamp returns the current timestamp for the specified time domain. device can be NULL unless the domain is VK_TIME_DOMAIN_DEVICE_KHR. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32689>
This commit is contained in:
parent
c6bcf88949
commit
3bc7564bb0
2 changed files with 52 additions and 0 deletions
|
|
@ -35,6 +35,7 @@
|
||||||
#include "util/hash_table.h"
|
#include "util/hash_table.h"
|
||||||
#include "util/perf/cpu_trace.h"
|
#include "util/perf/cpu_trace.h"
|
||||||
#include "util/ralloc.h"
|
#include "util/ralloc.h"
|
||||||
|
#include "util/timespec.h"
|
||||||
|
|
||||||
static enum vk_device_timeline_mode
|
static enum vk_device_timeline_mode
|
||||||
get_timeline_mode(struct vk_physical_device *physical_device)
|
get_timeline_mode(struct vk_physical_device *physical_device)
|
||||||
|
|
@ -555,6 +556,50 @@ vk_common_DeviceWaitIdle(VkDevice _device)
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
vk_device_get_timestamp(struct vk_device *device, VkTimeDomainKHR domain,
|
||||||
|
uint64_t *timestamp)
|
||||||
|
{
|
||||||
|
if (domain == VK_TIME_DOMAIN_DEVICE_KHR) {
|
||||||
|
assert(device && device->get_timestamp);
|
||||||
|
return device->get_timestamp(device, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* device is not used for host time domains */
|
||||||
|
#ifndef _WIN32
|
||||||
|
clockid_t clockid;
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
switch (domain) {
|
||||||
|
case VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR:
|
||||||
|
clockid = CLOCK_MONOTONIC;
|
||||||
|
break;
|
||||||
|
case VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR:
|
||||||
|
/* The "RAW" clocks on Linux are called "FAST" on FreeBSD */
|
||||||
|
#if defined(CLOCK_MONOTONIC_RAW)
|
||||||
|
clockid = CLOCK_MONOTONIC_RAW;
|
||||||
|
break;
|
||||||
|
#elif defined(CLOCK_MONOTONIC_FAST)
|
||||||
|
clockid = CLOCK_MONOTONIC_FAST;
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
FALLTHROUGH;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clock_gettime(clockid, &ts) < 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
*timestamp = (uint64_t)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
|
||||||
|
return VK_SUCCESS;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
return VK_ERROR_FEATURE_NOT_PRESENT;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,9 @@ struct vk_device {
|
||||||
*/
|
*/
|
||||||
VkResult (*check_status)(struct vk_device *device);
|
VkResult (*check_status)(struct vk_device *device);
|
||||||
|
|
||||||
|
/* Get the device timestamp in the VK_TIME_DOMAIN_DEVICE_KHR domain */
|
||||||
|
VkResult (*get_timestamp)(struct vk_device *device, uint64_t *timestamp);
|
||||||
|
|
||||||
/** Creates a vk_sync that wraps a memory object
|
/** Creates a vk_sync that wraps a memory object
|
||||||
*
|
*
|
||||||
* This is always a one-shot object so it need not track any additional
|
* This is always a one-shot object so it need not track any additional
|
||||||
|
|
@ -412,6 +415,10 @@ vk_device_check_status(struct vk_device *device)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
vk_device_get_timestamp(struct vk_device *device, VkTimeDomainKHR domain,
|
||||||
|
uint64_t *timestamp);
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue