v3dv: Use util/os_time helpers
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15704>
This commit is contained in:
parent
8bd7bd9577
commit
e5a0e2122f
|
@ -23,8 +23,6 @@
|
|||
#ifndef V3DV_LIMITS_H
|
||||
#define V3DV_LIMITS_H
|
||||
|
||||
#define NSEC_PER_SEC 1000000000ull
|
||||
|
||||
/* From vulkan spec "If the multiple viewports feature is not enabled,
|
||||
* scissorCount must be 1", ditto for viewportCount. For now we don't support
|
||||
* that feature.
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "drm-uapi/v3d_drm.h"
|
||||
|
||||
#include "broadcom/clif/clif_dump.h"
|
||||
#include "util/os_time.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
@ -67,25 +68,6 @@ v3dv_clif_dump(struct v3dv_device *device,
|
|||
clif_dump_destroy(clif);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
gettime_ns()
|
||||
{
|
||||
struct timespec current;
|
||||
clock_gettime(CLOCK_MONOTONIC, ¤t);
|
||||
return (uint64_t)current.tv_sec * NSEC_PER_SEC + current.tv_nsec;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
get_absolute_timeout(uint64_t timeout)
|
||||
{
|
||||
uint64_t current_time = gettime_ns();
|
||||
uint64_t max_timeout = (uint64_t) INT64_MAX - current_time;
|
||||
|
||||
timeout = MIN2(max_timeout, timeout);
|
||||
|
||||
return (current_time + timeout);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
queue_submit_job(struct v3dv_queue *queue,
|
||||
struct v3dv_job *job,
|
||||
|
@ -2056,7 +2038,7 @@ v3dv_WaitForFences(VkDevice _device,
|
|||
if (vk_device_is_lost(&device->vk))
|
||||
return VK_ERROR_DEVICE_LOST;
|
||||
|
||||
const uint64_t abs_timeout = get_absolute_timeout(timeout);
|
||||
const uint64_t abs_timeout = os_time_get_absolute_timeout(timeout);
|
||||
|
||||
uint32_t *syncobjs = vk_alloc(&device->vk.alloc,
|
||||
sizeof(*syncobjs) * fenceCount, 8,
|
||||
|
@ -2077,7 +2059,7 @@ v3dv_WaitForFences(VkDevice _device,
|
|||
do {
|
||||
ret = drmSyncobjWait(device->pdevice->render_fd, syncobjs, fenceCount,
|
||||
timeout, flags, NULL);
|
||||
} while (ret == -ETIME && gettime_ns() < abs_timeout);
|
||||
} while (ret == -ETIME && os_time_get_nano() < abs_timeout);
|
||||
|
||||
vk_free(&device->vk.alloc, syncobjs);
|
||||
|
||||
|
|
Loading…
Reference in New Issue