[PATCH libXext 2/3] Add XSyncQueryFence()

James Jones jajones at nvidia.com
Tue Sep 21 16:31:31 PDT 2010


Allows callers to query whether or not a given
fence sync object is currently triggered.

Signed-off-by: James Jones <jajones at nvidia.com>
Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
---
 include/X11/extensions/sync.h |    6 ++++++
 src/XSync.c                   |   29 +++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/include/X11/extensions/sync.h b/include/X11/extensions/sync.h
index 5b157f8..05a5a98 100644
--- a/include/X11/extensions/sync.h
+++ b/include/X11/extensions/sync.h
@@ -358,6 +358,12 @@ extern Bool XSyncDestroyFence(
     XSyncFence /*fence*/
 );
 
+extern Bool XSyncQueryFence(
+    Display* /*dpy*/,
+    XSyncFence /*fence*/,
+    Bool* /*triggered*/
+);
+
 _XFUNCPROTOEND
 
 #endif /* _SYNC_SERVER */
diff --git a/src/XSync.c b/src/XSync.c
index fdc5e33..0dcacc4 100644
--- a/src/XSync.c
+++ b/src/XSync.c
@@ -846,6 +846,35 @@ XSyncDestroyFence(Display *dpy, XSyncFence fence)
     return True;
 }
 
+Bool
+XSyncQueryFence(Display *dpy, XSyncFence fence, Bool *triggered)
+{
+    XExtDisplayInfo *info = find_display(dpy);
+    xSyncQueryFenceReply rep;
+    xSyncQueryFenceReq *req;
+
+    SyncCheckExtension(dpy, info, None);
+
+    LockDisplay(dpy);
+    GetReq(SyncQueryFence, req);
+    req->reqType = info->codes->major_opcode;
+    req->syncReqType = X_SyncQueryFence;
+    req->fid = fence;
+
+    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
+    {
+	UnlockDisplay(dpy);
+	SyncHandle();
+	return False;
+    }
+    if (triggered)
+	*triggered = rep.triggered;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return True;
+}
+
 /*
  *  Functions corresponding to the macros for manipulating 64-bit values
  */
-- 
1.7.1



More information about the xorg-devel mailing list