X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglx%2Fglxcmds.c;h=c8ec9c21fed8d20d3af40b4c0452901cd0d33e64;hb=e975e18bebb54b20f00c568e7870932402b79f8f;hp=8b4151d0b4b78b81003c352b80ab85759aa71ecb;hpb=776a2a54473194e2f0926902276a1f880cded91f;p=mesa.git diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 8b4151d0b4b..c8ec9c21fed 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -90,6 +90,51 @@ GetGLXDRIDrawable(Display * dpy, GLXDrawable drawable) #endif +_X_HIDDEN struct glx_drawable * +GetGLXDrawable(Display *dpy, GLXDrawable drawable) +{ + struct glx_display *priv = __glXInitialize(dpy); + struct glx_drawable *glxDraw; + + if (priv == NULL) + return NULL; + + if (__glxHashLookup(priv->glXDrawHash, drawable, (void *) &glxDraw) == 0) + return glxDraw; + + return NULL; +} + +_X_HIDDEN int +InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, XID xDrawable, + GLXDrawable drawable) +{ + struct glx_display *priv = __glXInitialize(dpy); + + if (!priv) + return -1; + + glxDraw->xDrawable = xDrawable; + glxDraw->drawable = drawable; + glxDraw->lastEventSbc = 0; + glxDraw->eventSbcWrap = 0; + + return __glxHashInsert(priv->glXDrawHash, drawable, glxDraw); +} + +_X_HIDDEN void +DestroyGLXDrawable(Display *dpy, GLXDrawable drawable) +{ + struct glx_display *priv = __glXInitialize(dpy); + struct glx_drawable *glxDraw; + + if (!priv) + return; + + glxDraw = GetGLXDrawable(dpy, drawable); + __glxHashDelete(priv->glXDrawHash, drawable); + free(glxDraw); +} /** * Get the GLX per-screen data structure associated with a GLX context. @@ -224,10 +269,14 @@ CreateContext(Display *dpy, int generic_id, struct glx_config *config, return NULL; gc = NULL; +#ifdef GLX_USE_APPLEGL + gc = applegl_create_context(psc, config, shareList, renderType); +#else if (allowDirect && psc->vtable->create_context) gc = psc->vtable->create_context(psc, config, shareList, renderType); if (!gc) gc = indirect_create_context(psc, config, shareList, renderType); +#endif if (!gc) return NULL; @@ -350,8 +399,9 @@ glx_send_destroy_context(Display *dpy, XID xid) /* ** Destroy the named context */ -static void -DestroyContext(Display * dpy, GLXContext ctx) + +_X_EXPORT void +glXDestroyContext(Display * dpy, GLXContext ctx) { struct glx_context *gc = (struct glx_context *) ctx; @@ -373,14 +423,7 @@ DestroyContext(Display * dpy, GLXContext ctx) } __glXUnlock(); - if (gc->vtable->destroy) - gc->vtable->destroy(gc); -} - -_X_EXPORT void -glXDestroyContext(Display * dpy, GLXContext gc) -{ - DestroyContext(dpy, gc); + gc->vtable->destroy(gc); } /* @@ -602,7 +645,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) struct glx_screen *const psc = GetGLXScreenConfigs(dpy, screen); const struct glx_config *config; - config = _gl_context_modes_find_visual(psc->visuals, vis->visualid); + config = glx_config_find_visual(psc->visuals, vis->visualid); if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, config)) return None; @@ -610,6 +653,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) return pixmap; #else xGLXCreateGLXPixmapReq *req; + struct glx_drawable *glxDraw; GLXPixmap xid; CARD8 opcode; @@ -618,6 +662,10 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) return None; } + glxDraw = Xmalloc(sizeof(*glxDraw)); + if (!glxDraw) + return None; + /* Send the glXCreateGLXPixmap request */ LockDisplay(dpy); GetReq(GLXCreateGLXPixmap, req); @@ -630,6 +678,11 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) UnlockDisplay(dpy); SyncHandle(); + if (InitGLXDrawable(dpy, glxDraw, pixmap, req->glxpixmap)) { + free(glxDraw); + return None; + } + #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) do { /* FIXME: Maybe delay __DRIdrawable creation until the drawable @@ -642,19 +695,33 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap) psc = priv->screens[vis->screen]; if (psc->driScreen == NULL) - break; + return xid; + config = glx_config_find_visual(psc->visuals, vis->visualid); pdraw = psc->driScreen->createDrawable(psc, pixmap, xid, config); if (pdraw == NULL) { fprintf(stderr, "failed to create pixmap\n"); + xid = None; break; } if (__glxHashInsert(priv->drawHash, xid, pdraw)) { (*pdraw->destroyDrawable) (pdraw); - return None; /* FIXME: Check what we're supposed to do here... */ + xid = None; + break; } } while (0); + + if (xid == None) { + xGLXDestroyGLXPixmapReq *dreq; + LockDisplay(dpy); + GetReq(GLXDestroyGLXPixmap, dreq); + dreq->reqType = opcode; + dreq->glxCode = X_GLXDestroyGLXPixmap; + dreq->glxpixmap = xid; + UnlockDisplay(dpy); + SyncHandle(); + } #endif return xid; @@ -688,6 +755,8 @@ glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap) UnlockDisplay(dpy); SyncHandle(); + DestroyGLXDrawable(dpy, glxpixmap); + #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) { struct glx_display *const priv = __glXInitialize(dpy); @@ -706,7 +775,7 @@ _X_EXPORT void glXSwapBuffers(Display * dpy, GLXDrawable drawable) { #ifdef GLX_USE_APPLEGL - GLXContext gc = glXGetCurrentContext(); + struct glx_context * gc = __glXGetCurrentContext(); if(gc && apple_glx_is_current_drawable(dpy, gc->driContext, drawable)) { apple_glx_swap_buffers(gc->driContext); } else { @@ -725,15 +794,17 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable) gc = __glXGetCurrentContext(); #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable); + { + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable); - if (pdraw != NULL) { - if (gc && drawable == gc->currentDrawable) { - glFlush(); - } + if (pdraw != NULL) { + if (gc && drawable == gc->currentDrawable) { + glFlush(); + } - (*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0); - return; + (*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0); + return; + } } #endif @@ -1476,12 +1547,9 @@ _X_EXPORT GLXContextID glXGetContextIDEXT(const GLXContext ctx_user) return ctx->xid; } -_X_EXPORT void -glXFreeContextEXT(Display * dpy, GLXContext ctx) -{ - DestroyContext(dpy, ctx); -} - +_X_EXPORT +GLX_ALIAS_VOID(glXFreeContextEXT, (Display *dpy, GLXContext ctx), (dpy, ctx), + glXDestroyContext); _X_EXPORT GLXFBConfig * glXChooseFBConfig(Display * dpy, int screen, @@ -2475,7 +2543,6 @@ static const struct name_address_pair GLX_functions[] = { {NULL, NULL} /* end of list */ }; -#ifndef GLX_USE_APPLEGL static const GLvoid * get_glx_proc_address(const char *funcName) { @@ -2489,7 +2556,6 @@ get_glx_proc_address(const char *funcName) return NULL; } -#endif /** * Get the address of a named GL function. This is the pre-GLX 1.4 name for @@ -2512,9 +2578,6 @@ _X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void) * DRI based drivers from searching the core GL function table for * internal API functions. */ -#ifdef GLX_USE_APPLEGL - f = (gl_function) apple_glx_get_proc_address(procName); -#else f = (gl_function) get_glx_proc_address((const char *) procName); if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l') && (procName[2] != 'X')) { @@ -2523,8 +2586,13 @@ _X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void) #endif if (!f) f = (gl_function) _glapi_get_proc_address((const char *) procName); + if (!f) { + struct glx_context *gc = __glXGetCurrentContext(); + + if (gc != NULL && gc->vtable->get_proc_address != NULL) + f = gc->vtable->get_proc_address((const char *) procName); + } } -#endif return f; }