xf86-video-intel: test/dri3.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Apr 20 07:01:11 PDT 2015


 test/dri3.c |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

New commits:
commit 75037efcd75f6baa3b48dd818b3efca42087f1b9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Apr 20 14:54:50 2015 +0100

    test/dri3: Add an explicit DRI3 extension check first
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/dri3.c b/test/dri3.c
index 45f3285..e564462 100644
--- a/test/dri3.c
+++ b/test/dri3.c
@@ -29,6 +29,7 @@
 #include <xcb/dri3.h>
 #include <xcb/sync.h>
 #include <unistd.h>
+#include <stdlib.h>
 
 #include "dri3.h"
 
@@ -109,12 +110,45 @@ void dri3_fence_free(Display *dpy, struct dri3_fence *fence)
 	xcb_sync_destroy_fence(c, fence->xid);
 }
 
+static void dri3_query_version(xcb_connection_t *c, int *major, int *minor)
+{
+	xcb_dri3_query_version_reply_t *reply;
+
+	reply = xcb_dri3_query_version_reply(c,
+					     xcb_dri3_query_version(c,
+								    XCB_DRI3_MAJOR_VERSION,
+								    XCB_DRI3_MINOR_VERSION),
+					     NULL);
+	if (reply != NULL) {
+		*major = reply->major_version;
+		*minor = reply->minor_version;
+		free(reply);
+	}
+}
+
+static int dri3_exists(xcb_connection_t *c)
+{
+	const xcb_query_extension_reply_t *ext;
+	int major, minor;
+
+	major = minor = -1;
+
+	ext = xcb_get_extension_data(c, &xcb_dri3_id);
+	if (ext != NULL && ext->present)
+		dri3_query_version(c, &major, &minor);
+
+	return major >= 0;
+}
+
 int dri3_open__full(Display *dpy, Window root, unsigned provider)
 {
 	xcb_connection_t *c = XGetXCBConnection(dpy);
 	xcb_dri3_open_cookie_t cookie;
 	xcb_dri3_open_reply_t *reply;
 
+	if (!dri3_exists(c))
+		return -1;
+
 	cookie = xcb_dri3_open(c, root, provider);
 	reply = xcb_dri3_open_reply(c, cookie, NULL);
 


More information about the xorg-commit mailing list