[Mesa-dev] [PATCH v3 6/8] anv/gem: Add a drm syncobj support
Jason Ekstrand
jason at jlekstrand.net
Fri Aug 4 17:24:52 UTC 2017
---
src/intel/vulkan/anv_gem.c | 52 ++++++++++++++++++++++++++++++++++++++++
src/intel/vulkan/anv_gem_stubs.c | 24 +++++++++++++++++++
src/intel/vulkan/anv_private.h | 4 ++++
3 files changed, 80 insertions(+)
diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c
index 5b68e9b..9e6b2bb 100644
--- a/src/intel/vulkan/anv_gem.c
+++ b/src/intel/vulkan/anv_gem.c
@@ -436,3 +436,55 @@ anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
return args.fence;
}
+
+uint32_t
+anv_gem_syncobj_create(struct anv_device *device)
+{
+ struct drm_syncobj_create args = {
+ .flags = 0,
+ };
+
+ int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
+ if (ret)
+ return 0;
+
+ return args.handle;
+}
+
+void
+anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
+{
+ struct drm_syncobj_destroy args = {
+ .handle = handle,
+ };
+
+ anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
+}
+
+int
+anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
+{
+ struct drm_syncobj_handle args = {
+ .handle = handle,
+ };
+
+ int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
+ if (ret)
+ return -1;
+
+ return args.fd;
+}
+
+uint32_t
+anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
+{
+ struct drm_syncobj_handle args = {
+ .fd = fd,
+ };
+
+ int ret = anv_ioctl(device->fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
+ if (ret)
+ return 0;
+
+ return args.handle;
+}
diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c
index 8d81eb5..842efb3 100644
--- a/src/intel/vulkan/anv_gem_stubs.c
+++ b/src/intel/vulkan/anv_gem_stubs.c
@@ -180,3 +180,27 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)
{
unreachable("Unused");
}
+
+uint32_t
+anv_gem_syncobj_create(struct anv_device *device)
+{
+ unreachable("Unused");
+}
+
+void
+anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
+{
+ unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
+{
+ unreachable("Unused");
+}
+
+uint32_t
+anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
+{
+ unreachable("Unused");
+}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 5c7b3b4..b451fa5 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -812,6 +812,10 @@ int anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle, uint32_t
int anv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
uint32_t read_domains, uint32_t write_domain);
int anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2);
+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);
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