mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 23:40:10 +01:00
anv/gem: Add support for syncobj wait and reset
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
parent
144487ebb8
commit
d21c151091
3 changed files with 87 additions and 0 deletions
|
|
@ -488,3 +488,65 @@ anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
|
|||
|
||||
return args.handle;
|
||||
}
|
||||
|
||||
void
|
||||
anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
|
||||
{
|
||||
struct drm_syncobj_array args = {
|
||||
.handles = (uint64_t)(uintptr_t)&handle,
|
||||
.count_handles = 1,
|
||||
};
|
||||
|
||||
anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_RESET, &args);
|
||||
}
|
||||
|
||||
bool
|
||||
anv_gem_supports_syncobj_wait(int fd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
struct drm_syncobj_create create = {
|
||||
.flags = 0,
|
||||
};
|
||||
ret = anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
|
||||
if (ret)
|
||||
return false;
|
||||
|
||||
uint32_t syncobj = create.handle;
|
||||
|
||||
struct drm_syncobj_wait wait = {
|
||||
.handles = (uint64_t)(uintptr_t)&create,
|
||||
.count_handles = 1,
|
||||
.timeout_nsec = 0,
|
||||
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
|
||||
};
|
||||
ret = anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &wait);
|
||||
|
||||
struct drm_syncobj_destroy destroy = {
|
||||
.handle = syncobj,
|
||||
};
|
||||
anv_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
|
||||
|
||||
/* If it timed out, then we have the ioctl and it supports the
|
||||
* DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT flag.
|
||||
*/
|
||||
return ret == -1 && errno == ETIME;
|
||||
}
|
||||
|
||||
int
|
||||
anv_gem_syncobj_wait(struct anv_device *device,
|
||||
uint32_t *handles, uint32_t num_handles,
|
||||
int64_t abs_timeout_ns, bool wait_all)
|
||||
{
|
||||
struct drm_syncobj_wait args = {
|
||||
.handles = (uint64_t)(uintptr_t)handles,
|
||||
.count_handles = num_handles,
|
||||
.timeout_nsec = abs_timeout_ns,
|
||||
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
|
||||
};
|
||||
|
||||
if (wait_all)
|
||||
args.flags |= DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL;
|
||||
|
||||
return anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,3 +210,23 @@ anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
|
|||
{
|
||||
unreachable("Unused");
|
||||
}
|
||||
|
||||
void
|
||||
anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
|
||||
{
|
||||
unreachable("Unused");
|
||||
}
|
||||
|
||||
bool
|
||||
anv_gem_supports_syncobj_wait(int fd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
anv_gem_syncobj_wait(struct anv_device *device,
|
||||
uint32_t *handles, uint32_t num_handles,
|
||||
int64_t abs_timeout_ns, bool wait_all)
|
||||
{
|
||||
unreachable("Unused");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -809,6 +809,11 @@ uint32_t anv_gem_syncobj_create(struct anv_device *device, uint32_t flags);
|
|||
void anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle);
|
||||
int anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle);
|
||||
uint32_t anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd);
|
||||
void anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle);
|
||||
bool anv_gem_supports_syncobj_wait(int fd);
|
||||
int anv_gem_syncobj_wait(struct anv_device *device,
|
||||
uint32_t *handles, uint32_t num_handles,
|
||||
int64_t abs_timeout_ns, bool wait_all);
|
||||
|
||||
VkResult anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue