summaryrefslogtreecommitdiff
path: root/src/glx/x11/glxext.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glx/x11/glxext.c')
-rw-r--r--src/glx/x11/glxext.c596
1 files changed, 65 insertions, 531 deletions
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index 7eef38446b..525faab10e 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -63,7 +63,6 @@
#include "xf86dri.h"
#include "xf86drm.h"
#include "sarea.h"
-#include "dri_glx.h"
#endif
#ifdef USE_XCB
@@ -72,7 +71,6 @@
#include <xcb/glx.h>
#endif
-#include <assert.h>
#ifdef DEBUG
void __glXDumpDrawBuffer(__GLXcontext *ctx);
@@ -150,7 +148,7 @@ static __GLapi *IndirectAPI = NULL;
static GLboolean TSDinitialized = GL_FALSE;
static xthread_key_t ContextTSD;
-__GLXcontext *__glXGetCurrentContext(void)
+_X_HIDDEN __GLXcontext *__glXGetCurrentContext(void)
{
if (!TSDinitialized) {
xthread_key_create(&ContextTSD, NULL);
@@ -167,7 +165,7 @@ __GLXcontext *__glXGetCurrentContext(void)
}
}
-void __glXSetCurrentContext(__GLXcontext *c)
+_X_HIDDEN void __glXSetCurrentContext(__GLXcontext *c)
{
if (!TSDinitialized) {
xthread_key_create(&ContextTSD, NULL);
@@ -178,11 +176,11 @@ void __glXSetCurrentContext(__GLXcontext *c)
/* Used by the __glXLock() and __glXUnlock() macros */
-xmutex_rec __glXmutex;
+_X_HIDDEN xmutex_rec __glXmutex;
#elif defined( PTHREADS )
-pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
+_X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
# if defined( GLX_USE_TLS )
@@ -196,7 +194,7 @@ pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
__thread void * __glX_tls_Context __attribute__((tls_model("initial-exec")))
= &dummyContext;
-void __glXSetCurrentContext( __GLXcontext * c )
+_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c )
{
__glX_tls_Context = (c != NULL) ? c : &dummyContext;
}
@@ -229,13 +227,13 @@ static void init_thread_data( void )
}
}
-void __glXSetCurrentContext( __GLXcontext * c )
+_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c )
{
pthread_once( & once_control, init_thread_data );
pthread_setspecific( ContextTSD, c );
}
-__GLXcontext * __glXGetCurrentContext( void )
+_X_HIDDEN __GLXcontext * __glXGetCurrentContext( void )
{
void * v;
@@ -254,7 +252,7 @@ __GLXcontext * __glXGetCurrentContext( void )
#else
/* not thread safe */
-__GLXcontext *__glXcurrentContext = &dummyContext;
+_X_HIDDEN __GLXcontext *__glXcurrentContext = &dummyContext;
#endif
@@ -263,15 +261,7 @@ __GLXcontext *__glXcurrentContext = &dummyContext;
** You can set this cell to 1 to force the gl drawing stuff to be
** one command per packet
*/
-int __glXDebug = 0;
-
-/*
-** forward prototype declarations
-*/
-int __glXCloseDisplay(Display *dpy, XExtCodes *codes);
-
-
-/************************************************************************/
+_X_HIDDEN int __glXDebug = 0;
/* Extension required boiler plate */
@@ -294,7 +284,7 @@ static /* const */ char *error_list[] = {
"GLXBadWindow",
};
-int __glXCloseDisplay(Display *dpy, XExtCodes *codes)
+static int __glXCloseDisplay(Display *dpy, XExtCodes *codes)
{
GLXContext gc;
@@ -358,10 +348,8 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
Xfree((char*) psc->serverGLXexts);
#ifdef GLX_DIRECT_RENDERING
- /* Free the direct rendering per screen data */
- if (psc->driScreen.private)
- (*psc->driScreen.destroyScreen)(&psc->driScreen);
- psc->driScreen.private = NULL;
+ if (psc->driScreen)
+ psc->driScreen->destroyScreen(psc);
if (psc->drawHash)
__glxHashDestroy(psc->drawHash);
#endif
@@ -390,14 +378,9 @@ static int __glXFreeDisplayPrivate(XExtData *extension)
#ifdef GLX_DIRECT_RENDERING
/* Free the direct rendering per display data */
- if (priv->driDisplay.private)
- (*priv->driDisplay.destroyDisplay)(priv->dpy,
- priv->driDisplay.private);
- priv->driDisplay.private = NULL;
- if (priv->driDisplay.createNewScreen) {
- Xfree(priv->driDisplay.createNewScreen); /* free array of ptrs */
- priv->driDisplay.createNewScreen = NULL;
- }
+ if (priv->driDisplay)
+ (*priv->driDisplay->destroyDisplay)(priv->driDisplay);
+ priv->driDisplay = NULL;
#endif
Xfree((char*) priv);
@@ -439,7 +422,7 @@ static Bool QueryVersion(Display *dpy, int opcode, int *major, int *minor)
}
-void
+_X_HIDDEN void
__glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count,
const INT32 *bp, Bool tagged_only,
Bool fbconfig_style_tags )
@@ -633,385 +616,6 @@ __glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count,
config->haveStencilBuffer = (config->stencilBits > 0);
}
-
-#ifdef GLX_DIRECT_RENDERING
-static void
-filter_modes( __GLcontextModes ** server_modes,
- const __GLcontextModes * driver_modes )
-{
- __GLcontextModes * m;
- __GLcontextModes ** prev_next;
- const __GLcontextModes * check;
-
- if (driver_modes == NULL) {
- fprintf(stderr, "libGL warning: 3D driver returned no fbconfigs.\n");
- return;
- }
-
- /* For each mode in server_modes, check to see if a matching mode exists
- * in driver_modes. If not, then the mode is not available.
- */
-
- prev_next = server_modes;
- for ( m = *prev_next ; m != NULL ; m = *prev_next ) {
- GLboolean do_delete = GL_TRUE;
-
- for ( check = driver_modes ; check != NULL ; check = check->next ) {
- if ( _gl_context_modes_are_same( m, check ) ) {
- do_delete = GL_FALSE;
- break;
- }
- }
-
- /* The 3D has to support all the modes that match the GLX visuals
- * sent from the X server.
- */
- if ( do_delete && (m->visualID != 0) ) {
- do_delete = GL_FALSE;
-
- /* don't warn for this visual (Novell #247471 / X.Org #6689) */
- if (m->visualRating != GLX_NON_CONFORMANT_CONFIG) {
- fprintf(stderr, "libGL warning: 3D driver claims to not "
- "support visual 0x%02x\n", m->visualID);
- }
- }
-
- if ( do_delete ) {
- *prev_next = m->next;
-
- m->next = NULL;
- _gl_context_modes_destroy( m );
- }
- else {
- prev_next = & m->next;
- }
- }
-}
-
-#ifdef XDAMAGE_1_1_INTERFACE
-static GLboolean has_damage_post(Display *dpy)
-{
- static GLboolean inited = GL_FALSE;
- static GLboolean has_damage;
-
- if (!inited) {
- int major, minor;
-
- if (XDamageQueryVersion(dpy, &major, &minor) &&
- major == 1 && minor >= 1)
- {
- has_damage = GL_TRUE;
- } else {
- has_damage = GL_FALSE;
- }
- inited = GL_TRUE;
- }
-
- return has_damage;
-}
-#endif /* XDAMAGE_1_1_INTERFACE */
-
-static void __glXReportDamage(__DRIdrawable *driDraw,
- int x, int y,
- drm_clip_rect_t *rects, int num_rects,
- GLboolean front_buffer)
-{
-#ifdef XDAMAGE_1_1_INTERFACE
- XRectangle *xrects;
- XserverRegion region;
- int i;
- int x_off, y_off;
- __GLXdrawable *glxDraw =
- containerOf(driDraw, __GLXdrawable, driDrawable);
- __GLXscreenConfigs *psc = glxDraw->psc;
- Display *dpy = psc->dpy;
- Drawable drawable;
-
- if (!has_damage_post(dpy))
- return;
-
- if (front_buffer) {
- x_off = x;
- y_off = y;
- drawable = RootWindow(dpy, psc->scr);
- } else{
- x_off = 0;
- y_off = 0;
- drawable = glxDraw->drawable;
- }
-
- xrects = malloc(sizeof(XRectangle) * num_rects);
- if (xrects == NULL)
- return;
-
- for (i = 0; i < num_rects; i++) {
- xrects[i].x = rects[i].x1 + x_off;
- xrects[i].y = rects[i].y1 + y_off;
- xrects[i].width = rects[i].x2 - rects[i].x1;
- xrects[i].height = rects[i].y2 - rects[i].y1;
- }
- region = XFixesCreateRegion(dpy, xrects, num_rects);
- free(xrects);
- XDamageAdd(dpy, drawable, region);
- XFixesDestroyRegion(dpy, region);
-#endif
-}
-
-static GLboolean
-__glXDRIGetDrawableInfo(__DRIdrawable *drawable,
- unsigned int *index, unsigned int *stamp,
- int *X, int *Y, int *W, int *H,
- int *numClipRects, drm_clip_rect_t ** pClipRects,
- int *backX, int *backY,
- int *numBackClipRects, drm_clip_rect_t **pBackClipRects)
-{
- __GLXdrawable *glxDraw =
- containerOf(drawable, __GLXdrawable, driDrawable);
- __GLXscreenConfigs *psc = glxDraw->psc;
- Display *dpy = psc->dpy;
-
- return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable,
- index, stamp, X, Y, W, H,
- numClipRects, pClipRects,
- backX, backY,
- numBackClipRects, pBackClipRects);
-}
-
-
-/**
- * Table of functions exported by the loader to the driver.
- */
-static const __DRIcontextModesExtension contextModesExtension = {
- { __DRI_CONTEXT_MODES, __DRI_CONTEXT_MODES_VERSION },
- _gl_context_modes_create,
- _gl_context_modes_destroy,
-};
-
-static const __DRIsystemTimeExtension systemTimeExtension = {
- { __DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION },
- __glXGetUST,
- __driGetMscRateOML,
-};
-
-static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = {
- { __DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION },
- __glXDRIGetDrawableInfo
-};
-
-static const __DRIdamageExtension damageExtension = {
- { __DRI_DAMAGE, __DRI_DAMAGE_VERSION },
- __glXReportDamage,
-};
-
-static const __DRIextension *loader_extensions[] = {
- &contextModesExtension.base,
- &systemTimeExtension.base,
- &getDrawableInfoExtension.base,
- &damageExtension.base,
- NULL
-};
-
-
-
-/**
- * Perform the required libGL-side initialization and call the client-side
- * driver's \c __driCreateNewScreen function.
- *
- * \param dpy Display pointer.
- * \param scrn Screen number on the display.
- * \param psc DRI screen information.
- * \param driDpy DRI display information.
- * \param createNewScreen Pointer to the client-side driver's
- * \c __driCreateNewScreen function.
- * \returns A pointer to the \c __DRIscreenPrivate structure returned by
- * the client-side driver on success, or \c NULL on failure.
- *
- * \todo This function needs to be modified to remove context-modes from the
- * list stored in the \c __GLXscreenConfigsRec to match the list
- * returned by the client-side driver.
- */
-static void *
-CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
- __DRIdisplay * driDpy,
- PFNCREATENEWSCREENFUNC createNewScreen)
-{
- __DRIscreenPrivate *psp = NULL;
-#ifndef GLX_USE_APPLEGL
- drm_handle_t hSAREA;
- drmAddress pSAREA = MAP_FAILED;
- char *BusID;
- __DRIversion ddx_version;
- __DRIversion dri_version;
- __DRIversion drm_version;
- __DRIframebuffer framebuffer;
- int fd = -1;
- int status;
- const char * err_msg;
- const char * err_extra;
-
- dri_version.major = driDpy->private->driMajor;
- dri_version.minor = driDpy->private->driMinor;
- dri_version.patch = driDpy->private->driPatch;
-
-
- err_msg = "XF86DRIOpenConnection";
- err_extra = NULL;
-
- framebuffer.base = MAP_FAILED;
- framebuffer.dev_priv = NULL;
-
- if (XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
- int newlyopened;
- fd = drmOpenOnce(NULL,BusID, &newlyopened);
- Xfree(BusID); /* No longer needed */
-
- err_msg = "open DRM";
- err_extra = strerror( -fd );
-
- if (fd >= 0) {
- drm_magic_t magic;
-
- err_msg = "drmGetMagic";
- err_extra = NULL;
-
- if (!drmGetMagic(fd, &magic)) {
- drmVersionPtr version = drmGetVersion(fd);
- if (version) {
- drm_version.major = version->version_major;
- drm_version.minor = version->version_minor;
- drm_version.patch = version->version_patchlevel;
- drmFreeVersion(version);
- }
- else {
- drm_version.major = -1;
- drm_version.minor = -1;
- drm_version.patch = -1;
- }
-
- err_msg = "XF86DRIAuthConnection";
- if (!newlyopened || XF86DRIAuthConnection(dpy, scrn, magic)) {
- char *driverName;
-
- /*
- * Get device name (like "tdfx") and the ddx version
- * numbers. We'll check the version in each DRI driver's
- * "createNewScreen" function.
- */
- err_msg = "XF86DRIGetClientDriverName";
- if (XF86DRIGetClientDriverName(dpy, scrn,
- &ddx_version.major,
- &ddx_version.minor,
- &ddx_version.patch,
- &driverName)) {
- drm_handle_t hFB;
- int junk;
-
- /* No longer needed. */
- Xfree( driverName );
-
-
- /*
- * Get device-specific info. pDevPriv will point to a struct
- * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h)
- * that has information about the screen size, depth, pitch,
- * ancilliary buffers, DRM mmap handles, etc.
- */
- err_msg = "XF86DRIGetDeviceInfo";
- if (XF86DRIGetDeviceInfo(dpy, scrn,
- &hFB,
- &junk,
- &framebuffer.size,
- &framebuffer.stride,
- &framebuffer.dev_priv_size,
- &framebuffer.dev_priv)) {
- framebuffer.width = DisplayWidth(dpy, scrn);
- framebuffer.height = DisplayHeight(dpy, scrn);
-
- /*
- * Map the framebuffer region.
- */
- status = drmMap(fd, hFB, framebuffer.size,
- (drmAddressPtr)&framebuffer.base);
-
- err_msg = "drmMap of framebuffer";
- err_extra = strerror( -status );
-
- if ( status == 0 ) {
- /*
- * Map the SAREA region. Further mmap regions
- * may be setup in each DRI driver's
- * "createNewScreen" function.
- */
- status = drmMap(fd, hSAREA, SAREA_MAX,
- &pSAREA);
-
- err_msg = "drmMap of sarea";
- err_extra = strerror( -status );
-
- if ( status == 0 ) {
- __GLcontextModes * driver_modes = NULL;
-
- err_msg = "InitDriver";
- err_extra = NULL;
- psp = (*createNewScreen)(scrn,
- &psc->driScreen,
- & ddx_version,
- & dri_version,
- & drm_version,
- & framebuffer,
- pSAREA,
- fd,
- loader_extensions,
- & driver_modes );
-
- filter_modes(&psc->configs, driver_modes);
- filter_modes(&psc->visuals, driver_modes);
- _gl_context_modes_destroy(driver_modes);
- }
- }
- }
- }
- }
- }
- }
- }
-
- if ( psp == NULL ) {
- if ( pSAREA != MAP_FAILED ) {
- (void)drmUnmap(pSAREA, SAREA_MAX);
- }
-
- if ( framebuffer.base != MAP_FAILED ) {
- (void)drmUnmap((drmAddress)framebuffer.base, framebuffer.size);
- }
-
- if ( framebuffer.dev_priv != NULL ) {
- Xfree(framebuffer.dev_priv);
- }
-
- if ( fd >= 0 ) {
- (void)drmCloseOnce(fd);
- }
-
- (void)XF86DRICloseConnection(dpy, scrn);
-
- if ( err_extra != NULL ) {
- fprintf(stderr, "libGL error: %s failed (%s)\n", err_msg,
- err_extra);
- }
- else {
- fprintf(stderr, "libGL error: %s failed\n", err_msg );
- }
-
- fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
- }
-#endif /* !GLX_USE_APPLEGL */
-
- return psp;
-}
-
-#endif /* GLX_DIRECT_RENDERING */
-
static __GLcontextModes *
createConfigsFromProperties(Display *dpy, int nvisuals, int nprops,
int screen, GLboolean tagged_only)
@@ -1167,34 +771,17 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
getVisualConfigs(dpy, priv, i);
getFBConfigs(dpy, priv, i);
-#ifdef GLX_DIRECT_RENDERING
psc->scr = i;
psc->dpy = dpy;
- /* Create drawable hash */
- psc->drawHash = __glxHashCreate();
- if ( psc->drawHash == NULL ) {
- SyncHandle();
- FreeScreenConfigs(priv);
- return GL_FALSE;
- }
-
- /* Initialize per screen dynamic client GLX extensions */
- psc->ext_list_first_time = GL_TRUE;
- /* Initialize the direct rendering per screen data and functions */
- if (priv->driDisplay.private != NULL) {
- /* FIXME: Should it be some sort of an error if createNewScreen[i]
- * FIXME: is NULL?
- */
- if (priv->driDisplay.createNewScreen &&
- priv->driDisplay.createNewScreen[i]) {
-
- psc->driScreen.private =
- CallCreateNewScreen(dpy, i, psc,
- & priv->driDisplay,
- priv->driDisplay.createNewScreen[i] );
- if (psc->driScreen.private != NULL)
- __glXScrEnableDRIExtension(psc);
- }
+#ifdef GLX_DIRECT_RENDERING
+ if (priv->driDisplay) {
+ /* Create drawable hash */
+ psc->drawHash = __glxHashCreate();
+ if (psc->drawHash == NULL)
+ continue;
+ psc->driScreen = (*priv->driDisplay->createScreen)(psc, i, priv);
+ if (psc->driScreen == NULL)
+ __glxHashDestroy(psc->drawHash);
}
#endif
}
@@ -1205,7 +792,7 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
/*
** Initialize the client side extension code.
*/
-__GLXdisplayPrivate *__glXInitialize(Display* dpy)
+_X_HIDDEN __GLXdisplayPrivate *__glXInitialize(Display* dpy)
{
XExtDisplayInfo *info = __glXFindDisplay(dpy);
XExtData **privList, *private, *found;
@@ -1285,8 +872,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
** (e.g., those called in AllocAndFetchScreenConfigs).
*/
if (getenv("LIBGL_ALWAYS_INDIRECT") == NULL) {
- dpyPriv->driDisplay.private =
- driCreateDisplay(dpy, &dpyPriv->driDisplay);
+ dpyPriv->driDisplay = driCreateDisplay(dpy);
}
#endif
@@ -1320,7 +906,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
** Setup for sending a GLX command on dpy. Make sure the extension is
** initialized. Try to avoid calling __glXInitialize as its kinda slow.
*/
-CARD8 __glXSetupForCommand(Display *dpy)
+_X_HIDDEN CARD8 __glXSetupForCommand(Display *dpy)
{
GLXContext gc;
__GLXdisplayPrivate *priv;
@@ -1361,7 +947,7 @@ CARD8 __glXSetupForCommand(Display *dpy)
* Modify this function to use \c ctx->pc instead of the explicit
* \c pc parameter.
*/
-GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
+_X_HIDDEN GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
{
Display * const dpy = ctx->currentDpy;
#ifdef USE_XCB
@@ -1411,9 +997,9 @@ GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
* \param data Command data.
* \param dataLen Size, in bytes, of the command data.
*/
-void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
- GLint totalRequests,
- const GLvoid * data, GLint dataLen)
+_X_HIDDEN void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
+ GLint totalRequests,
+ const GLvoid * data, GLint dataLen)
{
Display *dpy = gc->currentDpy;
#ifdef USE_XCB
@@ -1459,9 +1045,9 @@ void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
* \param data Command data.
* \param dataLen Size, in bytes, of the command data.
*/
-void __glXSendLargeCommand(__GLXcontext *ctx,
- const GLvoid *header, GLint headerLen,
- const GLvoid *data, GLint dataLen)
+_X_HIDDEN void __glXSendLargeCommand(__GLXcontext *ctx,
+ const GLvoid *header, GLint headerLen,
+ const GLvoid *data, GLint dataLen)
{
GLint maxSize;
GLint totalRequests, requestNumber;
@@ -1601,71 +1187,27 @@ static Bool SendMakeCurrentRequest(Display *dpy, CARD8 opcode,
#ifdef GLX_DIRECT_RENDERING
-static __DRIdrawable *
-FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc)
+static __GLXDRIdrawable *
+FetchDRIDrawable(Display *dpy, GLXDrawable drawable, GLXContext gc)
{
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
- __GLXdrawable *pdraw;
- __GLXscreenConfigs *sc;
- drm_drawable_t hwDrawable;
- void *empty_attribute_list = NULL;
+ __GLXDRIdrawable *pdraw;
+ __GLXscreenConfigs *psc;
- if (priv == NULL || priv->driDisplay.private == NULL)
+ if (priv == NULL || priv->driDisplay == NULL)
return NULL;
- sc = &priv->screenConfigs[gc->screen];
- if (__glxHashLookup(sc->drawHash, drawable, (void *) &pdraw) == 0)
- return &pdraw->driDrawable;
-
- /* Allocate a new drawable */
- pdraw = Xmalloc(sizeof(*pdraw));
- if (!pdraw)
- return NULL;
-
- pdraw->drawable = drawable;
- pdraw->psc = sc;
-
- if (!XF86DRICreateDrawable(dpy, sc->scr, drawable, &hwDrawable))
- return NULL;
-
- /* Create a new drawable */
- pdraw->driDrawable.private =
- (*sc->driScreen.createNewDrawable)(&sc->driScreen,
- gc->mode,
- &pdraw->driDrawable,
- hwDrawable,
- GLX_WINDOW_BIT,
- empty_attribute_list);
-
- if (!pdraw->driDrawable.private) {
- XF86DRIDestroyDrawable(dpy, sc->scr, drawable);
- Xfree(pdraw);
- return NULL;
- }
+ psc = &priv->screenConfigs[gc->screen];
+ if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0)
+ return pdraw;
- if (__glxHashInsert(sc->drawHash, drawable, pdraw)) {
- (*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable);
- XF86DRIDestroyDrawable(dpy, sc->scr, drawable);
- Xfree(pdraw);
+ pdraw = psc->driScreen->createDrawable(psc, drawable, gc);
+ if (__glxHashInsert(psc->drawHash, drawable, pdraw)) {
+ (*pdraw->destroyDrawable)(pdraw);
return NULL;
}
- return &pdraw->driDrawable;
-}
-
-static Bool BindContextWrapper( Display *dpy, GLXContext gc,
- GLXDrawable draw, GLXDrawable read )
-{
- __DRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc);
- __DRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
-
- return (*gc->driContext.bindContext)(&gc->driContext, pdraw, pread);
-}
-
-
-static Bool UnbindContextWrapper( GLXContext gc )
-{
- return (*gc->driContext.unbindContext)(&gc->driContext);
+ return pdraw;
}
#endif /* GLX_DIRECT_RENDERING */
@@ -1675,8 +1217,8 @@ static Bool UnbindContextWrapper( GLXContext gc )
*
* \note This is in this file so that it can access dummyContext.
*/
-USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext gc)
+static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext gc)
{
xGLXMakeCurrentReply reply;
const GLXContext oldGC = __glXGetCurrentContext();
@@ -1698,20 +1240,16 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
return GL_FALSE;
}
-#ifndef GLX_DIRECT_RENDERING
- if (gc && gc->isDirect) {
- return GL_FALSE;
- }
-#endif
-
_glapi_check_multithread();
#ifdef GLX_DIRECT_RENDERING
/* Bind the direct rendering context to the drawable */
- if (gc && gc->isDirect) {
- bindReturnValue = (gc->driContext.private)
- ? BindContextWrapper(dpy, gc, draw, read)
- : False;
+ if (gc && gc->driContext) {
+ __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc);
+ __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc);
+
+ bindReturnValue =
+ (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
} else
#endif
{
@@ -1728,7 +1266,7 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
return False;
}
- if ((dpy != oldGC->currentDpy || (gc && gc->isDirect)) &&
+ if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
!oldGC->isDirect && oldGC != &dummyContext) {
xGLXMakeCurrentReply dummy_reply;
@@ -1743,8 +1281,8 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
& dummy_reply);
}
#ifdef GLX_DIRECT_RENDERING
- else if (oldGC->isDirect && oldGC->driContext.private) {
- (void) UnbindContextWrapper(oldGC);
+ else if (oldGC->driContext) {
+ oldGC->driContext->unbindContext(oldGC->driContext);
}
#endif
@@ -1774,15 +1312,11 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
*/
#ifdef GLX_DIRECT_RENDERING
/* Destroy the old direct rendering context */
- if (oldGC->isDirect) {
- if (oldGC->driContext.private) {
- (*oldGC->driContext.destroyContext)
- (&oldGC->driContext);
- XF86DRIDestroyContext(oldGC->createDpy,
- oldGC->psc->scr,
- gc->hwContextID);
- oldGC->driContext.private = NULL;
- }
+ if (oldGC->driContext) {
+ oldGC->driContext->destroyContext(oldGC->driContext,
+ oldGC->psc,
+ oldGC->createDpy);
+ oldGC->driContext = NULL;
}
#endif
__glXFreeContext(oldGC);
@@ -1795,7 +1329,7 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
gc->currentDrawable = draw;
gc->currentReadable = read;
- if (!gc->isDirect) {
+ if (!gc->driContext) {
if (!IndirectAPI)
IndirectAPI = __glXNewIndirectAPI();
_glapi_set_dispatch(IndirectAPI);
@@ -1847,7 +1381,7 @@ PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
#ifdef DEBUG
-void __glXDumpDrawBuffer(__GLXcontext *ctx)
+_X_HIDDEN void __glXDumpDrawBuffer(__GLXcontext *ctx)
{
GLubyte *p = ctx->buf;
GLubyte *end = ctx->pc;