|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
Replacing cargo-culted Xlib DRI2 protocol with XCB.All over the place people have copied XF86DRI protocol stuff because people
never made an Xlib library for it. This is happening again with DRI2. I'd like to cut that off now by converting them to XCB, so I threw together this patch series. It's not really tested because XVMC is broken in 2/3 apps using it it seems, and the other one (mythtv) is a mess to configure. So, could the XCB folks review it to see if what I've done is sane (in particular the struct for the GetBuffersWithFormat req which doesn't have an equivalent in the xlib code, and the use of the reply strings in the XVMC code)? And Intel folks, do we see any issue with depending on XCB for this? _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
[PATCH] Add DRI2 protocol, based off of dri2proto.h and the server code.---
src/Makefile.am | 1 + src/dri2.xml | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 0 deletions(-) create mode 100644 src/dri2.xml diff --git a/src/Makefile.am b/src/Makefile.am index 3caaed2..0f0dfbc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ xcbinclude_HEADERS = \ composite.xml \ damage.xml \ dpms.xml \ + dri2.xml \ glx.xml \ randr.xml \ record.xml \ diff --git a/src/dri2.xml b/src/dri2.xml new file mode 100644 index 0000000..4d77f72 --- /dev/null +++ b/src/dri2.xml @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +Copyright (C) 2005 Jeremy Kolb. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person ob/Sintaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or their +institutions shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the authors. +--> + +<xcb header="dri2" extension-xname="DRI2" extension-name="DRI2" + major-version="1" minor-version="1"> + + <!-- Types --> + + <struct name="DRI2Buffer"> + <field type="CARD32" name="attachment" /> + <field type="CARD32" name="name" /> + <field type="CARD32" name="pitch" /> + <field type="CARD32" name="cpp" /> + <field type="CARD32" name="flags" /> + </struct> + + <struct name="GetBuffersWithFormatAttachment"> + <field type="CARD32" name="attachment" /> + <field type="CARD32" name="format" /> + </struct> + + <!-- Requests --> + <request name="QueryVersion" opcode="0"> + <field type="CARD32" name="major_version" /> + <field type="CARD32" name="minor_version" /> + <reply> + <pad bytes="1" /> + <field type="CARD32" name="major_version" /> + <field type="CARD32" name="minor_version" /> + <pad bytes="16" /> + </reply> + </request> + + <request name="Connect" opcode="1"> + <field type="CARD32" name="window" /> + <field type="CARD32" name="driver_type" /> + <reply> + <pad bytes="1" /> + <field type="CARD32" name="driver_name_length" /> + <field type="CARD32" name="device_name_length" /> + <pad bytes="16" /> + <list type="char" name="driver_name"> + <fieldref>driver_name_length</fieldref> + </list> + <list type="char" name="device_name"> + <fieldref>device_name_length</fieldref> + </list> + </reply> + </request> + + <request name="Authenticate" opcode="2"> + <field type="CARD32" name="window" /> + <field type="CARD32" name="magic" /> + <reply> + <pad bytes="1" /> + <field type="CARD32" name="authenticated" /> + <pad bytes="20" /> + </reply> + </request> + + <request name="CreateDrawable" opcode="3"> + <field type="CARD32" name="drawable" /> + </request> + + <request name="DestroyDrawable" opcode="4"> + <field type="CARD32" name="drawable" /> + </request> + + <request name="GetBuffers" opcode="5"> + <field type="CARD32" name="drawable" /> + <field type="CARD32" name="count" /> + <list type="CARD32" name="attachments" /> + <reply> + <pad bytes="1" /> + <field type="CARD32" name="width" /> + <field type="CARD32" name="height" /> + <field type="CARD32" name="count" /> + <list type="DRI2Buffer" name="buffers"> + <fieldref>count</fieldref> + </list> + <pad bytes="12" /> + </reply> + </request> + + <request name="CopyRegion" opcode="6"> + <field type="CARD32" name="drawable" /> + <field type="CARD32" name="region" /> + <field type="CARD32" name="dest" /> + <field type="CARD32" name="src" /> + <reply> + <pad bytes="1" /> + <pad bytes="24" /> + </reply> + </request> + + <request name="GetBuffersWithFormat" opcode="7"> + <field type="CARD32" name="drawable" /> + <field type="CARD32" name="count" /> + <list type="GetBuffersWithFormatAttachment" name="attachments" /> + <reply> + <pad bytes="1" /> + <field type="CARD32" name="width" /> + <field type="CARD32" name="height" /> + <field type="CARD32" name="count" /> + <list type="DRI2Buffer" name="buffers"> + <fieldref>count</fieldref> + </list> + <pad bytes="12" /> + </reply> + </request> +</xcb> -- 1.6.4.3 _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
[PATCH 1/2] Fix typo in the tutorial.---
doc/tutorial/index.html | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/doc/tutorial/index.html b/doc/tutorial/index.html index c540426..5824807 100644 --- a/doc/tutorial/index.html +++ b/doc/tutorial/index.html @@ -173,7 +173,7 @@ with the <a href="http://xcb.freedesktop.org">XCB</a> library. keep in mind that XCB, like the <a href="http://tronche.com/gui/x/xlib/introduction">Xlib</a> - library, isn't what post programmers wanting to write X + library, isn't what most programmers wanting to write X applications are looking for. They should use a much higher level GUI toolkit like Motif, <a href="http://www.lesstif.org">LessTiff</a>, -- 1.6.4.3 _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
[PATCH 2/2] Add DRI2 support.---
Makefile.am | 3 +++ configure.ac | 2 ++ src/.gitignore | 1 + src/Makefile.am | 10 ++++++++++ xcb-dri2.pc.in | 11 +++++++++++ 5 files changed, 27 insertions(+), 0 deletions(-) create mode 100644 xcb-dri2.pc.in diff --git a/Makefile.am b/Makefile.am index 3a2f6f5..ff9dea1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,9 @@ endif if BUILD_DPMS pkgconfig_DATA += xcb-dpms.pc endif +if BUILD_DRI2 +pkgconfig_DATA += xcb-dri2.pc +endif if BUILD_GLX pkgconfig_DATA += xcb-glx.pc endif diff --git a/configure.ac b/configure.ac index 96f5079..a748489 100644 --- a/configure.ac +++ b/configure.ac @@ -132,6 +132,7 @@ esac XCB_EXTENSION(Composite, "yes") XCB_EXTENSION(Damage, "yes") XCB_EXTENSION(DPMS, "yes") +XCB_EXTENSION(DRI2, "yes") XCB_EXTENSION(GLX, "yes") XCB_EXTENSION(RandR, "yes") XCB_EXTENSION(Record, "yes") @@ -174,6 +175,7 @@ xcb.pc xcb-composite.pc xcb-damage.pc xcb-dpms.pc +xcb-dri2.pc xcb-glx.pc xcb-randr.pc xcb-record.pc diff --git a/src/.gitignore b/src/.gitignore index 86d9b9c..21421a2 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -2,6 +2,7 @@ bigreq.* composite.* damage.* dpms.* +dri2.* glx.* randr.* record.* diff --git a/src/Makefile.am b/src/Makefile.am index f58ee65..fb19c28 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,6 +60,16 @@ libxcb_dpms_la_LIBADD = $(XCB_LIBS) nodist_libxcb_dpms_la_SOURCES = dpms.c dpms.h endif +EXTHEADERS += dri2.h +EXTSOURCES += dri2.c +EXTENSION_XML += dri2.xml +if BUILD_XFREE86_DRI +lib_LTLIBRARIES += libxcb-dri2.la +libxcb_dri2_la_LDFLAGS = -version-info 0:0:0 -no-undefined +libxcb_dri2_la_LIBADD = $(XCB_LIBS) +nodist_libxcb_dri2_la_SOURCES = dri2.c dri2.h +endif + EXTHEADERS += glx.h EXTSOURCES += glx.c EXTENSION_XML += glx.xml diff --git a/xcb-dri2.pc.in b/xcb-dri2.pc.in new file mode 100644 index 0000000..a9944df --- /dev/null +++ b/xcb-dri2.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: XCB DRI2 +Description: XCB DRI2 Extension +Version: @PACKAGE_VERSION@ +Requires: xcb +Libs: -L${libdir} -lxcb-dri2 +Cflags: -I${includedir} -- 1.6.4.3 _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
[PATCH] XVMC: Use XCB DRI2 instead of cargo-culting our own copy of the protocol.---
configure.ac | 4 +- src/xvmc/Makefile.am | 4 +- src/xvmc/dri2.c | 298 ------------------------------------------------- src/xvmc/dri2.h | 65 ----------- src/xvmc/intel_xvmc.c | 106 ++++++++++-------- 5 files changed, 63 insertions(+), 414 deletions(-) delete mode 100644 src/xvmc/dri2.c delete mode 100644 src/xvmc/dri2.h diff --git a/configure.ac b/configure.ac index b1e9a71..19dbf13 100644 --- a/configure.ac +++ b/configure.ac @@ -155,7 +155,9 @@ if test "$VIDEO_DEBUG" = yes; then fi if test "$XVMC" = yes; then - PKG_CHECK_MODULES(XVMCLIB, [xvmc xext xfixes dri2proto], [XVMC=yes], [XVMC=no]) + PKG_CHECK_MODULES(XVMCLIB, + [xvmc xext xfixes dri2proto x11-xcb xcb-dri2 xcb-aux], + [XVMC=yes], [XVMC=no]) fi AC_MSG_CHECKING([whether to include XvMC support]) AC_MSG_RESULT([$XVMC]) diff --git a/src/xvmc/Makefile.am b/src/xvmc/Makefile.am index 6cbba6a..5921244 100644 --- a/src/xvmc/Makefile.am +++ b/src/xvmc/Makefile.am @@ -24,9 +24,7 @@ libIntelXvMC_la_SOURCES = intel_xvmc.c \ xvmc_vld.c \ xvmc_vld.h \ intel_batchbuffer.c \ - intel_batchbuffer.h \ - dri2.c \ - dri2.h + intel_batchbuffer.h libIntelXvMC_la_CFLAGS = @XORG_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \ @XVMCLIB_CFLAGS@ -I$(top_srcdir)/src -DTRUE=1 -DFALSE=0 diff --git a/src/xvmc/dri2.c b/src/xvmc/dri2.c deleted file mode 100644 index 1ba9482..0000000 --- a/src/xvmc/dri2.c +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@...) - */ - -#define NEED_REPLIES -#include <X11/Xlibint.h> -#include <X11/extensions/Xext.h> -#include <X11/extensions/extutil.h> -#include <X11/extensions/dri2proto.h> -#include "xf86drm.h" -#include "dri2.h" - -static char dri2ExtensionName[] = DRI2_NAME; -static XExtensionInfo *dri2Info; -static XEXT_GENERATE_CLOSE_DISPLAY(DRI2CloseDisplay, dri2Info) -static /* const */ XExtensionHooks dri2ExtensionHooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - DRI2CloseDisplay, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static XEXT_GENERATE_FIND_DISPLAY(DRI2FindDisplay, dri2Info, - dri2ExtensionName, - &dri2ExtensionHooks, 0, NULL) - -Bool DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - - if (XextHasExtension(info)) { - *eventBase = info->codes->first_event; - *errorBase = info->codes->first_error; - return True; - } - - return False; -} - -Bool DRI2QueryVersion(Display * dpy, int *major, int *minor) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2QueryVersionReply rep; - xDRI2QueryVersionReq *req; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2QueryVersion, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2QueryVersion; - req->majorVersion = DRI2_MAJOR; - req->minorVersion = DRI2_MINOR; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *major = rep.majorVersion; - *minor = rep.minorVersion; - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} - -Bool DRI2Connect(Display * dpy, XID window, - char **driverName, char **deviceName) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2ConnectReply rep; - xDRI2ConnectReq *req; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2Connect, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2Connect; - req->window = window; - req->driverType = DRI2DriverDRI; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - *driverName = Xmalloc(rep.driverNameLength + 1); - if (*driverName == NULL) { - _XEatData(dpy, - ((rep.driverNameLength + 3) & ~3) + - ((rep.deviceNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - _XReadPad(dpy, *driverName, rep.driverNameLength); - (*driverName)[rep.driverNameLength] = '\0'; - - *deviceName = Xmalloc(rep.deviceNameLength + 1); - if (*deviceName == NULL) { - Xfree(*driverName); - _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - _XReadPad(dpy, *deviceName, rep.deviceNameLength); - (*deviceName)[rep.deviceNameLength] = '\0'; - - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} - -Bool DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2AuthenticateReq *req; - xDRI2AuthenticateReply rep; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2Authenticate, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2Authenticate; - req->window = window; - req->magic = magic; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return rep.authenticated; -} - -void DRI2CreateDrawable(Display * dpy, XID drawable) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2CreateDrawableReq *req; - - XextSimpleCheckExtension(dpy, info, dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2CreateDrawable, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2CreateDrawable; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); -} - -void DRI2DestroyDrawable(Display * dpy, XID drawable) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2DestroyDrawableReq *req; - - XextSimpleCheckExtension(dpy, info, dri2ExtensionName); - - XSync(dpy, False); - - LockDisplay(dpy); - GetReq(DRI2DestroyDrawable, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2DestroyDrawable; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); -} - -DRI2Buffer *DRI2GetBuffers(Display * dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, int *outCount) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2GetBuffersReply rep; - xDRI2GetBuffersReq *req; - DRI2Buffer *buffers; - xDRI2Buffer repBuffer; - CARD32 *p; - int i; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReqExtra(DRI2GetBuffers, count * 4, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2GetBuffers; - req->drawable = drawable; - req->count = count; - p = (CARD32 *) & req[1]; - for (i = 0; i < count; i++) - p[i] = attachments[i]; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - *width = rep.width; - *height = rep.height; - *outCount = rep.count; - - buffers = Xmalloc(rep.count * sizeof buffers[0]); - if (buffers == NULL) { - _XEatData(dpy, rep.count * sizeof repBuffer); - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - for (i = 0; i < rep.count; i++) { - _XReadPad(dpy, (char *)&repBuffer, sizeof repBuffer); - buffers[i].attachment = repBuffer.attachment; - buffers[i].name = repBuffer.name; - buffers[i].pitch = repBuffer.pitch; - buffers[i].cpp = repBuffer.cpp; - buffers[i].flags = repBuffer.flags; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return buffers; -} - -void DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region, - CARD32 dest, CARD32 src) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2CopyRegionReq *req; - xDRI2CopyRegionReply rep; - - XextSimpleCheckExtension(dpy, info, dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2CopyRegion, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2CopyRegion; - req->drawable = drawable; - req->region = region; - req->dest = dest; - req->src = src; - - _XReply(dpy, (xReply *) & rep, 0, xFalse); - - UnlockDisplay(dpy); - SyncHandle(); -} diff --git a/src/xvmc/dri2.h b/src/xvmc/dri2.h deleted file mode 100644 index ac6ce58..0000000 --- a/src/xvmc/dri2.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright © 2007,2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@...) - */ - -#ifndef _DRI2_H_ -#define _DRI2_H_ - -#include <X11/extensions/Xfixes.h> -#include <X11/extensions/dri2tokens.h> - -typedef struct { - unsigned int attachment; - unsigned int name; - unsigned int pitch; - unsigned int cpp; - unsigned int flags; -} DRI2Buffer; - -extern Bool -DRI2QueryExtension(Display * display, int *eventBase, int *errorBase); -extern Bool DRI2QueryVersion(Display * display, int *major, int *minor); -extern Bool -DRI2Connect(Display * display, XID window, - char **driverName, char **deviceName); -extern Bool DRI2Authenticate(Display * display, XID window, drm_magic_t magic); -extern void DRI2CreateDrawable(Display * display, XID drawable); -extern void DRI2DestroyDrawable(Display * display, XID handle); -extern DRI2Buffer *DRI2GetBuffers(Display * dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, - int *outCount); - -extern void -DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region, - CARD32 dest, CARD32 src); - -#endif diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c index 947f97d..8310527 100644 --- a/src/xvmc/intel_xvmc.c +++ b/src/xvmc/intel_xvmc.c @@ -25,7 +25,11 @@ * */ #include "intel_xvmc.h" -#include "dri2.h" +#include <xcb/xcb.h> +#include <xcb/xcb_aux.h> +#include <xcb/dri2.h> +#include <X11/Xlib-xcb.h> +#include <X11/extensions/dri2tokens.h> /* global */ struct _intel_xvmc_driver *xvmc_driver = NULL; @@ -235,6 +239,58 @@ intel_xvmc_surface_ptr intel_xvmc_find_surface(XID id) return NULL; } +static int +dri2_connect(Display *display) +{ + xcb_dri2_query_version_cookie_t query_version_cookie; + xcb_dri2_query_version_reply_t *query_version_reply; + xcb_dri2_connect_cookie_t connect_cookie; + xcb_dri2_connect_reply_t *connect_reply; + xcb_dri2_authenticate_cookie_t auth_cookie; + xcb_dri2_authenticate_reply_t *auth_reply; + xcb_screen_t *root; + xcb_connection_t *c = XGetXCBConnection(display); + drm_magic_t magic; + + root = xcb_aux_get_screen(c, DefaultScreen(display)); + + query_version_cookie = xcb_dri2_query_version(c, 1, 0); + query_version_reply = + xcb_dri2_query_version_reply(c, query_version_cookie, NULL); + + if (!query_version_reply) { + XVMC_ERR("DRI2 required"); + return BadValue; + } + free(query_version_reply); + + connect_cookie = xcb_dri2_connect(c, root->root, DRI2DriverDRI); + connect_reply = xcb_dri2_connect_reply(c, connect_cookie, NULL); + + xvmc_driver->fd = open(xcb_dri2_connect_device_name(connect_reply), + O_RDWR); + free(connect_reply); + if (xvmc_driver->fd < 0) { + XVMC_ERR("Failed to open drm device: %s\n", strerror(errno)); + return BadValue; + } + + if (drmGetMagic(xvmc_driver->fd, &magic)) { + XVMC_ERR("Failed to get magic\n"); + return BadValue; + } + + auth_cookie = xcb_dri2_authenticate(c, root->root, magic); + auth_reply = xcb_dri2_authenticate_reply(c, auth_cookie, NULL); + if (!auth_reply) { + XVMC_ERR("Failed to authenticate magic %d\n", magic); + return BadValue; + } + free(auth_reply); + + return Success; +} + /* * Function: XvMCCreateContext * Description: Create a XvMC context for the given surface parameters. @@ -258,7 +314,6 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port, Status ret; CARD32 *priv_data = NULL; struct _intel_xvmc_common *comm; - drm_magic_t magic; int major, minor; int error_base; int event_base; @@ -295,6 +350,7 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port, XVMC_ERR("XvMCExtension is not available!"); return BadValue; } + ret = XvMCQueryVersion(display, &major, &minor); if (ret) { XVMC_ERR @@ -360,56 +416,12 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port, ret = Success; xvmc_driver->fd = -1; - do { - if (!DRI2QueryExtension(display, &event_base, &error_base)) { - ret = BadValue; - break; - } - - if (!DRI2QueryVersion(display, &major, &minor)) { - ret = BadValue; - break; - } - - if (!DRI2Connect(display, RootWindow(display, screen), - &driverName, &deviceName)) { - ret = BadValue; - break; - } - - xvmc_driver->fd = open(deviceName, O_RDWR); - - if (xvmc_driver->fd < 0) { - XVMC_ERR("Failed to open drm device: %s\n", - strerror(errno)); - ret = BadValue; - break; - } - - if (drmGetMagic(xvmc_driver->fd, &magic)) { - XVMC_ERR("Failed to get magic\n"); - ret = BadValue; - break; - } - - if (!DRI2Authenticate - (display, RootWindow(display, screen), magic)) { - XVMC_ERR("Failed to authenticate magic %d\n", magic); - ret = BadValue; - break; - } - } while (0); - - XFree(driverName); - XFree(deviceName); - + ret = dri2_connect(display); if (ret != Success) { XFree(priv_data); context->privData = NULL; - if (xvmc_driver->fd >= 0) close(xvmc_driver->fd); - xvmc_driver = NULL; return ret; } -- 1.6.4.3 _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
Re: [PATCH 2/2] Add DRI2 support.On Thu, Oct 15, 2009 at 14:25:48 -0700, Eric Anholt wrote:
> @@ -60,6 +60,16 @@ libxcb_dpms_la_LIBADD = $(XCB_LIBS) > nodist_libxcb_dpms_la_SOURCES = dpms.c dpms.h > endif > > +EXTHEADERS += dri2.h > +EXTSOURCES += dri2.c > +EXTENSION_XML += dri2.xml > +if BUILD_XFREE86_DRI This one should be BUILD_DRI2. > +lib_LTLIBRARIES += libxcb-dri2.la > +libxcb_dri2_la_LDFLAGS = -version-info 0:0:0 -no-undefined > +libxcb_dri2_la_LIBADD = $(XCB_LIBS) > +nodist_libxcb_dri2_la_SOURCES = dri2.c dri2.h > +endif > + > EXTHEADERS += glx.h > EXTSOURCES += glx.c > EXTENSION_XML += glx.xml Cheers, Julien _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
Re: [PATCH] XVMC: Use XCB DRI2 instead of cargo-culting our own copy of the protocol.On Thu, Oct 15, 2009 at 14:25:49 -0700, Eric Anholt wrote:
> +static int > +dri2_connect(Display *display) > +{ > + xcb_dri2_query_version_cookie_t query_version_cookie; > + xcb_dri2_query_version_reply_t *query_version_reply; > + xcb_dri2_connect_cookie_t connect_cookie; > + xcb_dri2_connect_reply_t *connect_reply; > + xcb_dri2_authenticate_cookie_t auth_cookie; > + xcb_dri2_authenticate_reply_t *auth_reply; > + xcb_screen_t *root; > + xcb_connection_t *c = XGetXCBConnection(display); > + drm_magic_t magic; > + > + root = xcb_aux_get_screen(c, DefaultScreen(display)); > + > + query_version_cookie = xcb_dri2_query_version(c, 1, 0); > + query_version_reply = > + xcb_dri2_query_version_reply(c, query_version_cookie, NULL); > + > + if (!query_version_reply) { > + XVMC_ERR("DRI2 required"); > + return BadValue; > + } > + free(query_version_reply); > + maybe use xcb_get_extension_data() before xcb_dri2_query_version()? Cheers, Julien _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
Re: [PATCH] XVMC: Use XCB DRI2 instead of cargo-culting our own copy of the protocol.This sure makes me happy. :-)
Quirks that will bite you here: On Thu, Oct 15, 2009 at 2:25 PM, Eric Anholt <eric@...> wrote: > + query_version_cookie = xcb_dri2_query_version(c, 1, 0); You want to call xcb_get_extension_data (a cached version of QueryExtension) and verify that the extension is present before using any requests from the extension. The stubs will do this for you if you forget, but will shut down your X connection if the extension is not present, which would be unfortunate. ...I don't see that documented anywhere. Oops. Anyone know where we wrote this down, or mind adding it someplace appropriate? > + xvmc_driver->fd = open(xcb_dri2_connect_device_name(connect_reply), > + O_RDWR); Does the protocol specify that the device name field is null-terminated? Can you really trust it? XCB won't null-terminate things for you; it gives you exactly what it got off the wire. Otherwise, while it's unfortunate that this takes four completely sequential round-trips, it looks like good XCB client code. You could probably be optimistic and issue the Connect request while waiting for the QueryVersion reply, and just expect an error from Connect if you got one from QueryVersion. Just wait for both replies before returning, or you'll leak memory inside XCB. Jamey _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
Re: [Intel-gfx] [PATCH] Add DRI2 protocol, based off of dri2proto.h and the server code.On Thu, Oct 15, 2009 at 14:25:46 -0700, Eric Anholt wrote:
> diff --git a/src/dri2.xml b/src/dri2.xml > new file mode 100644 > index 0000000..4d77f72 > --- /dev/null > +++ b/src/dri2.xml > @@ -0,0 +1,136 @@ > +<?xml version="1.0" encoding="utf-8"?> > +<!-- > +Copyright (C) 2005 Jeremy Kolb. > +All Rights Reserved. This copyright notice seems wrong? > + > +Permission is hereby granted, free of charge, to any person ob/Sintaining a copy s,/Sin,, > +of this software and associated documentation files (the "Software"), to deal > +in the Software without restriction, including without limitation the rights > +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > +copies of the Software, and to permit persons to whom the Software is > +furnished to do so, subject to the following conditions: > + > +The above copyright notice and this permission notice shall be included in all [...] > + > +<xcb header="dri2" extension-xname="DRI2" extension-name="DRI2" > + major-version="1" minor-version="1"> > + > + <!-- Types --> > + > + <struct name="DRI2Buffer"> > + <field type="CARD32" name="attachment" /> attachment could get an enum, I think. > + <field type="CARD32" name="name" /> > + <field type="CARD32" name="pitch" /> > + <field type="CARD32" name="cpp" /> > + <field type="CARD32" name="flags" /> > + </struct> > + > + <struct name="GetBuffersWithFormatAttachment"> > + <field type="CARD32" name="attachment" /> > + <field type="CARD32" name="format" /> > + </struct> > + dri2proto.txt calls this DRI2ATTACH_FORMAT, so maybe name="AttachFormat"? > + <!-- Requests --> > + <request name="QueryVersion" opcode="0"> > + <field type="CARD32" name="major_version" /> > + <field type="CARD32" name="minor_version" /> > + <reply> > + <pad bytes="1" /> > + <field type="CARD32" name="major_version" /> > + <field type="CARD32" name="minor_version" /> > + <pad bytes="16" /> I think you can omit the trailing padding from replies. > + </reply> > + </request> > + > + <request name="Connect" opcode="1"> > + <field type="CARD32" name="window" /> > + <field type="CARD32" name="driver_type" /> maybe add an enum for driver_type as well. > + <reply> > + <pad bytes="1" /> > + <field type="CARD32" name="driver_name_length" /> > + <field type="CARD32" name="device_name_length" /> > + <pad bytes="16" /> > + <list type="char" name="driver_name"> > + <fieldref>driver_name_length</fieldref> > + </list> > + <list type="char" name="device_name"> > + <fieldref>device_name_length</fieldref> > + </list> > + </reply> > + </request> > + > + <request name="Authenticate" opcode="2"> > + <field type="CARD32" name="window" /> type="WINDOW" works, if you add '<import>xproto</import>' > + <field type="CARD32" name="magic" /> > + <reply> > + <pad bytes="1" /> > + <field type="CARD32" name="authenticated" /> > + <pad bytes="20" /> > + </reply> > + </request> > + > + <request name="CreateDrawable" opcode="3"> > + <field type="CARD32" name="drawable" /> > + </request> > + > + <request name="DestroyDrawable" opcode="4"> > + <field type="CARD32" name="drawable" /> > + </request> type="DRAWABLE" for these two. > + > + <request name="GetBuffers" opcode="5"> > + <field type="CARD32" name="drawable" /> > + <field type="CARD32" name="count" /> > + <list type="CARD32" name="attachments" /> should this list have a <fieldref>count</fieldref>? I guess it's not necessary since the length can be deduced from the request length... > + <reply> > + <pad bytes="1" /> > + <field type="CARD32" name="width" /> > + <field type="CARD32" name="height" /> > + <field type="CARD32" name="count" /> > + <list type="DRI2Buffer" name="buffers"> > + <fieldref>count</fieldref> > + </list> > + <pad bytes="12" /> the list should be after the padding, afaict? > + </reply> > + </request> > + > + <request name="CopyRegion" opcode="6"> > + <field type="CARD32" name="drawable" /> > + <field type="CARD32" name="region" /> > + <field type="CARD32" name="dest" /> > + <field type="CARD32" name="src" /> > + <reply> > + <pad bytes="1" /> > + <pad bytes="24" /> > + </reply> > + </request> > + > + <request name="GetBuffersWithFormat" opcode="7"> > + <field type="CARD32" name="drawable" /> > + <field type="CARD32" name="count" /> > + <list type="GetBuffersWithFormatAttachment" name="attachments" /> > + <reply> > + <pad bytes="1" /> > + <field type="CARD32" name="width" /> > + <field type="CARD32" name="height" /> > + <field type="CARD32" name="count" /> > + <list type="DRI2Buffer" name="buffers"> > + <fieldref>count</fieldref> > + </list> > + <pad bytes="12" /> same as above for pad vs list ordering. > + </reply> > + </request> > +</xcb> Cheers, Julien _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
|
|
Re: [Intel-gfx] Replacing cargo-culted Xlib DRI2 protocol with XCB.-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Eric Anholt wrote: > All over the place people have copied XF86DRI protocol stuff because people > never made an Xlib library for it. This is happening again with DRI2. > I'd like to cut that off now by converting them to XCB, so I threw together > this patch series. It's not really tested because XVMC is broken > in 2/3 apps using it it seems, and the other one (mythtv) is a mess > to configure. > > So, could the XCB folks review it to see if what I've done is sane (in > particular the struct for the GetBuffersWithFormat req which doesn't have an > equivalent in the xlib code, and the use of the reply strings in the XVMC > code)? And Intel folks, do we see any issue with depending on XCB for this? We had talked about this a XDC, and I strongly support it. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkrZBIIACgkQX1gOwKyEAw8zqACeOEO49VkTe6m/oTgLZbTq0u6H ficAn0gslaovnU4Z52/U3MzZFvIrR27Y =gJVM -----END PGP SIGNATURE----- _______________________________________________ Xcb mailing list Xcb@... http://lists.freedesktop.org/mailman/listinfo/xcb |
| Free embeddable forum powered by Nabble | Forum Help |