#include "util/macros.h"
#include "vk_util.h"
+#include <time.h>
#include <unistd.h>
#include <xf86drm.h>
return final_result;
}
+
+uint64_t
+wsi_common_get_current_time(void)
+{
+ struct timespec current;
+ clock_gettime(CLOCK_MONOTONIC, ¤t);
+ return current.tv_nsec + current.tv_sec * 1000000000ull;
+}
(double) MAX2(wsi->vscan, 1));
}
-static uint64_t wsi_get_current_monotonic(void)
-{
- struct timespec tv;
-
- clock_gettime(CLOCK_MONOTONIC, &tv);
- return tv.tv_nsec + tv.tv_sec*1000000000ull;
-}
-
static uint64_t wsi_rel_to_abs_time(uint64_t rel_time)
{
- uint64_t current_time = wsi_get_current_monotonic();
+ uint64_t current_time = wsi_common_get_current_time();
/* check for overflow */
if (rel_time > UINT64_MAX - current_time)
wsi_display_debug("%9lu wait fence %lu %ld\n",
pthread_self(), fence->sequence,
- (int64_t) (timeout - wsi_get_current_monotonic()));
- wsi_display_debug_code(uint64_t start_ns = wsi_get_current_monotonic());
+ (int64_t) (timeout - wsi_common_get_current_time()));
+ wsi_display_debug_code(uint64_t start_ns = wsi_common_get_current_time());
pthread_mutex_lock(&wsi->wait_mutex);
VkResult result;
pthread_mutex_unlock(&wsi->wait_mutex);
wsi_display_debug("%9lu fence wait %f ms\n",
pthread_self(),
- ((int64_t) (wsi_get_current_monotonic() - start_ns)) /
+ ((int64_t) (wsi_common_get_current_time() - start_ns)) /
1.0e6);
return result;
}
}
-static uint64_t wsi_get_current_time(void)
-{
- uint64_t current_time;
- struct timespec tv;
-
- clock_gettime(CLOCK_MONOTONIC, &tv);
- current_time = tv.tv_nsec + tv.tv_sec*1000000000ull;
- return current_time;
-}
-
static uint64_t wsi_get_absolute_timeout(uint64_t timeout)
{
- uint64_t current_time = wsi_get_current_time();
+ uint64_t current_time = wsi_common_get_current_time();
timeout = MIN2(UINT64_MAX - current_time, timeout);
/* If a non-special event happens, the fd will still
* poll. So recalculate the timeout now just in case.
*/
- uint64_t current_time = wsi_get_current_time();
+ uint64_t current_time = wsi_common_get_current_time();
if (atimeout > current_time)
timeout = atimeout - current_time;
else