glx: Make glXGetScreenDriver() work for DRI2

This commit is contained in:
Adam Jackson 2009-04-14 17:56:29 -04:00
parent 71793e0f79
commit a3c3c1f143
1 changed files with 35 additions and 21 deletions

View File

@ -40,6 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "glxclient.h" #include "glxclient.h"
#include "glcontextmodes.h" #include "glcontextmodes.h"
#include "xf86dri.h" #include "xf86dri.h"
#include "dri2.h"
#include "sarea.h" #include "sarea.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <sys/types.h> #include <sys/types.h>
@ -75,32 +76,45 @@ struct __GLXDRIcontextPrivateRec {
*/ */
static Bool driGetDriverName(Display *dpy, int scrNum, char **driverName) static Bool driGetDriverName(Display *dpy, int scrNum, char **driverName)
{ {
int directCapable; int directCapable;
Bool b; Bool b;
int driverMajor, driverMinor, driverPatch; int event, error;
int driverMajor, driverMinor, driverPatch;
*driverName = NULL; *driverName = NULL;
if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) { if (XF86DRIQueryExtension(dpy, &event, &error)) { /* DRI1 */
ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n"); if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) {
return False; ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n");
} return False;
if (!directCapable) { }
ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n"); if (!directCapable) {
return False; ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n");
} return False;
}
b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor, b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor,
&driverPatch, driverName); &driverPatch, driverName);
if (!b) { if (!b) {
ErrorMessageF("Cannot determine driver name for screen %d\n", scrNum); ErrorMessageF("Cannot determine driver name for screen %d\n", scrNum);
return False; return False;
} }
InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n", InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
driverMajor, driverMinor, driverPatch, *driverName, scrNum); driverMajor, driverMinor, driverPatch, *driverName, scrNum);
return True; return True;
} else if (DRI2QueryExtension(dpy, &event, &error)) { /* DRI2 */
char *dev;
Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev);
if (ret)
Xfree(dev);
return ret;
}
return False;
} }
/* /*