[Mesa-dev] [PATCH v2 07/10] anv/gem: Add support for syncobj wait and reset
Jason Ekstrand
jason at jlekstrand.net
Thu Aug 24 23:49:34 UTC 2017
---
src/intel/vulkan/anv_gem.c | 71 ++++++++++++++++++++++++++++++++++++++++
src/intel/vulkan/anv_gem_stubs.c | 26 +++++++++++++++
src/intel/vulkan/anv_private.h | 6 ++++
3 files changed, 103 insertions(+)
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 57a8b79..ed94a7e 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -488,3 +488,74 @@ 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_reset args = {
+ .handle = handle,
+ };
+
+ anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_RESET, &args);
+}
+
+void
+anv_gem_syncobj_signal(struct anv_device *device, uint32_t handle)
+{
+ struct drm_syncobj_signal args = {
+ .handle = handle,
+ };
+
+ anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_SIGNAL, &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);
+}
diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c
index c9f05ee..17f84f2 100644
--- a/src/intel/vulkan/anv_gem_stubs.c
+++ b/src/intel/vulkan/anv_gem_stubs.c
@@ -210,3 +210,29 @@ 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");
+}
+void
+anv_gem_syncobj_syncobj(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");
+}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 3b50c49..66a85db 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -809,6 +809,12 @@ uint32_t anv_gem_syncobj_create(struct anv_device *device);
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);
+void anv_gem_syncobj_signal(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);
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list