dri_glx.c revision a296d96de45d38a6ed0b3c817334d443facc169b
1cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/************************************************************************** 2cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonCopyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 4cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonAll Rights Reserved. 5cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 6cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonPermission is hereby granted, free of charge, to any person obtaining a 7cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksoncopy of this software and associated documentation files (the 8cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson"Software"), to deal in the Software without restriction, including 9cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonwithout limitation the rights to use, copy, modify, merge, publish, 10cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksondistribute, sub license, and/or sell copies of the Software, and to 11cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonpermit persons to whom the Software is furnished to do so, subject to 12cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonthe following conditions: 13cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 14cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonThe above copyright notice and this permission notice (including the 15cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonnext paragraph) shall be included in all copies or substantial portions 16cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jacksonof the Software. 17cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 18cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonIN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 22cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24cb3610e37c4c0a40520441b8515d044dabcc8854Adam JacksonSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 26cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson**************************************************************************/ 27cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 28cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 29cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Authors: 30cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Kevin E. Martin <kevin@precisioninsight.com> 31cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Brian Paul <brian@precisioninsight.com> 32cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 33cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 34cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 3580b280db883edc9550484dba03bd5c124b6a9bf9Jeremy Huddleston#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) 36cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 376497d50924230e6b96929c8da0c2bd7287b70d8aAlan Hourihane#include <X11/Xlib.h> 3842c279a03b4d3529efc0d552c37ace2c82306822Xiang, Haihao#include <X11/extensions/Xfixes.h> 3942c279a03b4d3529efc0d552c37ace2c82306822Xiang, Haihao#include <X11/extensions/Xdamage.h> 40cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "glxclient.h" 41cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "xf86dri.h" 42a3c3c1f1437de0186d70de9017a6a8e404ecf482Adam Jackson#include "dri2.h" 43cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include "sarea.h" 44cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <dlfcn.h> 45cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#include <sys/types.h> 46890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg#include <sys/mman.h> 47890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg#include "xf86drm.h" 48079345703901b497f2c09714051b33bb2dff1b4fGeorge Sapountzis#include "dri_common.h" 49cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 50a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsbergstruct dri_display 510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdisplay base; 53425f9ed44e576aef27f7ab98968043f7f180d0fdKristian Høgsberg 540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 55425f9ed44e576aef27f7ab98968043f7f180d0fdKristian Høgsberg ** XFree86-DRI version information 56425f9ed44e576aef27f7ab98968043f7f180d0fdKristian Høgsberg */ 570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int driMajor; 580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int driMinor; 590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int driPatch; 60425f9ed44e576aef27f7ab98968043f7f180d0fdKristian Høgsberg}; 61cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 62a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsbergstruct dri_context 630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIcontext base; 650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __DRIcontext *driContext; 660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XID hwContextID; 670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc; 68e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg}; 69e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 70cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 71cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Given a display pointer and screen number, determine the name of 72cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * the DRI driver for the screen. (I.e. "r128", "tdfx", etc). 73cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Return True for success, False for failure. 74cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 760896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriGetDriverName(Display * dpy, int scrNum, char **driverName) 77cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int directCapable; 790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Bool b; 800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int event, error; 810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int driverMajor, driverMinor, driverPatch; 820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf *driverName = NULL; 840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (XF86DRIQueryExtension(dpy, &event, &error)) { /* DRI1 */ 860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) { 870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n"); 880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!directCapable) { 910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n"); 920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor, 960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &driverPatch, driverName); 970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!b) { 980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("Cannot determine driver name for screen %d\n", 990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf scrNum); 1000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 1010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n", 1040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf driverMajor, driverMinor, driverPatch, *driverName, 1050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf scrNum); 1060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return True; 1080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else if (DRI2QueryExtension(dpy, &event, &error)) { /* DRI2 */ 1100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf char *dev; 1110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev); 1120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (ret) 1140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(dev); 1150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return ret; 1170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return False; 120cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 121cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 122cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 123cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Exported function for querying the DRI driver for a given screen. 124cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 125cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * The returned char pointer points to a static array that will be 126cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * overwritten by subsequent calls. 127cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 1280896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC const char * 1290896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetScreenDriver(Display * dpy, int scrNum) 1300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf{ 131cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson static char ret[32]; 132cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson char *driverName; 133079345703901b497f2c09714051b33bb2dff1b4fGeorge Sapountzis if (driGetDriverName(dpy, scrNum, &driverName)) { 134cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson int len; 135cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson if (!driverName) 1360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 1370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf len = strlen(driverName); 138cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson if (len >= 31) 1390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 1400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf memcpy(ret, driverName, len + 1); 141cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson Xfree(driverName); 142cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return ret; 143cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson } 144cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return NULL; 145cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 146cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 147cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 148cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Exported function for obtaining a driver's option list (UTF-8 encoded XML). 149cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 150cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * The returned char pointer points directly into the driver. Therefore 151cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * it should be treated as a constant. 152cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 153cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * If the driver was not found or does not support configuration NULL is 154cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * returned. 155cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * 156cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Note: The driver remains opened after this function returns. 157cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 1580896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófPUBLIC const char * 1590896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófglXGetDriverConfig(const char *driverName) 160e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg{ 1610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf void *handle = driOpenDriver(driverName); 1620f2723cacbaf9b27ecb8d13581f4b72ff86dd911Kristian Høgsberg if (handle) 1630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return dlsym(handle, "__driConfigOptions"); 164cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson else 165cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson return NULL; 166cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 167cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 168890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg#ifdef XDAMAGE_1_1_INTERFACE 169e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 1700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic GLboolean 1710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófhas_damage_post(Display * dpy) 172890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg{ 1730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf static GLboolean inited = GL_FALSE; 1740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf static GLboolean has_damage; 1750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!inited) { 1770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int major, minor; 1780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (XDamageQueryVersion(dpy, &major, &minor) && 1800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf major == 1 && minor >= 1) { 1810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf has_damage = GL_TRUE; 1820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 1840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf has_damage = GL_FALSE; 1850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf inited = GL_TRUE; 1870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 1880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 1890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return has_damage; 190890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg} 191890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg 1920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 1930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXReportDamage(__DRIdrawable * driDraw, 1940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int x, int y, 1950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_clip_rect_t * rects, int num_rects, 1960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLboolean front_buffer, void *loaderPrivate) 197890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg{ 1980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XRectangle *xrects; 1990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XserverRegion region; 2000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int i; 2010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int x_off, y_off; 2020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *glxDraw = loaderPrivate; 2030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc = glxDraw->psc; 2040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Display *dpy = psc->dpy; 2050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Drawable drawable; 2060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!has_damage_post(dpy)) 2080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 2090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (front_buffer) { 2110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf x_off = x; 2120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf y_off = y; 2130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drawable = RootWindow(dpy, psc->scr); 2140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 2160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf x_off = 0; 2170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf y_off = 0; 2180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drawable = glxDraw->xDrawable; 2190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xrects = malloc(sizeof(XRectangle) * num_rects); 2220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (xrects == NULL) 2230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return; 2240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (i = 0; i < num_rects; i++) { 2260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xrects[i].x = rects[i].x1 + x_off; 2270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xrects[i].y = rects[i].y1 + y_off; 2280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xrects[i].width = rects[i].x2 - rects[i].x1; 2290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf xrects[i].height = rects[i].y2 - rects[i].y1; 2300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 2310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf region = XFixesCreateRegion(dpy, xrects, num_rects); 2320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf free(xrects); 2330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XDamageAdd(dpy, drawable, region); 2340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFixesDestroyRegion(dpy, region); 235890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg} 236890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg 237e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergstatic const __DRIdamageExtension damageExtension = { 2380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf {__DRI_DAMAGE, __DRI_DAMAGE_VERSION}, 2390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXReportDamage, 240e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg}; 241e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 242e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg#endif 243e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 244890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsbergstatic GLboolean 2450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf__glXDRIGetDrawableInfo(__DRIdrawable * drawable, 2460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf unsigned int *index, unsigned int *stamp, 2470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int *X, int *Y, int *W, int *H, 2480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int *numClipRects, drm_clip_rect_t ** pClipRects, 2490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int *backX, int *backY, 2500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int *numBackClipRects, 2510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_clip_rect_t ** pBackClipRects, 2520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf void *loaderPrivate) 253890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg{ 2540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *glxDraw = loaderPrivate; 2550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc = glxDraw->psc; 2560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Display *dpy = psc->dpy; 2570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 2580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable, 2590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf index, stamp, X, Y, W, H, 2600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf numClipRects, pClipRects, 2610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf backX, backY, 2620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf numBackClipRects, pBackClipRects); 263890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg} 264890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg 265890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsbergstatic const __DRIgetDrawableInfoExtension getDrawableInfoExtension = { 2660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf {__DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION}, 2670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __glXDRIGetDrawableInfo 268890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg}; 269890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg 270890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsbergstatic const __DRIextension *loader_extensions[] = { 2710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &systemTimeExtension.base, 2720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &getDrawableInfoExtension.base, 273e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg#ifdef XDAMAGE_1_1_INTERFACE 2740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &damageExtension.base, 275e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg#endif 2760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf NULL 277890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg}; 278890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg 279890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg/** 280890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * Perform the required libGL-side initialization and call the client-side 281890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * driver's \c __driCreateNewScreen function. 282890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * 283890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * \param dpy Display pointer. 284890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * \param scrn Screen number on the display. 285890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * \param psc DRI screen information. 286890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * \param driDpy DRI display information. 287890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * \param createNewScreen Pointer to the client-side driver's 288890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * \c __driCreateNewScreen function. 289d61f07318c8678901b948fdaa8ccdf37aa3203e9Kristian Høgsberg * \returns A pointer to the \c __DRIscreen structure returned by 290890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg * the client-side driver on success, or \c NULL on failure. 291890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg */ 292890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsbergstatic void * 2930896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófCallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc, 294a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg struct dri_display * driDpy) 295890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg{ 2960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf void *psp = NULL; 2970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_handle_t hSAREA; 2980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drmAddress pSAREA = MAP_FAILED; 2990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf char *BusID; 3000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __DRIversion ddx_version; 3010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __DRIversion dri_version; 3020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __DRIversion drm_version; 3030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __DRIframebuffer framebuffer; 3040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int fd = -1; 3050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int status; 3060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_magic_t magic; 3080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drmVersionPtr version; 3090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int newlyopened; 3100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf char *driverName; 3110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_handle_t hFB; 3120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int junk; 3130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __DRIconfig **driver_configs; 3140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLcontextModes *visual; 3150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* DRI protocol version. */ 3170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf dri_version.major = driDpy->driMajor; 3180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf dri_version.minor = driDpy->driMinor; 3190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf dri_version.patch = driDpy->driPatch; 3200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf framebuffer.base = MAP_FAILED; 3220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf framebuffer.dev_priv = NULL; 32386d98fa4a2dfdae75e6ecd9a7e6e73d4183075a0Vinson Lee framebuffer.size = 0; 3240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) { 3260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("XF86DRIOpenConnection failed\n"); 3270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 3280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf fd = drmOpenOnce(NULL, BusID, &newlyopened); 3310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(BusID); /* No longer needed */ 3330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (fd < 0) { 3350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("drmOpenOnce failed (%s)\n", strerror(-fd)); 3360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 3370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (drmGetMagic(fd, &magic)) { 3400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("drmGetMagic failed\n"); 3410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 3420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf version = drmGetVersion(fd); 3450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (version) { 3460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_version.major = version->version_major; 3470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_version.minor = version->version_minor; 3480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_version.patch = version->version_patchlevel; 3490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drmFreeVersion(version); 3500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf else { 3520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_version.major = -1; 3530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_version.minor = -1; 3540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_version.patch = -1; 3550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (newlyopened && !XF86DRIAuthConnection(dpy, scrn, magic)) { 3580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("XF86DRIAuthConnection failed\n"); 3590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 3600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Get device name (like "tdfx") and the ddx version numbers. 3630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * We'll check the version in each DRI driver's "createNewScreen" 3640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * function. */ 3650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!XF86DRIGetClientDriverName(dpy, scrn, 3660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &ddx_version.major, 3670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &ddx_version.minor, 3680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &ddx_version.patch, &driverName)) { 3690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("XF86DRIGetClientDriverName failed\n"); 3700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 3710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(driverName); /* No longer needed. */ 3740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* 3760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * Get device-specific info. pDevPriv will point to a struct 3770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that 3780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * has information about the screen size, depth, pitch, ancilliary 3790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * buffers, DRM mmap handles, etc. 3800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 3810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk, 3820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &framebuffer.size, &framebuffer.stride, 3830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &framebuffer.dev_priv_size, 3840896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &framebuffer.dev_priv)) { 3850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("XF86DRIGetDeviceInfo failed"); 3860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 3870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf framebuffer.width = DisplayWidth(dpy, scrn); 3900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf framebuffer.height = DisplayHeight(dpy, scrn); 3910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 3920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Map the framebuffer region. */ 3930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = drmMap(fd, hFB, framebuffer.size, 3940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (drmAddressPtr) & framebuffer.base); 3950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (status != 0) { 3960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status)); 3970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 3980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 3990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Map the SAREA region. Further mmap regions may be setup in 4010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * each DRI driver's "createNewScreen" function. 4020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 4030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA); 4040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (status != 0) { 4050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("drmMap of SAREA failed (%s)", strerror(-status)); 4060896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 4070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 4080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4090896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp = (*psc->legacy->createNewScreen) (scrn, 4100896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &ddx_version, 4110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &dri_version, 4120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &drm_version, 4130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &framebuffer, 4140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pSAREA, 4150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf fd, 4160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf loader_extensions, 4170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &driver_configs, psc); 4180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psp == NULL) { 4200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("Calling driver entry point failed"); 4210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf goto handle_error; 4220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 4230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs); 4250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs); 4260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->driver_configs = driver_configs; 4280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Visuals with depth != screen depth are subject to automatic compositing 4300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * in the X server, so DRI1 can't render to them properly. Mark them as 4310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf * non-conformant to prevent apps from picking them up accidentally. 4320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf */ 4330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (visual = psc->visuals; visual; visual = visual->next) { 4340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XVisualInfo template; 4350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XVisualInfo *visuals; 4360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int num_visuals; 4370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf long mask; 4380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf template.visualid = visual->visualID; 4400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf mask = VisualIDMask; 4410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf visuals = XGetVisualInfo(dpy, mask, &template, &num_visuals); 4420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (visuals) { 4440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (num_visuals > 0 && visuals->depth != DefaultDepth(dpy, scrn)) 4450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf visual->visualRating = GLX_NON_CONFORMANT_CONFIG; 4460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XFree(visuals); 4480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 4490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 4500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return psp; 452906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis 453906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis handle_error: 4540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pSAREA != MAP_FAILED) 4550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drmUnmap(pSAREA, SAREA_MAX); 456906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis 4570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (framebuffer.base != MAP_FAILED) 4580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drmUnmap((drmAddress) framebuffer.base, framebuffer.size); 459906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis 4600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (framebuffer.dev_priv != NULL) 4610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(framebuffer.dev_priv); 462906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis 4630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (fd >= 0) 4640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drmCloseOnce(fd); 465906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis 4660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XF86DRICloseConnection(dpy, scrn); 467906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis 4680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("reverting to software direct rendering\n"); 469906e189bd362399f1ffc4d5421ae0d0abd586977George Sapountzis 4700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 471890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg} 472890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg 4730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 4740896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriDestroyContext(__GLXDRIcontext * context, 4750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs * psc, Display * dpy) 476020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg{ 477a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg struct dri_context *pcp = (struct dri_context *) context; 478020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg 4790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->core->destroyContext) (pcp->driContext); 4800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 4810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); 4820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(pcp); 483020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg} 48453dc86363665b9b22f042c5d950b7de0ed02b4c8Kristian Høgsberg 4850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic Bool 4860896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriBindContext(__GLXDRIcontext * context, 4870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable * draw, __GLXDRIdrawable * read) 48853dc86363665b9b22f042c5d950b7de0ed02b4c8Kristian Høgsberg{ 489a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg struct dri_context *pcp = (struct dri_context *) context; 4900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __DRIcoreExtension *core = pcp->psc->core; 491020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg 4920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return (*core->bindContext) (pcp->driContext, 4930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf draw->driDrawable, read->driDrawable); 494020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg} 495020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg 4960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 4970896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriUnbindContext(__GLXDRIcontext * context) 498020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg{ 499a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg struct dri_context *pcp = (struct dri_context *) context; 5000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __DRIcoreExtension *core = pcp->psc->core; 501020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg 5020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*core->unbindContext) (pcp->driContext); 503020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg} 504020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg 5050896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic __GLXDRIcontext * 5060896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriCreateContext(__GLXscreenConfigs * psc, 5070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __GLcontextModes * mode, 5080896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXContext gc, GLXContext shareList, int renderType) 509020c64b2cf2973b5cb41e233d2bfbd85f1b699f7Kristian Høgsberg{ 510a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg struct dri_context *pcp, *pcp_shared; 5110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_context_t hwContext; 5120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __DRIcontext *shared = NULL; 5130896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode; 5140896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!psc || !psc->driScreen) 5160896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 5170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5180896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (shareList) { 519a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg pcp_shared = (struct dri_context *) shareList->driContext; 5200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf shared = pcp_shared->driContext; 5210896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 5220896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pcp = Xmalloc(sizeof *pcp); 5240896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pcp == NULL) 5250896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 5260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pcp->psc = psc; 5280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr, 5290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf mode->visualID, 5300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf &pcp->hwContextID, &hwContext)) { 5310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(pcp); 5320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 5330896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 5340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pcp->driContext = 5360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->legacy->createNewContext) (psc->__driScreen, 5370896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->driConfig, 5380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf renderType, shared, hwContext, pcp); 5390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (pcp->driContext == NULL) { 5400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID); 5410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(pcp); 5420896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 5430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 5440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pcp->base.destroyContext = driDestroyContext; 5460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pcp->base.bindContext = driBindContext; 5470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pcp->base.unbindContext = driUnbindContext; 5480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return &pcp->base; 55053dc86363665b9b22f042c5d950b7de0ed02b4c8Kristian Høgsberg} 55153dc86363665b9b22f042c5d950b7de0ed02b4c8Kristian Høgsberg 5520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 5530896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriDestroyDrawable(__GLXDRIdrawable * pdraw) 5549110425c72e45f618131b559eba883fd6c5536b4Kristian Høgsberg{ 5550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXscreenConfigs *psc = pdraw->psc; 5569110425c72e45f618131b559eba883fd6c5536b4Kristian Høgsberg 5570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->core->destroyDrawable) (pdraw->driDrawable); 5580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable); 5590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(pdraw); 5609110425c72e45f618131b559eba883fd6c5536b4Kristian Høgsberg} 56120b9230ce1b96ca246850a8088caeffc3f391a0cKristian Høgsberg 5620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic __GLXDRIdrawable * 5630896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriCreateDrawable(__GLXscreenConfigs * psc, 5640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XID xDrawable, 5650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLXDrawable drawable, const __GLcontextModes * modes) 56620b9230ce1b96ca246850a8088caeffc3f391a0cKristian Høgsberg{ 5670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIdrawable *pdraw; 5680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf drm_drawable_t hwDrawable; 5690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf void *empty_attribute_list = NULL; 5700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; 5710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Old dri can't handle GLX 1.3+ drawable constructors. */ 5730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (xDrawable != drawable) 5740896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 5750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5760896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw = Xmalloc(sizeof(*pdraw)); 5770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!pdraw) 5780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 5790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->drawable = drawable; 5810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->psc = psc; 5820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 583e0556657526a7fe53d6e17cf70ffa6a8ee35e0a9Vinson Lee if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable)) { 584e0556657526a7fe53d6e17cf70ffa6a8ee35e0a9Vinson Lee Xfree(pdraw); 5850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 586e0556657526a7fe53d6e17cf70ffa6a8ee35e0a9Vinson Lee } 5870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Create a new drawable */ 5890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->driDrawable = 5900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->legacy->createNewDrawable) (psc->__driScreen, 5910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf config->driConfig, 5920896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf hwDrawable, 5930896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf GLX_WINDOW_BIT, 5940896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf empty_attribute_list, pdraw); 5950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 5960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!pdraw->driDrawable) { 5970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable); 5980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(pdraw); 5990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 6000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdraw->destroyDrawable = driDestroyDrawable; 6030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return pdraw; 60520b9230ce1b96ca246850a8088caeffc3f391a0cKristian Høgsberg} 60620b9230ce1b96ca246850a8088caeffc3f391a0cKristian Høgsberg 607daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnesstatic int64_t 608daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse BarnesdriSwapBuffers(__GLXDRIdrawable * pdraw, int64_t unused1, int64_t unused2, 609daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes int64_t unused3) 610f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg{ 6110896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable); 612daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes return 0; 613f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg} 614f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg 6150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 6160896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriCopySubBuffer(__GLXDRIdrawable * pdraw, 6170896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int x, int y, int width, int height) 6184830809524b20e517e949151957512b14d7e679aKristian Høgsberg{ 6190896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*pdraw->psc->driCopySubBuffer->copySubBuffer) (pdraw->driDrawable, 6200896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf x, y, width, height); 6214830809524b20e517e949151957512b14d7e679aKristian Høgsberg} 6224830809524b20e517e949151957512b14d7e679aKristian Høgsberg 6230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 6240896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriDestroyScreen(__GLXscreenConfigs * psc) 625a1ea6f6198d80f716936a308cfab235f18a014e1Kristian Høgsberg{ 6260896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf /* Free the direct rendering per screen data */ 6270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->__driScreen) 6280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf (*psc->core->destroyScreen) (psc->__driScreen); 6290896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->__driScreen = NULL; 6300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->driver) 6310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf dlclose(psc->driver); 632a1ea6f6198d80f716936a308cfab235f18a014e1Kristian Høgsberg} 633a1ea6f6198d80f716936a308cfab235f18a014e1Kristian Høgsberg 634643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsbergstatic const struct glx_context_vtable dri_context_vtable = { 635643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg NULL, 636643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg NULL, 637643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg}; 638643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg 6390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic __GLXDRIscreen * 6400896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriCreateScreen(__GLXscreenConfigs * psc, int screen, 6410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXdisplayPrivate * priv) 642890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg{ 643a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg struct dri_display *pdp; 6440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf __GLXDRIscreen *psp; 6450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf const __DRIextension **extensions; 6460896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf char *driverName; 6470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int i; 6480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6490896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp = Xcalloc(1, sizeof *psp); 6500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psp == NULL) 6510896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 6520896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6530896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!driGetDriverName(priv->dpy, screen, &driverName)) { 6540896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(psp); 6550896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 6560896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6570896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6580896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->driver = driOpenDriver(driverName); 6590896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(driverName); 6600896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->driver == NULL) { 6610896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(psp); 6620896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 6630896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6640896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6650896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS); 6660896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (extensions == NULL) { 6670896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf ErrorMessageF("driver exports no extensions (%s)\n", dlerror()); 6680896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(psp); 6690896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 6700896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6710896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6720896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf for (i = 0; extensions[i]; i++) { 6730896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (strcmp(extensions[i]->name, __DRI_CORE) == 0) 674daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes psc->core = (__DRIcoreExtension *) extensions[i]; 6750896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0) 676daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes psc->legacy = (__DRIlegacyExtension *) extensions[i]; 6770896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6780896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6790896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->core == NULL || psc->legacy == NULL) { 6800896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(psp); 6810896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 6820896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6830896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 684a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg pdp = (struct dri_display *) priv->driDisplay; 6850896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psc->__driScreen = CallCreateNewScreen(psc->dpy, screen, psc, pdp); 6860896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->__driScreen == NULL) { 6870896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf dlclose(psc->driver); 6880896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(psp); 6890896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 6900896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 6910896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 692daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes driBindExtensions(psc); 693daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes driBindCommonExtensions(psc); 694daf7fe69f7bd0caa955d30b43fc35b7ce0069b6bJesse Barnes 6950896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (psc->driCopySubBuffer) 6960896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp->copySubBuffer = driCopySubBuffer; 6970896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 6980896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp->destroyScreen = driDestroyScreen; 6990896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp->createContext = driCreateContext; 7000896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp->createDrawable = driCreateDrawable; 7010896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp->swapBuffers = driSwapBuffers; 7020896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp->waitX = NULL; 7030896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf psp->waitGL = NULL; 7040896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf 705643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg psc->direct_context_vtable = &dri_context_vtable; 706643b2af0203764cb9f0a5b9e082937ab3f243523Kristian Høgsberg 7070896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return psp; 708890d44e54f2c800f066f59eb074ad09e14d54483Kristian Høgsberg} 709cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7108628b382e4ac492d829fe720219187b758add003Michel Dänzer/* Called from __glXFreeDisplayPrivate. 711cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 7120896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristófstatic void 7130896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriDestroyDisplay(__GLXDRIdisplay * dpy) 714cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 7150896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf Xfree(dpy); 716cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 717cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 718cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson/* 719cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * Allocate, initialize and return a __DRIdisplayPrivate object. 720cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * This is called from __glXInitialize() when we are given a new 721cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson * display pointer. 722cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson */ 7230896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf_X_HIDDEN __GLXDRIdisplay * 7240896268b97674d009d609476acfa1eed5dfea350RALOVICH, KristófdriCreateDisplay(Display * dpy) 725cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson{ 726a296d96de45d38a6ed0b3c817334d443facc169bKristian Høgsberg struct dri_display *pdpyp; 7270896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int eventBase, errorBase; 7280896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf int major, minor, patch; 729cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7300896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) { 7310896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 7320896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 733cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7340896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) { 7350896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 7360896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 737cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7380896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdpyp = Xmalloc(sizeof *pdpyp); 7390896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf if (!pdpyp) { 7400896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return NULL; 7410896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf } 742cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7430896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdpyp->driMajor = major; 7440896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdpyp->driMinor = minor; 7450896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdpyp->driPatch = patch; 746cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7470896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdpyp->base.destroyDisplay = driDestroyDisplay; 7480896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf pdpyp->base.createScreen = driCreateScreen; 749cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 7500896268b97674d009d609476acfa1eed5dfea350RALOVICH, Kristóf return &pdpyp->base; 751cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson} 752cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson 753cb3610e37c4c0a40520441b8515d044dabcc8854Adam Jackson#endif /* GLX_DIRECT_RENDERING */ 754