[PATCH i-g-t 3/4] lib/igt_vgem: Add a syncobj attach helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jason Ekstrand <jason@xxxxxxxxxxxxxx>
---
 lib/igt_vgem.c | 25 ++++++++++++++++++++++++-
 lib/igt_vgem.h |  1 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c
index 21cccb3..069c6dd 100644
--- a/lib/igt_vgem.c
+++ b/lib/igt_vgem.c
@@ -101,8 +101,9 @@ void *vgem_mmap(int fd, struct vgem_bo *bo, unsigned prot)
 struct local_vgem_fence_attach {
 	uint32_t handle;
 	uint32_t flags;
+#define LOCAL_VGEM_FENCE_SYNCOBJ	0x2
 	uint32_t out_fence;
-	uint32_t pad;
+	uint32_t syncobj;
 };
 
 struct local_vgem_fence_signal {
@@ -167,6 +168,28 @@ uint32_t vgem_fence_attach(int fd, struct vgem_bo *bo, unsigned flags)
 	return arg.out_fence;
 }
 
+uint32_t vgem_fence_attach_syncobj(int fd, uint32_t syncobj)
+{
+	struct local_vgem_fence_attach arg;
+	struct vgem_bo bo;
+
+	/* Create a dummy BO so the import works */
+	bo.width = 1;
+	bo.height = 1;
+	bo.bpp = 4;
+	vgem_create(fd, &bo);
+
+	memset(&arg, 0, sizeof(arg));
+	arg.handle = bo.handle;
+	arg.syncobj = syncobj;
+	arg.flags = LOCAL_VGEM_FENCE_SYNCOBJ;
+	igt_assert_eq(__vgem_fence_attach(fd, &arg), 0);
+
+	gem_close(fd, bo.handle);
+
+	return arg.out_fence;
+}
+
 static int ioctl_vgem_fence_signal(int fd, struct local_vgem_fence_signal *arg)
 {
 	int err = 0;
diff --git a/lib/igt_vgem.h b/lib/igt_vgem.h
index 002ad7f..555674b 100644
--- a/lib/igt_vgem.h
+++ b/lib/igt_vgem.h
@@ -44,6 +44,7 @@ bool vgem_fence_has_flag(int fd, unsigned flags);
 uint32_t vgem_fence_attach(int fd, struct vgem_bo *bo, unsigned flags);
 #define VGEM_FENCE_WRITE 0x1
 #define WIP_VGEM_FENCE_NOTIMEOUT 0x2
+uint32_t vgem_fence_attach_syncobj(int fd, uint32_t syncobj);
 int __vgem_fence_signal(int fd, uint32_t fence);
 void vgem_fence_signal(int fd, uint32_t fence);
 
-- 
2.5.0.400.gff86faf

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux