anv: add new gem/drm helpers
Needed for dealing with the new DRM timeline syncobj ioctls. v2: Make use of the anv_gem_get_drm_cap() parameter... (Jason) Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2901>
This commit is contained in:

committed by
Marge Bot

parent
a0c07e41e5
commit
a965ffad21
@@ -285,6 +285,17 @@ anv_gem_get_param(int fd, uint32_t param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
anv_gem_get_drm_cap(int fd, uint32_t capability)
|
||||
{
|
||||
struct drm_get_cap cap = {
|
||||
.capability = capability,
|
||||
};
|
||||
|
||||
gen_ioctl(fd, DRM_IOCTL_GET_CAP, &cap);
|
||||
return cap.value;
|
||||
}
|
||||
|
||||
bool
|
||||
anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
|
||||
{
|
||||
@@ -574,7 +585,7 @@ anv_gem_supports_syncobj_wait(int fd)
|
||||
|
||||
int
|
||||
anv_gem_syncobj_wait(struct anv_device *device,
|
||||
uint32_t *handles, uint32_t num_handles,
|
||||
const uint32_t *handles, uint32_t num_handles,
|
||||
int64_t abs_timeout_ns, bool wait_all)
|
||||
{
|
||||
struct drm_syncobj_wait args = {
|
||||
@@ -589,3 +600,59 @@ anv_gem_syncobj_wait(struct anv_device *device,
|
||||
|
||||
return gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_WAIT, &args);
|
||||
}
|
||||
|
||||
int
|
||||
anv_gem_syncobj_timeline_wait(struct anv_device *device,
|
||||
const uint32_t *handles, const uint64_t *points,
|
||||
uint32_t num_items, int64_t abs_timeout_ns,
|
||||
bool wait_all, bool wait_materialize)
|
||||
{
|
||||
assert(device->physical->has_syncobj_wait_available);
|
||||
|
||||
struct drm_syncobj_timeline_wait args = {
|
||||
.handles = (uint64_t)(uintptr_t)handles,
|
||||
.points = (uint64_t)(uintptr_t)points,
|
||||
.count_handles = num_items,
|
||||
.timeout_nsec = abs_timeout_ns,
|
||||
.flags = DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,
|
||||
};
|
||||
|
||||
if (wait_all)
|
||||
args.flags |= DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL;
|
||||
if (wait_materialize)
|
||||
args.flags |= DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE;
|
||||
|
||||
return gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT, &args);
|
||||
}
|
||||
|
||||
int
|
||||
anv_gem_syncobj_timeline_signal(struct anv_device *device,
|
||||
const uint32_t *handles, const uint64_t *points,
|
||||
uint32_t num_items)
|
||||
{
|
||||
assert(device->physical->has_syncobj_wait_available);
|
||||
|
||||
struct drm_syncobj_timeline_array args = {
|
||||
.handles = (uint64_t)(uintptr_t)handles,
|
||||
.points = (uint64_t)(uintptr_t)points,
|
||||
.count_handles = num_items,
|
||||
};
|
||||
|
||||
return gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL, &args);
|
||||
}
|
||||
|
||||
int
|
||||
anv_gem_syncobj_timeline_query(struct anv_device *device,
|
||||
const uint32_t *handles, uint64_t *points,
|
||||
uint32_t num_items)
|
||||
{
|
||||
assert(device->physical->has_syncobj_wait_available);
|
||||
|
||||
struct drm_syncobj_timeline_array args = {
|
||||
.handles = (uint64_t)(uintptr_t)handles,
|
||||
.points = (uint64_t)(uintptr_t)points,
|
||||
.count_handles = num_items,
|
||||
};
|
||||
|
||||
return gen_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_QUERY, &args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user