From 4a22ae8d446855d839cc199df8eb1b057045cb88 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Sun, 7 Jan 2007 08:12:01 -0500 Subject: Remove XIDs from DRI interface (see #5714). --- src/mesa/drivers/dri/common/dri_util.c | 198 +++------------------------------ src/mesa/drivers/dri/common/dri_util.h | 5 - 2 files changed, 16 insertions(+), 187 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index c30e66f172..1f916a82ca 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -88,63 +88,6 @@ __driUtilMessage(const char *f, ...) } -/*****************************************************************/ -/** \name Drawable list management */ -/*****************************************************************/ -/*@{*/ - -static GLboolean __driAddDrawable(void *drawHash, __DRIdrawable *pdraw) -{ - __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private; - - if (drmHashInsert(drawHash, pdp->draw, pdraw)) - return GL_FALSE; - - return GL_TRUE; -} - -static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw) -{ - int retcode; - __DRIdrawable *pdraw; - - retcode = drmHashLookup(drawHash, draw, (void *)&pdraw); - if (retcode) - return NULL; - - return pdraw; -} - - -/** - * Find drawables in the local hash that have been destroyed on the - * server. - * - * \param drawHash Hash-table containing all know drawables. - */ -static void __driGarbageCollectDrawables(void *drawHash) -{ - __DRIid draw; - __DRInativeDisplay *dpy; - __DRIdrawable *pdraw; - - if (drmHashFirst(drawHash, &draw, (void *)&pdraw) == 1) { - do { - __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private; - dpy = pdp->driScreenPriv->display; - if (! (*dri_interface->windowExists)(dpy, draw)) { - /* Destroy the local drawable data, if the drawable no - longer exists in the Xserver */ - (*pdraw->destroyDrawable)(dpy, pdraw->private); - _mesa_free(pdraw); - } - } while (drmHashNext(drawHash, &draw, (void *)&pdraw) == 1); - } -} - -/*@}*/ - - /*****************************************************************/ /** \name Context (un)binding functions */ /*****************************************************************/ @@ -155,8 +98,6 @@ static void __driGarbageCollectDrawables(void *drawHash) * * \param dpy the display handle. * \param scrn the screen number. - * \param draw drawable. - * \param read Current reading drawable. * \param gc context. * * \return \c GL_TRUE on success, or \c GL_FALSE on failure. @@ -170,12 +111,9 @@ static void __driGarbageCollectDrawables(void *drawHash) * into their respective real types it also assures they are not \c NULL. */ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, - __DRIid draw, __DRIid read, - __DRIcontext *ctx) + __DRIcontext *ctx) { __DRIscreen *pDRIScreen; - __DRIdrawable *pdraw; - __DRIdrawable *pread; __DRIcontextPrivate *pcp; __DRIscreenPrivate *psp; __DRIdrawablePrivate *pdp; @@ -186,7 +124,7 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, ** calling driUnbindContext. */ - if (ctx == NULL || draw == None || read == None) { + if (ctx == NULL) { /* ERROR!!! */ return GL_FALSE; } @@ -199,26 +137,12 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, psp = (__DRIscreenPrivate *)pDRIScreen->private; pcp = (__DRIcontextPrivate *)ctx->private; - - pdraw = __driFindDrawable(psp->drawHash, draw); - if (!pdraw) { - /* ERROR!!! */ - return GL_FALSE; - } - pdp = (__DRIdrawablePrivate *)pdraw->private; - - pread = __driFindDrawable(psp->drawHash, read); - if (!pread) { - /* ERROR!!! */ - return GL_FALSE; - } - prp = (__DRIdrawablePrivate *)pread->private; - + pdp = (__DRIdrawablePrivate *)pcp->driDrawablePriv; + prp = (__DRIdrawablePrivate *)pcp->driReadablePriv; /* Let driver unbind drawable from context */ (*psp->DriverAPI.UnbindContext)(pcp); - if (pdp->refcount == 0) { /* ERROR!!! */ return GL_FALSE; @@ -254,72 +178,20 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, * This function takes both a read buffer and a draw buffer. This is needed * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent * function. - * - * \bug This function calls \c driCreateNewDrawable in two places with the - * \c renderType hard-coded to \c GLX_WINDOW_BIT. Some checking might - * be needed in those places when support for pbuffers and / or pixmaps - * is added. Is it safe to assume that the drawable is a window? */ static GLboolean DoBindContext(__DRInativeDisplay *dpy, - __DRIid draw, __DRIid read, - __DRIcontext *ctx, const __GLcontextModes * modes, - __DRIscreenPrivate *psp) + __DRIdrawable *pdraw, + __DRIdrawable *pread, + __DRIcontext *ctx, + __DRIscreenPrivate *psp) { - __DRIdrawable *pdraw; __DRIdrawablePrivate *pdp; - __DRIdrawable *pread; __DRIdrawablePrivate *prp; __DRIcontextPrivate * const pcp = ctx->private; - /* Find the _DRIdrawable which corresponds to the writing drawable. */ - pdraw = __driFindDrawable(psp->drawHash, draw); - if (!pdraw) { - /* Allocate a new drawable */ - pdraw = (__DRIdrawable *)_mesa_malloc(sizeof(__DRIdrawable)); - if (!pdraw) { - /* ERROR!!! */ - return GL_FALSE; - } - - /* Create a new drawable */ - driCreateNewDrawable(dpy, modes, draw, pdraw, GLX_WINDOW_BIT, - empty_attribute_list); - if (!pdraw->private) { - /* ERROR!!! */ - _mesa_free(pdraw); - return GL_FALSE; - } - - } pdp = (__DRIdrawablePrivate *) pdraw->private; - - /* Find the _DRIdrawable which corresponds to the reading drawable. */ - if (read == draw) { - /* read buffer == draw buffer */ - prp = pdp; - } - else { - pread = __driFindDrawable(psp->drawHash, read); - if (!pread) { - /* Allocate a new drawable */ - pread = (__DRIdrawable *)_mesa_malloc(sizeof(__DRIdrawable)); - if (!pread) { - /* ERROR!!! */ - return GL_FALSE; - } - - /* Create a new drawable */ - driCreateNewDrawable(dpy, modes, read, pread, GLX_WINDOW_BIT, - empty_attribute_list); - if (!pread->private) { - /* ERROR!!! */ - _mesa_free(pread); - return GL_FALSE; - } - } - prp = (__DRIdrawablePrivate *) pread->private; - } + prp = (__DRIdrawablePrivate *) pread->private; /* Bind the drawable to the context */ pcp->driDrawablePriv = pdp; @@ -359,8 +231,9 @@ static GLboolean DoBindContext(__DRInativeDisplay *dpy, * function. */ static GLboolean driBindContext(__DRInativeDisplay *dpy, int scrn, - __DRIid draw, __DRIid read, - __DRIcontext * ctx) + __DRIdrawable *pdraw, + __DRIdrawable *pread, + __DRIcontext * ctx) { __DRIscreen *pDRIScreen; @@ -369,7 +242,7 @@ static GLboolean driBindContext(__DRInativeDisplay *dpy, int scrn, ** calling driBindContext. */ - if (ctx == NULL || draw == None || read == None) { + if (ctx == NULL || pdraw == None || pread == None) { /* ERROR!!! */ return GL_FALSE; } @@ -380,7 +253,7 @@ static GLboolean driBindContext(__DRInativeDisplay *dpy, int scrn, return GL_FALSE; } - return DoBindContext( dpy, draw, read, ctx, ctx->mode, + return DoBindContext( dpy, pdraw, pread, ctx, (__DRIscreenPrivate *)pDRIScreen->private ); } /*@}*/ @@ -438,8 +311,7 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - if (!__driFindDrawable(psp->drawHash, pdp->draw) || - ! (*dri_interface->getDrawableInfo)(pdp->display, pdp->screen, pdp->draw, + if (! (*dri_interface->getDrawableInfo)(pdp->display, pdp->screen, pdp->draw, &pdp->index, &pdp->lastStamp, &pdp->x, &pdp->y, &pdp->w, &pdp->h, &pdp->numClipRects, &pdp->pClipRects, @@ -675,30 +547,9 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy, pdp->swapBuffers = psp->DriverAPI.SwapBuffers; - /* Add pdraw to drawable list */ - if (!__driAddDrawable(psp->drawHash, pdraw)) { - /* ERROR!!! */ - (*pdraw->destroyDrawable)(dpy, pdp); - _mesa_free(pdp); - pdp = NULL; - pdraw->private = NULL; - } - return (void *) pdp; } -static __DRIdrawable * -driGetDrawable(__DRInativeDisplay *dpy, __DRIid draw, void *screenPrivate) -{ - __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate; - - /* - ** Make sure this routine returns NULL if the drawable is not bound - ** to a direct rendering context! - */ - return __driFindDrawable(psp->drawHash, draw); -} - static void driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate) { @@ -710,9 +561,7 @@ driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate) psp = pdp->driScreenPriv; scrn = psp->myNum; (*psp->DriverAPI.DestroyBuffer)(pdp); - if ((*dri_interface->windowExists)(dpy, pdp->draw)) - (void)(*dri_interface->destroyDrawable)(dpy, scrn, pdp->draw); - drmHashDelete(psp->drawHash, pdp->draw); + (void)(*dri_interface->destroyDrawable)(dpy, scrn, pdp->draw); if (pdp->pClipRects) { _mesa_free(pdp->pClipRects); pdp->pClipRects = NULL; @@ -751,7 +600,6 @@ driDestroyContext(__DRInativeDisplay *dpy, int scrn, void *contextPrivate) if (pcp) { (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp); - __driGarbageCollectDrawables(pcp->driScreenPriv->drawHash); (void) (*dri_interface->destroyContext)(dpy, scrn, pcp->contextID); _mesa_free(pcp); } @@ -836,8 +684,6 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes, return NULL; } - __driGarbageCollectDrawables(pcp->driScreenPriv->drawHash); - return pcp; } /*@}*/ @@ -874,15 +720,11 @@ static void driDestroyScreen(__DRInativeDisplay *dpy, int scrn, void *screenPriv (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize); - _mesa_free(psp->pDevPriv); (void)drmCloseOnce(psp->fd); if ( psp->modes != NULL ) { (*dri_interface->destroyContextModes)( psp->modes ); } - assert(psp->drawHash); - drmHashDestroy(psp->drawHash); - _mesa_free(psp); } } @@ -939,13 +781,6 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, return NULL; } - /* Create the hash table */ - psp->drawHash = drmHashCreate(); - if ( psp->drawHash == NULL ) { - _mesa_free( psp ); - return NULL; - } - psp->display = dpy; psp->myNum = scrn; psp->psc = psc; @@ -993,7 +828,6 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, psc->destroyScreen = driDestroyScreen; psc->createNewDrawable = driCreateNewDrawable; - psc->getDrawable = driGetDrawable; psc->getMSC = driGetMSC; psc->createNewContext = driCreateNewContext; diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 539d28d114..a08eab1616 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -489,11 +489,6 @@ struct __DRIscreenPrivateRec { */ __DRIcontextPrivate dummyContextPriv; - /** - * Hash table to hold the drawable information for this screen. - */ - void *drawHash; - /** * Device-dependent private information (not stored in the SAREA). * -- cgit v1.2.3 From aceccda56b08338e217991e54607f1c9f18fc3e6 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 10 May 2007 15:52:22 -0400 Subject: Drop __DRInativeDisplay and pass in __DRIscreen pointers instead. Many DRI entry points took a __DRInativeDisplay pointer and a screen index as arguments. The only use for the native display pointer was to pass it back to the loader when looking up the __DRIscreen for the given screen index. Instead, let's just pass in the __DRIscreen pointer directly, which let's drop the __DRInativeDisplay type and the getScreen function. The assumption is now that the loader will be able to retrieve context from the __DRIscreen pointer when necessary. --- include/GL/internal/dri_interface.h | 75 ++++++------ src/glx/x11/XF86dri.c | 9 +- src/glx/x11/glxclient.h | 28 ++++- src/glx/x11/glxcmds.c | 60 +++++----- src/glx/x11/glxext.c | 155 +++++++++++++++---------- src/glx/x11/xf86dri.h | 6 +- src/mesa/drivers/dri/common/dri_util.c | 139 +++++++--------------- src/mesa/drivers/dri/common/dri_util.h | 24 +--- src/mesa/drivers/dri/ffb/ffb_xmesa.c | 22 ++-- src/mesa/drivers/dri/i810/i810screen.c | 23 ++-- src/mesa/drivers/dri/i915/intel_screen.c | 33 +++--- src/mesa/drivers/dri/i965/intel_screen.c | 22 ++-- src/mesa/drivers/dri/mach64/mach64_screen.c | 22 ++-- src/mesa/drivers/dri/mga/mga_xmesa.c | 22 ++-- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 22 ++-- src/mesa/drivers/dri/r128/r128_screen.c | 22 ++-- src/mesa/drivers/dri/r200/r200_ioctl.c | 6 +- src/mesa/drivers/dri/r200/r200_ioctl.h | 6 +- src/mesa/drivers/dri/radeon/radeon_screen.c | 25 ++-- src/mesa/drivers/dri/savage/savage_xmesa.c | 22 ++-- src/mesa/drivers/dri/sis/sis_screen.c | 23 ++-- src/mesa/drivers/dri/tdfx/tdfx_screen.c | 22 ++-- src/mesa/drivers/dri/trident/trident_context.c | 24 ++-- src/mesa/drivers/dri/unichrome/via_context.c | 3 - src/mesa/drivers/dri/unichrome/via_context.h | 1 - src/mesa/drivers/dri/unichrome/via_screen.c | 23 ++-- 26 files changed, 405 insertions(+), 434 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 97edec0ca9..8a6984de68 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -57,7 +57,6 @@ typedef struct __DRIframebufferRec __DRIframebuffer; typedef struct __DRIversionRec __DRIversion; typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods; typedef unsigned long __DRIid; -typedef void __DRInativeDisplay; /*@}*/ @@ -73,7 +72,7 @@ typedef void __DRInativeDisplay; * * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig */ -typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum); +typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRIscreen *screen); /** * Type of a pointer to \c glXGetDriverConfig, as returned by @@ -115,8 +114,8 @@ typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name ); #define __DRI_INTERFACE_VERSION 20070105 -typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn, - __DRIscreen *psc, const __GLcontextModes * modes, +typedef void *(CREATENEWSCREENFUNC)(int scr, __DRIscreen *psc, + const __GLcontextModes * modes, const __DRIversion * ddx_version, const __DRIversion * dri_version, const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer, void * pSAREA, int fd, int internal_api_version, @@ -174,11 +173,6 @@ struct __DRIinterfaceMethodsRec { */ void (*destroyContextModes)( __GLcontextModes * modes ); - /** - * Get the \c __DRIscreen for a given display and screen number. - */ - __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum); - /** * \name Client/server protocol functions. @@ -192,33 +186,31 @@ struct __DRIinterfaceMethodsRec { /** * Create the server-side portion of the GL context. */ - GLboolean (* createContext)( __DRInativeDisplay *dpy, int screenNum, + GLboolean (* createContext)( __DRIscreen *screen, int configID, void * contextID, drm_context_t * hw_context ); /** * Destroy the server-side portion of the GL context. */ - GLboolean (* destroyContext)( __DRInativeDisplay *dpy, int screenNum, - __DRIid context ); + GLboolean (* destroyContext)( __DRIscreen *screen, __DRIid context ); /** * Create the server-side portion of the drawable. */ - GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen, + GLboolean (*createDrawable)( __DRIscreen *screen, __DRIid drawable, drm_drawable_t * hHWDrawable ); /** * Destroy the server-side portion of the drawable. */ - GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen, - __DRIid drawable ); + GLboolean (*destroyDrawable)( __DRIscreen *screen, __DRIid drawable ); /** * This function is used to get information about the position, size, and * clip rects of a drawable. */ - GLboolean (* getDrawableInfo) ( __DRInativeDisplay *dpy, int scrn, - __DRIid draw, unsigned int * index, unsigned int * stamp, + GLboolean (* getDrawableInfo) ( __DRIscreen *screen, __DRIid drawable, + unsigned int * index, unsigned int * stamp, int * x, int * y, int * width, int * height, int * numClipRects, drm_clip_rect_t ** pClipRects, int * backX, int * backY, @@ -242,8 +234,8 @@ struct __DRIinterfaceMethodsRec { * the rate of the "media stream counter". In practical terms, this is * the frame refresh rate of the display. */ - GLboolean (*getMSCRate)(__DRInativeDisplay * dpy, __DRIid drawable, - int32_t * numerator, int32_t * denominator); + GLboolean (*getMSCRate)(__DRIdrawable *draw, + int32_t * numerator, int32_t * denominator); /*@}*/ /** @@ -260,11 +252,10 @@ struct __DRIinterfaceMethodsRec { * drawable was actually done directly to the front buffer (instead * of backing storage, for example) */ - void (*reportDamage)(__DRInativeDisplay * dpy, int screen, - __DRIid drawable, + void (*reportDamage)(__DRIdrawable *draw, int x, int y, drm_clip_rect_t *rects, int num_rects, - int front_buffer); + GLboolean front_buffer); }; @@ -304,13 +295,14 @@ struct __DRIscreenRec { /** * Method to destroy the private DRI screen data. */ - void (*destroyScreen)(__DRInativeDisplay *dpy, int scrn, void *screenPrivate); + void (*destroyScreen)(void *screenPrivate); /** * Method to create the private DRI drawable data and initialize the * drawable dependent methods. */ - void *(*createNewDrawable)(__DRInativeDisplay *dpy, const __GLcontextModes *modes, + void *(*createNewDrawable)(__DRIscreen *screen, + const __GLcontextModes *modes, __DRIid draw, __DRIdrawable *pdraw, int renderType, const int *attrs); @@ -345,13 +337,13 @@ struct __DRIscreenRec { * \since Internal API version 20030815. */ /*@{*/ - void *(*allocateMemory)(__DRInativeDisplay *dpy, int scrn, GLsizei size, + void *(*allocateMemory)(__DRIscreen *screen, GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); - void (*freeMemory)(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer); + void (*freeMemory)(__DRIscreen *screen, GLvoid *pointer); - GLuint (*memoryOffset)(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer); + GLuint (*memoryOffset)(__DRIscreen *screen, const GLvoid *pointer); /*@}*/ /** @@ -360,7 +352,8 @@ struct __DRIscreenRec { * * \since Internal API version 20031201. */ - void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes, + void * (*createNewContext)(__DRIscreen *screen, + const __GLcontextModes *modes, int render_type, void *sharedPrivate, __DRIcontext *pctx); @@ -385,7 +378,7 @@ struct __DRIcontextRec { /** * Method to destroy the private DRI context data. */ - void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate); + void (*destroyContext)(void *contextPrivate); /** * Opaque pointer to private per context direct rendering data. @@ -399,8 +392,7 @@ struct __DRIcontextRec { * * \since Internal API version 20050727. */ - GLboolean (*bindContext)(__DRInativeDisplay *dpy, int scrn, - __DRIdrawable *pdraw, + GLboolean (*bindContext)(__DRIdrawable *pdraw, __DRIdrawable *pread, __DRIcontext *ctx); @@ -409,8 +401,7 @@ struct __DRIcontextRec { * * \since Internal API version 20050727. */ - GLboolean (*unbindContext)(__DRInativeDisplay *dpy, int scrn, - __DRIcontext *ctx); + GLboolean (*unbindContext)(__DRIcontext *ctx); }; /** @@ -423,12 +414,12 @@ struct __DRIdrawableRec { /** * Method to destroy the private DRI drawable data. */ - void (*destroyDrawable)(__DRInativeDisplay *dpy, void *drawablePrivate); + void (*destroyDrawable)(void *drawablePrivate); /** * Method to swap the front and back buffers. */ - void (*swapBuffers)(__DRInativeDisplay *dpy, void *drawablePrivate); + void (*swapBuffers)(void *drawablePrivate); /** * Opaque pointer to private per drawable direct rendering data. @@ -442,14 +433,14 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int (*getSBC)(__DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc ); + int (*getSBC)(void *drawablePrivate, int64_t *sbc ); /** * Wait for the SBC to be greater than or equal target_sbc. * * \since Internal API version 20030317. */ - int (*waitForSBC)( __DRInativeDisplay * dpy, void *drawablePriv, + int (*waitForSBC)( void *drawablePriv, int64_t target_sbc, int64_t * msc, int64_t * sbc ); @@ -461,7 +452,7 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int (*waitForMSC)( __DRInativeDisplay * dpy, void *drawablePriv, + int (*waitForMSC)( void *drawablePriv, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc, int64_t * sbc ); @@ -474,7 +465,7 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int64_t (*swapBuffersMSC)(__DRInativeDisplay *dpy, void *drawablePrivate, + int64_t (*swapBuffersMSC)(void *drawablePrivate, int64_t target_msc, int64_t divisor, int64_t remainder); @@ -483,14 +474,14 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable); + int (*frameTracking)(void *drawablePrivate, GLboolean enable); /** * Retrieve frame usage information. * * \since Internal API version 20030317. */ - int (*queryFrameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, + int (*queryFrameTracking)(void *drawablePrivate, int64_t * sbc, int64_t * missedFrames, float * lastMissedUsage, float * usage ); @@ -507,7 +498,7 @@ struct __DRIdrawableRec { * * \since Internal API version 20060314. */ - void (*copySubBuffer)(__DRInativeDisplay *dpy, void *drawablePrivate, + void (*copySubBuffer)(void *drawablePrivate, int x, int y, int w, int h); }; diff --git a/src/glx/x11/XF86dri.c b/src/glx/x11/XF86dri.c index 721bb3e65a..b44ebaf329 100644 --- a/src/glx/x11/XF86dri.c +++ b/src/glx/x11/XF86dri.c @@ -375,10 +375,9 @@ PUBLIC Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext) context, hHWContext ); } -PUBLIC GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, +PUBLIC GLboolean XF86DRIDestroyContext(Display *dpy, int screen, __DRIid context ) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyContextReq *req; @@ -397,10 +396,9 @@ PUBLIC GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, return True; } -PUBLIC GLboolean XF86DRICreateDrawable( __DRInativeDisplay * ndpy, int screen, +PUBLIC GLboolean XF86DRICreateDrawable(Display *dpy, int screen, __DRIid drawable, drm_drawable_t * hHWDrawable ) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRICreateDrawableReply rep; xXF86DRICreateDrawableReq *req; @@ -432,10 +430,9 @@ static int noopErrorHandler(Display *dpy, XErrorEvent *xerr) return 0; } -PUBLIC GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen, +PUBLIC GLboolean XF86DRIDestroyDrawable(Display *dpy, int screen, __DRIid drawable ) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyDrawableReq *req; int (*oldXErrorHandler)(Display *, XErrorEvent *); diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index 3dbdc306da..7ed4549658 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -72,7 +72,9 @@ #define __GLX_MAX_TEXTURE_UNITS 32 +typedef struct __GLXscreenConfigsRec __GLXscreenConfigs; typedef struct __GLXcontextRec __GLXcontext; +typedef struct __GLXdrawableRec __GLXdrawable; typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate; typedef struct _glapi_table __GLapi; @@ -80,6 +82,9 @@ typedef struct _glapi_table __GLapi; #ifdef GLX_DIRECT_RENDERING +#define containerOf(ptr, type, member) \ + (type *)( (char *)ptr - offsetof(type,member) ) + #include @@ -240,6 +245,7 @@ struct __GLXcontextRec { * Screen number. */ GLint screen; + __GLXscreenConfigs *psc; /** * \c GL_TRUE if the context was created with ImportContext, which @@ -445,7 +451,7 @@ extern void __glFreeAttributeState(__GLXcontext *); * One of these records exists per screen of the display. It contains * a pointer to the config data for that screen (if the screen supports GL). */ -typedef struct __GLXscreenConfigsRec { +struct __GLXscreenConfigsRec { /** * GLX extension string reported by the X-server. */ @@ -463,6 +469,8 @@ typedef struct __GLXscreenConfigsRec { */ __DRIscreen driScreen; __glxHashTable *drawHash; + Display *dpy; + int scr; #endif /** @@ -482,7 +490,7 @@ typedef struct __GLXscreenConfigsRec { GLboolean ext_list_first_time; /*@}*/ -} __GLXscreenConfigs; +}; /** * Per display private data. One of these records exists for each display @@ -535,6 +543,18 @@ struct __GLXdisplayPrivateRec { #endif }; +#ifdef GLX_DIRECT_RENDERING + +struct __GLXdrawableRec { + XID drawable; + __GLXscreenConfigs *psc; + __DRIdrawable driDrawable; +}; + +#endif + + + void __glXFreeContext(__GLXcontext*); extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*); @@ -694,7 +714,7 @@ extern int __glXGetInternalVersion(void); /* Get the unadjusted system time */ extern int __glXGetUST( int64_t * ust ); -extern Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, - int32_t * numerator, int32_t * denominator); +extern GLboolean __glXGetMscRateOML(__DRIdrawable *draw, + int32_t * numerator, int32_t * denominator); #endif /* !__GLX_client_h__ */ diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 0951493726..45ee93c5c3 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -105,7 +105,7 @@ static void GarbageCollectDRIDrawables(Display *dpy, int screen) if (!windowExistsFlag) { /* Destroy the local drawable data, if the drawable no longer exists in the Xserver */ - (*pdraw->destroyDrawable)(dpy, pdraw->private); + (*pdraw->destroyDrawable)(pdraw->private); Xfree(pdraw); } } while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1); @@ -127,7 +127,7 @@ static __DRIdrawable * GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num ) { __GLXdisplayPrivate * const priv = __glXInitialize(dpy); - __DRIdrawable * const pdraw; + __GLXdrawable * const pdraw; const unsigned screen_count = ScreenCount(dpy); unsigned i; __GLXscreenConfigs *sc; @@ -140,7 +140,7 @@ GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num ) if (__glxHashLookup(sc->drawHash, drawable, (void *) &pdraw) == 0) { if (scrn_num != NULL) *scrn_num = i; - return pdraw; + return &pdraw->driDrawable; } } @@ -402,12 +402,14 @@ CreateContext(Display *dpy, XVisualInfo *vis, void * const shared = (shareList != NULL) ? shareList->driContext.private : NULL; gc->driContext.private = - (*psc->driScreen.createNewContext)( dpy, mode, renderType, + (*psc->driScreen.createNewContext)( &psc->driScreen, + mode, renderType, shared, &gc->driContext ); if (gc->driContext.private) { gc->isDirect = GL_TRUE; gc->screen = mode->screen; + gc->psc = psc; gc->vid = mode->visualID; gc->fbconfigID = mode->fbconfigID; gc->mode = mode; @@ -520,8 +522,7 @@ DestroyContext(Display *dpy, GLXContext gc) /* Destroy the direct rendering context */ if (gc->isDirect) { if (gc->driContext.private) { - (*gc->driContext.destroyContext)(dpy, gc->screen, - gc->driContext.private); + (*gc->driContext.destroyContext)(gc->driContext.private); gc->driContext.private = NULL; } GarbageCollectDRIDrawables(dpy, gc->screen); @@ -849,7 +850,7 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, NULL ); if ( pdraw != NULL ) { - (*pdraw->swapBuffers)(dpy, pdraw->private); + (*pdraw->swapBuffers)(pdraw->private); return; } #endif @@ -1835,7 +1836,7 @@ static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable) if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking( dpy, pdraw->private, GL_TRUE ); + status = pdraw->frameTracking( pdraw->private, GL_TRUE ); } #else (void) dpy; @@ -1855,7 +1856,7 @@ static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable) if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking( dpy, pdraw->private, GL_FALSE ); + status = pdraw->frameTracking( pdraw->private, GL_FALSE ); } #else (void) dpy; @@ -1879,7 +1880,7 @@ static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, int64_t sbc, missedFrames; float lastMissedUsage; - status = pdraw->queryFrameTracking( dpy, pdraw->private, &sbc, + status = pdraw->queryFrameTracking( pdraw->private, &sbc, &missedFrames, &lastMissedUsage, usage ); } @@ -1906,7 +1907,7 @@ static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { float usage; - status = pdraw->queryFrameTracking( dpy, pdraw->private, sbc, + status = pdraw->queryFrameTracking( pdraw->private, sbc, missedFrames, lastMissedUsage, & usage ); } @@ -1973,7 +1974,7 @@ static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count int64_t msc; int64_t sbc; - ret = (*pdraw->waitForMSC)( gc->currentDpy, pdraw->private, + ret = (*pdraw->waitForMSC)( pdraw->private, 0, divisor, remainder, & msc, & sbc ); *count = (unsigned) msc; @@ -2142,7 +2143,7 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) && ((*psc->driScreen.getMSC)( psc->driScreen.private, msc ) == 0) - && ((*pdraw->getSBC)( dpy, psc->driScreen.private, sbc ) == 0) + && ((*pdraw->getSBC)( psc->driScreen.private, sbc ) == 0) && (__glXGetUST( ust ) == 0) ); } #else @@ -2172,24 +2173,25 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, * when GLX_OML_sync_control appears in the client extension string. */ -Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, - int32_t * numerator, int32_t * denominator) +GLboolean __glXGetMscRateOML(__DRIdrawable *draw, + int32_t * numerator, int32_t * denominator) { #if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE ) + __GLXdrawable *glxDraw = + containerOf(draw, __GLXdrawable, driDrawable); + __GLXscreenConfigs *psc = glxDraw->psc; + Display *dpy = psc->dpy; __GLXdisplayPrivate * const priv = __glXInitialize(dpy); if ( priv != NULL ) { XF86VidModeModeLine mode_line; int dot_clock; - int screen_num; int i; - if (GetDRIDrawable( dpy, drawable, & screen_num) != NULL - && XF86VidModeQueryVersion( dpy, & i, & i ) - && XF86VidModeGetModeLine( dpy, screen_num, & dot_clock, - & mode_line ) ) { + if (XF86VidModeQueryVersion( dpy, & i, & i ) && + XF86VidModeGetModeLine(dpy, psc->scr, &dot_clock, &mode_line) ) { unsigned n = dot_clock * 1000; unsigned d = mode_line.vtotal * mode_line.htotal; @@ -2231,13 +2233,11 @@ Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, *numerator = n; *denominator = d; - (void) drawable; return True; } } #else - (void) dpy; - (void) drawable; + (void) draw; (void) numerator; (void) denominator; #endif @@ -2266,7 +2266,7 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable, if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - return (*pdraw->swapBuffersMSC)(dpy, pdraw->private, target_msc, + return (*pdraw->swapBuffersMSC)(pdraw->private, target_msc, divisor, remainder); } #else @@ -2301,7 +2301,7 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable, if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - ret = (*pdraw->waitForMSC)( dpy, pdraw->private, target_msc, + ret = (*pdraw->waitForMSC)( pdraw->private, target_msc, divisor, remainder, msc, sbc ); /* __glXGetUST returns zero on success and non-zero on failure. @@ -2341,7 +2341,7 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) { - ret = (*pdraw->waitForSBC)( dpy, pdraw->private, target_sbc, msc, sbc ); + ret = (*pdraw->waitForSBC)( pdraw->private, target_sbc, msc, sbc ); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. @@ -2374,7 +2374,7 @@ PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn, if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) { if (psc && psc->driScreen.private && psc->driScreen.allocateMemory) { - return (*psc->driScreen.allocateMemory)( dpy, scrn, size, + return (*psc->driScreen.allocateMemory)( &psc->driScreen, size, readFreq, writeFreq, priority ); } @@ -2399,7 +2399,7 @@ PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer) if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) { if (psc && psc->driScreen.private && psc->driScreen.freeMemory) { - (*psc->driScreen.freeMemory)( dpy, scrn, pointer ); + (*psc->driScreen.freeMemory)( &psc->driScreen, pointer ); } } #else @@ -2418,7 +2418,7 @@ PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn, if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) { if (psc && psc->driScreen.private && psc->driScreen.memoryOffset) { - return (*psc->driScreen.memoryOffset)( dpy, scrn, pointer ); + return (*psc->driScreen.memoryOffset)( &psc->driScreen, pointer ); } } #else @@ -2499,7 +2499,7 @@ static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, if ( pdraw != NULL ) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); if ( __glXExtensionBitIsEnabled( psc, MESA_copy_sub_buffer_bit ) ) { - (*pdraw->copySubBuffer)(dpy, pdraw->private, x, y, width, height); + (*pdraw->copySubBuffer)(pdraw->private, x, y, width, height); } return; diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 7f0428c0a9..2ff73685e3 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -109,10 +109,6 @@ static int _mesa_sparc_needs_init = 1; #define INIT_MESA_SPARC #endif -#ifdef GLX_DIRECT_RENDERING -static __DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn); -#endif /* GLX_DIRECT_RENDERING */ - static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext gc); @@ -364,8 +360,7 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv) #ifdef GLX_DIRECT_RENDERING /* Free the direct rendering per screen data */ if (psc->driScreen.private) - (*psc->driScreen.destroyScreen)(priv->dpy, i, - psc->driScreen.private); + (*psc->driScreen.destroyScreen)(psc->driScreen.private); psc->driScreen.private = NULL; __glxHashDestroy(psc->drawHash); #endif @@ -710,7 +705,7 @@ static __DRIfuncPtr get_proc_address( const char * proc_name ) } #ifdef XDAMAGE_1_1_INTERFACE -static GLboolean has_damage_post(__DRInativeDisplay *dpy) +static GLboolean has_damage_post(Display *dpy) { static GLboolean inited = GL_FALSE; static GLboolean has_damage; @@ -732,8 +727,7 @@ static GLboolean has_damage_post(__DRInativeDisplay *dpy) } #endif /* XDAMAGE_1_1_INTERFACE */ -static void __glXReportDamage(__DRInativeDisplay *dpy, int screen, - __DRIid drawable, +static void __glXReportDamage(__DRIdrawable *driDraw, int x, int y, drm_clip_rect_t *rects, int num_rects, GLboolean front_buffer) @@ -743,6 +737,11 @@ static void __glXReportDamage(__DRInativeDisplay *dpy, int screen, 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; @@ -750,10 +749,11 @@ static void __glXReportDamage(__DRInativeDisplay *dpy, int screen, if (front_buffer) { x_off = x; y_off = y; - drawable = RootWindow(dpy, screen); + drawable = RootWindow(dpy, psc->scr); } else{ x_off = 0; y_off = 0; + drawable = glxDraw->drawable; } xrects = malloc(sizeof(XRectangle) * num_rects); @@ -773,6 +773,69 @@ static void __glXReportDamage(__DRInativeDisplay *dpy, int screen, #endif } +static GLboolean +__glXDRICreateContext(__DRIscreen *screen, int configID, + void *pid, drm_context_t *hHWContext) +{ + __GLXscreenConfigs *psc = + containerOf(screen, __GLXscreenConfigs, driScreen); + Display *dpy = psc->dpy; + + return XF86DRICreateContextWithConfig(dpy, psc->scr, + configID, pid, hHWContext); +} + +static GLboolean +__glXDRIDestroyContext(__DRIscreen *screen, __DRIid context_id) +{ + __GLXscreenConfigs *psc = + containerOf(screen, __GLXscreenConfigs, driScreen); + Display *dpy = psc->dpy; + + return XF86DRIDestroyContext(dpy, psc->scr, context_id); +} + +static GLboolean +__glXDRICreateDrawable( __DRIscreen *screen, + __DRIid drawable, drm_drawable_t *hHWDrawable ) +{ + __GLXscreenConfigs *psc = + containerOf(screen, __GLXscreenConfigs, driScreen); + Display *dpy = psc->dpy; + + return XF86DRICreateDrawable(dpy, psc->scr, drawable, hHWDrawable); +} + +static GLboolean +__glXDRIDestroyDrawable(__DRIscreen *screen, __DRIid drawable) +{ + __GLXscreenConfigs *psc = + containerOf(screen, __GLXscreenConfigs, driScreen); + Display *dpy = psc->dpy; + + return XF86DRIDestroyDrawable(dpy, psc->scr, drawable); +} + +static GLboolean +__glXDRIGetDrawableInfo(__DRIscreen *screen, __DRIid 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) +{ + __GLXscreenConfigs *psc = + containerOf(screen, __GLXscreenConfigs, driScreen); + Display *dpy = psc->dpy; + + return XF86DRIGetDrawableInfo(dpy, psc->scr, drawable, + index, stamp, X, Y, W, H, + numClipRects, pClipRects, + backX, backY, + numBackClipRects, pBackClipRects); +} + + /** * Table of functions exported by the loader to the driver. */ @@ -782,14 +845,12 @@ static const __DRIinterfaceMethods interface_methods = { _gl_context_modes_create, _gl_context_modes_destroy, - __glXFindDRIScreen, - - XF86DRICreateContextWithConfig, - XF86DRIDestroyContext, + __glXDRICreateContext, + __glXDRIDestroyContext, - XF86DRICreateDrawable, - XF86DRIDestroyDrawable, - XF86DRIGetDrawableInfo, + __glXDRICreateDrawable, + __glXDRIDestroyDrawable, + __glXDRIGetDrawableInfo, __glXGetUST, __glXGetMscRateOML, @@ -941,7 +1002,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc, err_msg = "InitDriver"; err_extra = NULL; - psp = (*createNewScreen)(dpy, scrn, + psp = (*createNewScreen)(scrn, &psc->driScreen, psc->configs, & ddx_version, @@ -1169,6 +1230,8 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv) UnlockDisplay(dpy); #ifdef GLX_DIRECT_RENDERING + psc->scr = i; + psc->dpy = dpy; /* Create drawable hash */ psc->drawHash = __glxHashCreate(); if ( psc->drawHash == NULL ) { @@ -1512,33 +1575,6 @@ PUBLIC GLXDrawable glXGetCurrentDrawable(void) } -/************************************************************************/ - -#ifdef GLX_DIRECT_RENDERING -/* Return the DRI per screen structure */ -__DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn) -{ - __DRIscreen *pDRIScreen = NULL; - XExtDisplayInfo *info = __glXFindDisplay(dpy); - XExtData **privList, *found; - __GLXdisplayPrivate *dpyPriv; - XEDataObject dataObj; - - __glXLock(); - dataObj.display = dpy; - privList = XEHeadOfExtensionList(dataObj); - found = XFindOnExtensionList(privList, info->codes->extension); - __glXUnlock(); - - if (found) { - dpyPriv = (__GLXdisplayPrivate *)found->private_data; - pDRIScreen = &dpyPriv->screenConfigs[scrn].driScreen; - } - - return pDRIScreen; -} -#endif - /************************************************************************/ static Bool SendMakeCurrentRequest( Display *dpy, CARD8 opcode, @@ -1629,7 +1665,7 @@ static __DRIdrawable * FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc) { __GLXdisplayPrivate * const priv = __glXInitialize(dpy); - __DRIdrawable *pdraw; + __GLXdrawable *pdraw; __GLXscreenConfigs *sc; void *empty_attribute_list = NULL; @@ -1638,34 +1674,37 @@ FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc) sc = &priv->screenConfigs[gc->screen]; if (__glxHashLookup(sc->drawHash, drawable, (void *) &pdraw) == 0) - return pdraw; + return &pdraw->driDrawable; /* Allocate a new drawable */ - pdraw = (__DRIdrawable *)Xmalloc(sizeof(__DRIdrawable)); + pdraw = Xmalloc(sizeof(*pdraw)); if (!pdraw) return NULL; + pdraw->drawable = drawable; + pdraw->psc = sc; + /* Create a new drawable */ - pdraw->private = - (*sc->driScreen.createNewDrawable)(dpy, + pdraw->driDrawable.private = + (*sc->driScreen.createNewDrawable)(&sc->driScreen, gc->mode, - drawable, pdraw, + drawable, &pdraw->driDrawable, GLX_WINDOW_BIT, empty_attribute_list); - if (!pdraw->private) { + if (!pdraw->driDrawable.private) { /* ERROR!!! */ Xfree(pdraw); return NULL; } if (__glxHashInsert(sc->drawHash, drawable, pdraw)) { - (*pdraw->destroyDrawable)(dpy, pdraw->private); + (*pdraw->driDrawable.destroyDrawable)(pdraw->driDrawable.private); Xfree(pdraw); return NULL; } - return pdraw; + return &pdraw->driDrawable; } static Bool BindContextWrapper( Display *dpy, GLXContext gc, @@ -1674,15 +1713,13 @@ static Bool BindContextWrapper( Display *dpy, GLXContext gc, __DRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc); __DRIdrawable *pread = FetchDRIDrawable(dpy, read, gc); - return (*gc->driContext.bindContext)(dpy, gc->screen, pdraw, pread, - & gc->driContext); + return (*gc->driContext.bindContext)(pdraw, pread, &gc->driContext); } static Bool UnbindContextWrapper( GLXContext gc ) { - return (*gc->driContext.unbindContext)(gc->currentDpy, gc->screen, - &gc->driContext ); + return (*gc->driContext.unbindContext)(&gc->driContext); } #endif /* GLX_DIRECT_RENDERING */ @@ -1794,7 +1831,7 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw, if (oldGC->isDirect) { if (oldGC->driContext.private) { (*oldGC->driContext.destroyContext) - (dpy, oldGC->screen, oldGC->driContext.private); + (oldGC->driContext.private); oldGC->driContext.private = NULL; } } diff --git a/src/glx/x11/xf86dri.h b/src/glx/x11/xf86dri.h index 0a2bb24971..ddac7db266 100644 --- a/src/glx/x11/xf86dri.h +++ b/src/glx/x11/xf86dri.h @@ -94,13 +94,13 @@ Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual, Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID, XID *ptr_to_returned_context_id, drm_context_t *hHWContext ); -extern GLboolean XF86DRIDestroyContext( __DRInativeDisplay *dpy, int screen, +extern GLboolean XF86DRIDestroyContext( Display *dpy, int screen, __DRIid context_id ); -extern GLboolean XF86DRICreateDrawable( __DRInativeDisplay *dpy, int screen, +extern GLboolean XF86DRICreateDrawable( Display *dpy, int screen, __DRIid drawable, drm_drawable_t *hHWDrawable ); -extern GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay *dpy, int screen, +extern GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen, __DRIid drawable); Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable, diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 1f916a82ca..2b5d6f0a59 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -33,7 +33,7 @@ #include "drm_sarea.h" #ifndef GLX_OML_sync_control -typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRInativeDisplay *dpy, __DRIid drawable, int32_t *numerator, int32_t *denominator); +typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t *numerator, int32_t *denominator); #endif /* This pointer *must* be set by the driver's __driCreateNewScreen funciton! @@ -53,16 +53,16 @@ static const int empty_attribute_list[1] = { None }; static int api_ver = 0; /* forward declarations */ -static int driQueryFrameTracking( __DRInativeDisplay *dpy, void *priv, +static int driQueryFrameTracking( void *priv, int64_t *sbc, int64_t *missedFrames, float *lastMissedUsage, float *usage ); -static void *driCreateNewDrawable(__DRInativeDisplay *dpy, - const __GLcontextModes *modes, +static void *driCreateNewDrawable(__DRIscreen *screen, + const __GLcontextModes *modes, __DRIid draw, __DRIdrawable *pdraw, int renderType, const int *attrs); -static void driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate); +static void driDestroyDrawable(void *drawablePrivate); /** @@ -96,8 +96,7 @@ __driUtilMessage(const char *f, ...) /** * Unbind context. * - * \param dpy the display handle. - * \param scrn the screen number. + * \param scrn the screen. * \param gc context. * * \return \c GL_TRUE on success, or \c GL_FALSE on failure. @@ -110,10 +109,8 @@ __driUtilMessage(const char *f, ...) * While casting the opaque private pointers associated with the parameters * into their respective real types it also assures they are not \c NULL. */ -static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, - __DRIcontext *ctx) +static GLboolean driUnbindContext(__DRIcontext *ctx) { - __DRIscreen *pDRIScreen; __DRIcontextPrivate *pcp; __DRIscreenPrivate *psp; __DRIdrawablePrivate *pdp; @@ -124,19 +121,11 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, ** calling driUnbindContext. */ - if (ctx == NULL) { - /* ERROR!!! */ - return GL_FALSE; - } + if (ctx == NULL) + return GL_FALSE; - pDRIScreen = (*dri_interface->getScreen)(dpy, scrn); - if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { - /* ERROR!!! */ - return GL_FALSE; - } - - psp = (__DRIscreenPrivate *)pDRIScreen->private; pcp = (__DRIcontextPrivate *)ctx->private; + psp = (__DRIscreenPrivate *)pcp->driScreenPriv; pdp = (__DRIdrawablePrivate *)pcp->driDrawablePriv; prp = (__DRIdrawablePrivate *)pcp->driReadablePriv; @@ -179,16 +168,14 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn, * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent * function. */ -static GLboolean DoBindContext(__DRInativeDisplay *dpy, - __DRIdrawable *pdraw, +static GLboolean DoBindContext(__DRIdrawable *pdraw, __DRIdrawable *pread, - __DRIcontext *ctx, - __DRIscreenPrivate *psp) + __DRIcontext *ctx) { __DRIdrawablePrivate *pdp; __DRIdrawablePrivate *prp; __DRIcontextPrivate * const pcp = ctx->private; - + __DRIscreenPrivate *psp = pcp->driScreenPriv; pdp = (__DRIdrawablePrivate *) pdraw->private; prp = (__DRIdrawablePrivate *) pread->private; @@ -230,31 +217,19 @@ static GLboolean DoBindContext(__DRInativeDisplay *dpy, * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent * function. */ -static GLboolean driBindContext(__DRInativeDisplay *dpy, int scrn, - __DRIdrawable *pdraw, +static GLboolean driBindContext(__DRIdrawable *pdraw, __DRIdrawable *pread, __DRIcontext * ctx) { - __DRIscreen *pDRIScreen; - /* ** Assume error checking is done properly in glXMakeCurrent before ** calling driBindContext. */ - if (ctx == NULL || pdraw == None || pread == None) { - /* ERROR!!! */ - return GL_FALSE; - } - - pDRIScreen = (*dri_interface->getScreen)(dpy, scrn); - if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { - /* ERROR!!! */ + if (ctx == NULL || pdraw == None || pread == None) return GL_FALSE; - } - return DoBindContext( dpy, pdraw, pread, ctx, - (__DRIscreenPrivate *)pDRIScreen->private ); + return DoBindContext( pdraw, pread, ctx ); } /*@}*/ @@ -311,7 +286,7 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - if (! (*dri_interface->getDrawableInfo)(pdp->display, pdp->screen, pdp->draw, + if (! (*dri_interface->getDrawableInfo)(pdp->driScreenPriv->psc, pdp->draw, &pdp->index, &pdp->lastStamp, &pdp->x, &pdp->y, &pdp->w, &pdp->h, &pdp->numClipRects, &pdp->pClipRects, @@ -345,7 +320,6 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) /** * Swap buffers. * - * \param dpy the display handle. * \param drawablePrivate opaque pointer to the per-drawable private info. * * \internal @@ -353,7 +327,7 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) * * Is called directly from glXSwapBuffers(). */ -static void driSwapBuffers( __DRInativeDisplay *dpy, void *drawablePrivate ) +static void driSwapBuffers(void *drawablePrivate) { __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; drm_clip_rect_t rect; @@ -374,8 +348,7 @@ static void driSwapBuffers( __DRInativeDisplay *dpy, void *drawablePrivate ) * front buffer, so we report the damage there rather than to the backing * store (if any). */ - (*dri_interface->reportDamage)(dpy, dPriv->screen, dPriv->draw, - dPriv->x, dPriv->y, + (*dri_interface->reportDamage)(dPriv->pdraw, dPriv->x, dPriv->y, &rect, 1, GL_TRUE); } @@ -392,7 +365,7 @@ static int driGetMSC( void *screenPrivate, int64_t *msc ) /** * Called directly from a number of higher-level GLX functions. */ -static int driGetSBC( __DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc ) +static int driGetSBC( void *drawablePrivate, int64_t *sbc ) { __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; __DRIswapInfo sInfo; @@ -405,8 +378,7 @@ static int driGetSBC( __DRInativeDisplay *dpy, void *drawablePrivate, int64_t *s return status; } -static int driWaitForSBC( __DRInativeDisplay * dpy, void *drawablePriv, - int64_t target_sbc, +static int driWaitForSBC( void *drawablePriv, int64_t target_sbc, int64_t * msc, int64_t * sbc ) { __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv; @@ -415,8 +387,7 @@ static int driWaitForSBC( __DRInativeDisplay * dpy, void *drawablePriv, msc, sbc ); } -static int driWaitForMSC( __DRInativeDisplay * dpy, void *drawablePriv, - int64_t target_msc, +static int driWaitForMSC( void *drawablePriv, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc, int64_t * sbc ) { @@ -442,8 +413,7 @@ static int driWaitForMSC( __DRInativeDisplay * dpy, void *drawablePriv, return status; } -static int64_t driSwapBuffersMSC( __DRInativeDisplay * dpy, void *drawablePriv, - int64_t target_msc, +static int64_t driSwapBuffersMSC( void *drawablePriv, int64_t target_msc, int64_t divisor, int64_t remainder ) { __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv; @@ -453,25 +423,23 @@ static int64_t driSwapBuffersMSC( __DRInativeDisplay * dpy, void *drawablePriv, remainder ); } -static void driCopySubBuffer( __DRInativeDisplay *dpy, void *drawablePrivate, +static void driCopySubBuffer( void *drawablePrivate, int x, int y, int w, int h) { __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h); - (void) dpy; } /** * This is called via __DRIscreenRec's createNewDrawable pointer. */ -static void *driCreateNewDrawable(__DRInativeDisplay *dpy, +static void *driCreateNewDrawable(__DRIscreen *screen, const __GLcontextModes *modes, __DRIid draw, __DRIdrawable *pdraw, int renderType, const int *attrs) { - __DRIscreen * const pDRIScreen = (*dri_interface->getScreen)(dpy, modes->screen); __DRIscreenPrivate *psp; __DRIdrawablePrivate *pdp; @@ -483,16 +451,14 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy, */ (void) attrs; - if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { - return NULL; - } - pdp = (__DRIdrawablePrivate *)_mesa_malloc(sizeof(__DRIdrawablePrivate)); if (!pdp) { return NULL; } - if (!(*dri_interface->createDrawable)(dpy, modes->screen, draw, &pdp->hHWDrawable)) { + /* Ensure that modes->screen and screen are the same screen? */ + + if (!(*dri_interface->createDrawable)(screen, draw, &pdp->hHWDrawable)) { _mesa_free(pdp); return NULL; } @@ -511,16 +477,14 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy, pdp->numBackClipRects = 0; pdp->pClipRects = NULL; pdp->pBackClipRects = NULL; - pdp->display = dpy; - pdp->screen = modes->screen; - psp = (__DRIscreenPrivate *)pDRIScreen->private; + psp = (__DRIscreenPrivate *)screen->private; pdp->driScreenPriv = psp; pdp->driContextPriv = &psp->dummyContextPriv; if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, modes, renderType == GLX_PIXMAP_BIT)) { - (void)(*dri_interface->destroyDrawable)(dpy, modes->screen, pdp->draw); + (void)(*dri_interface->destroyDrawable)(screen, pdp->draw); _mesa_free(pdp); return NULL; } @@ -551,17 +515,15 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy, } static void -driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate) +driDestroyDrawable(void *drawablePrivate) { __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *) drawablePrivate; __DRIscreenPrivate *psp; - int scrn; if (pdp) { psp = pdp->driScreenPriv; - scrn = psp->myNum; (*psp->DriverAPI.DestroyBuffer)(pdp); - (void)(*dri_interface->destroyDrawable)(dpy, scrn, pdp->draw); + (void)(*dri_interface->destroyDrawable)(psp->psc, pdp->draw); if (pdp->pClipRects) { _mesa_free(pdp->pClipRects); pdp->pClipRects = NULL; @@ -585,8 +547,6 @@ driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate) /** * Destroy the per-context private information. * - * \param dpy the display handle. - * \param scrn the screen number. * \param contextPrivate opaque pointer to the per-drawable private info. * * \internal @@ -594,13 +554,14 @@ driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate) * drmDestroyContext(), and finally frees \p contextPrivate. */ static void -driDestroyContext(__DRInativeDisplay *dpy, int scrn, void *contextPrivate) +driDestroyContext(void *contextPrivate) { __DRIcontextPrivate *pcp = (__DRIcontextPrivate *) contextPrivate; if (pcp) { (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp); - (void) (*dri_interface->destroyContext)(dpy, scrn, pcp->contextID); + (void) (*dri_interface->destroyContext)(pcp->driScreenPriv->psc, + pcp->contextID); _mesa_free(pcp); } } @@ -628,35 +589,27 @@ driDestroyContext(__DRInativeDisplay *dpy, int scrn, void *contextPrivate) * */ static void * -driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes, +driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, int render_type, void *sharedPrivate, __DRIcontext *pctx) { - __DRIscreen *pDRIScreen; __DRIcontextPrivate *pcp; __DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate; __DRIscreenPrivate *psp; void * const shareCtx = (pshare != NULL) ? pshare->driverPrivate : NULL; - pDRIScreen = (*dri_interface->getScreen)(dpy, modes->screen); - if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { - /* ERROR!!! */ - return NULL; - } - - psp = (__DRIscreenPrivate *)pDRIScreen->private; + psp = (__DRIscreenPrivate *)screen->private; pcp = (__DRIcontextPrivate *)_mesa_malloc(sizeof(__DRIcontextPrivate)); if (!pcp) { return NULL; } - if (! (*dri_interface->createContext)(dpy, modes->screen, modes->fbconfigID, - &pcp->contextID, &pcp->hHWContext)) { + if (! (*dri_interface->createContext)(screen, modes->fbconfigID, + &pcp->contextID, &pcp->hHWContext)) { _mesa_free(pcp); return NULL; } - pcp->display = dpy; pcp->driScreenPriv = psp; pcp->driDrawablePriv = NULL; @@ -678,8 +631,7 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes, pctx->unbindContext = driUnbindContext; if ( !(*psp->DriverAPI.CreateContext)(modes, pcp, shareCtx) ) { - (void) (*dri_interface->destroyContext)(dpy, modes->screen, - pcp->contextID); + (void) (*dri_interface->destroyContext)(screen, pcp->contextID); _mesa_free(pcp); return NULL; } @@ -705,7 +657,7 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes, * This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls * drmClose(), and finally frees \p screenPrivate. */ -static void driDestroyScreen(__DRInativeDisplay *dpy, int scrn, void *screenPrivate) +static void driDestroyScreen(void *screenPrivate) { __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate; @@ -760,7 +712,7 @@ static void driDestroyScreen(__DRInativeDisplay *dpy, int scrn, void *screenPriv * loader that is too old to even load this driver. */ __DRIscreenPrivate * -__driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, +__driUtilCreateNewScreen(int scr, __DRIscreen *psc, __GLcontextModes * modes, const __DRIversion * ddx_version, const __DRIversion * dri_version, @@ -781,8 +733,6 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, return NULL; } - psp->display = dpy; - psp->myNum = scrn; psp->psc = psc; psp->modes = modes; @@ -818,6 +768,7 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, psp->fbBPP = psp->fbStride * 8 / frame_buffer->width; psp->fd = fd; + psp->myNum = scr; /* ** Do not init dummy context here; actual initialization will be @@ -873,7 +824,7 @@ int driCompareGLXAPIVersion( GLint required_version ) static int -driQueryFrameTracking( __DRInativeDisplay * dpy, void * priv, +driQueryFrameTracking( void * priv, int64_t * sbc, int64_t * missedFrames, float * lastMissedUsage, float * usage ) { @@ -935,7 +886,7 @@ driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust, float usage = 1.0; - if ( (*dri_interface->getMSCRate)( dPriv->display, dPriv->draw, &n, &d ) ) { + if ( (*dri_interface->getMSCRate)(dPriv->pdraw, &n, &d) ) { interval = (dPriv->pdraw->swap_interval != 0) ? dPriv->pdraw->swap_interval : 1; diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index a08eab1616..cae170c5f8 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -317,17 +317,6 @@ struct __DRIdrawablePrivateRec { */ __DRIscreenPrivate *driScreenPriv; - /** - * \name Display and screen information. - * - * Basically just need these for when the locking code needs to call - * \c __driUtilUpdateDrawableInfo. - */ - /*@{*/ - __DRInativeDisplay *display; - int screen; - /*@}*/ - /** * Called via glXSwapBuffers(). */ @@ -354,9 +343,9 @@ struct __DRIcontextPrivateRec { void *driverPrivate; /** - * This context's display pointer. + * Pointer back to the \c __DRIcontext that contains this structure. */ - __DRInativeDisplay *display; + __DRIcontext *pctx; /** * Pointer to drawable currently bound to this context for drawing. @@ -378,11 +367,6 @@ struct __DRIcontextPrivateRec { * Per-screen private driver information. */ struct __DRIscreenPrivateRec { - /** - * Display for this screen - */ - __DRInativeDisplay *display; - /** * Current screen's number */ @@ -535,8 +519,8 @@ extern void __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp); -extern __DRIscreenPrivate * __driUtilCreateNewScreen( __DRInativeDisplay *dpy, - int scrn, __DRIscreen *psc, __GLcontextModes * modes, +extern __DRIscreenPrivate * __driUtilCreateNewScreen( int scr, __DRIscreen *psc, + __GLcontextModes * modes, const __DRIversion * ddx_version, const __DRIversion * dri_version, const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer, drm_sarea_t *pSAREA, int fd, int internal_api_version, diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c index 4c5323d230..4cd5b9a208 100644 --- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c +++ b/src/mesa/drivers/dri/ffb/ffb_xmesa.c @@ -714,16 +714,16 @@ ffbFillInModes( unsigned pixel_bits, unsigned depth_bits, * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; @@ -740,7 +740,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &ffbAPI); diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c index c0a7cdb90a..b04bc38327 100644 --- a/src/mesa/drivers/dri/i810/i810screen.c +++ b/src/mesa/drivers/dri/i810/i810screen.c @@ -431,17 +431,16 @@ static const struct __DriverAPIRec i810API = { * failure. */ PUBLIC -void * __driCreateNewScreen_20070105( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) - +void *__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 0, 0 }; @@ -457,7 +456,7 @@ void * __driCreateNewScreen_20070105( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &i810API); diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 2721a90094..7a11672a8f 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -886,18 +886,18 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits, * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on * failure. */ -PUBLIC void * -__driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn, - __DRIscreen * psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) +PUBLIC +void * __DRI_CREATE_NEW_SCREEN(int scrn, + __DRIscreen * psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 5, 0 }; @@ -913,11 +913,10 @@ __driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn, return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &intelAPI); - + psp = __driUtilCreateNewScreen(scrn, psc, NULL, + ddx_version, dri_version, drm_version, + frame_buffer, pSAREA, fd, + internal_api_version, &intelAPI); if (psp != NULL) { I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv; *driver_modes = intelFillInModes(dri_priv->cpp * 8, diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 5dac50df32..29ea07d78e 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -650,16 +650,16 @@ intelFillInModes( unsigned pixel_bits, unsigned depth_bits, * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes ) { __DRIscreenPrivate *psp; @@ -676,7 +676,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &intelAPI); diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index 4e9e216e7d..52b96bf0bc 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -505,16 +505,16 @@ static struct __DriverAPIRec mach64API = { * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; @@ -531,7 +531,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &mach64API); diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index f4e651afa0..372d2ce433 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -963,16 +963,16 @@ static const struct __DriverAPIRec mgaAPI = { * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; @@ -989,7 +989,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &mgaAPI); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 065aa81746..cab53f41ad 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -295,16 +295,16 @@ nouveauFillInModes( unsigned pixel_bits, unsigned depth_bits, * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; @@ -331,7 +331,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &nouveauAPI); diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 880dee85c2..a84b54924a 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -514,16 +514,16 @@ r128FillInModes( unsigned pixel_bits, unsigned depth_bits, * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; @@ -541,7 +541,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &r128API); diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.c b/src/mesa/drivers/dri/r200/r200_ioctl.c index 2366bde525..c9c5a86172 100644 --- a/src/mesa/drivers/dri/r200/r200_ioctl.c +++ b/src/mesa/drivers/dri/r200/r200_ioctl.c @@ -857,7 +857,7 @@ void r200Finish( GLcontext *ctx ) * the kernel data structures, and the current context to get the * device fd. */ -void *r200AllocateMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLsizei size, +void *r200AllocateMemoryMESA(__DRIscreen *screen, GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority) { @@ -899,7 +899,7 @@ void *r200AllocateMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLsizei size, /* Called via glXFreeMemoryMESA() */ -void r200FreeMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer) +void r200FreeMemoryMESA(__DRIscreen *screen, GLvoid *pointer) { GET_CURRENT_CONTEXT(ctx); r200ContextPtr rmesa; @@ -936,7 +936,7 @@ void r200FreeMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer) } /* Called via glXGetMemoryOffsetMESA() */ -GLuint r200GetMemoryOffsetMESA(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer) +GLuint r200GetMemoryOffsetMESA(__DRIscreen *screen, const GLvoid *pointer) { GET_CURRENT_CONTEXT(ctx); r200ContextPtr rmesa; diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.h b/src/mesa/drivers/dri/r200/r200_ioctl.h index 5ed1555f6a..bf12679947 100644 --- a/src/mesa/drivers/dri/r200/r200_ioctl.h +++ b/src/mesa/drivers/dri/r200/r200_ioctl.h @@ -98,10 +98,10 @@ extern void r200WaitForIdleLocked( r200ContextPtr rmesa ); extern void r200WaitForVBlank( r200ContextPtr rmesa ); extern void r200InitIoctlFuncs( struct dd_function_table *functions ); -extern void *r200AllocateMemoryMESA( __DRInativeDisplay *dpy, int scrn, GLsizei size, GLfloat readfreq, +extern void *r200AllocateMemoryMESA( __DRIscreen *screen, GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority ); -extern void r200FreeMemoryMESA( __DRInativeDisplay *dpy, int scrn, GLvoid *pointer ); -extern GLuint r200GetMemoryOffsetMESA( __DRInativeDisplay *dpy, int scrn, const GLvoid *pointer ); +extern void r200FreeMemoryMESA( __DRIscreen *screen, GLvoid *pointer ); +extern GLuint r200GetMemoryOffsetMESA( __DRIscreen *screen, const GLvoid *pointer ); extern GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer, GLint size ); diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 682cf3a5ee..2d44532a84 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -990,17 +990,16 @@ static const struct __DriverAPIRec r200API = { * failure. */ PUBLIC void * -__driCreateNewScreen_20050727( __DRInativeDisplay *dpy, - int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; #if !RADEON_COMMON @@ -1029,12 +1028,12 @@ __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, return NULL; } #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)) - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &radeonAPI); #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &r200API); diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index 43422db9a8..e8a63ae51b 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -1027,16 +1027,16 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits, * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes ) { __DRIscreenPrivate *psp; @@ -1053,7 +1053,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &savageAPI); diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c index 89d734ba78..a1275f0026 100644 --- a/src/mesa/drivers/dri/sis/sis_screen.c +++ b/src/mesa/drivers/dri/sis/sis_screen.c @@ -333,17 +333,16 @@ static struct __DriverAPIRec sisAPI = { * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, - __DRIscreen *psc, - const __GLcontextModes *modes, - const __DRIversion *ddx_version, - const __DRIversion *dri_version, - const __DRIversion *drm_version, - const __DRIframebuffer *frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes **driver_modes ) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes *modes, + const __DRIversion *ddx_version, + const __DRIversion *dri_version, + const __DRIversion *drm_version, + const __DRIframebuffer *frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes **driver_modes) { __DRIscreenPrivate *psp; @@ -359,7 +358,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &sisAPI); diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c index 1f9ff4e30c..899963d06d 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c @@ -442,16 +442,16 @@ static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits, * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void *__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 1, 0 }; @@ -467,7 +467,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &tdfxAPI); diff --git a/src/mesa/drivers/dri/trident/trident_context.c b/src/mesa/drivers/dri/trident/trident_context.c index 8dc7f0dc78..1d2a49e6f4 100644 --- a/src/mesa/drivers/dri/trident/trident_context.c +++ b/src/mesa/drivers/dri/trident/trident_context.c @@ -430,17 +430,17 @@ static struct __DriverAPIRec tridentAPI = { }; -PUBLIC void *__driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, - __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +PUBLIC void * +__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 4, 0, 0 }; @@ -456,7 +456,7 @@ PUBLIC void *__driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &tridentAPI); diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 7c73877720..66e92cc602 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -601,9 +601,6 @@ viaCreateContext(const __GLcontextModes *visual, _tnl_allow_pixel_fog(ctx, GL_FALSE); _tnl_allow_vertex_fog(ctx, GL_TRUE); -/* vmesa->display = dpy; */ - vmesa->display = sPriv->display; - vmesa->hHWContext = driContextPriv->hHWContext; vmesa->driFd = sPriv->fd; vmesa->driHwLock = &sPriv->pSAREA->lock; diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h index fecd2782fb..6321713688 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.h +++ b/src/mesa/drivers/dri/unichrome/via_context.h @@ -289,7 +289,6 @@ struct via_context { drm_context_t hHWContext; drm_hw_lock_t *driHwLock; int driFd; - __DRInativeDisplay *display; /** * DRI drawable bound to this context for drawing. diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index 90f76be44d..c10b7d1a9b 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -418,17 +418,16 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer ) * failure. */ PUBLIC -void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, - __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) +void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes) { __DRIscreenPrivate *psp; @@ -448,7 +447,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, return NULL; } - psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + psp = __driUtilCreateNewScreen(scrn, psc, NULL, ddx_version, dri_version, drm_version, frame_buffer, pSAREA, fd, internal_api_version, &viaAPI); -- cgit v1.2.3 From 4ff95e78e19e5902352ea3759d32d9f013255f42 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 10 May 2007 17:14:38 -0400 Subject: Drop createDrawable and destroyDrawable fron DRIinterfaceMethods. All the DRI driver did was call the createDrawable callback immediately upon entry to DRIscreen::createNewDrawable to get the drm_drawable_t. We can just call that before calling into the DRI driver and pass the returned drm_drawable_t as an argument to the DRI entry point. Likewise for destroyDrawable. Also, DRIdrawablePrivate::draw isn't used anywhere, and since the driver no longer needs the XID of the drawable we can now drop that. --- include/GL/internal/dri_interface.h | 16 +++---------- src/glx/x11/glxcmds.c | 5 ++-- src/glx/x11/glxext.c | 42 +++++++++++----------------------- src/mesa/drivers/dri/common/dri_util.c | 18 ++++----------- src/mesa/drivers/dri/common/dri_util.h | 1 - src/mesa/drivers/dri/mga/mgastate.c | 5 ---- 6 files changed, 24 insertions(+), 63 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 8a6984de68..0f90f49507 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -194,22 +194,11 @@ struct __DRIinterfaceMethodsRec { */ GLboolean (* destroyContext)( __DRIscreen *screen, __DRIid context ); - /** - * Create the server-side portion of the drawable. - */ - GLboolean (*createDrawable)( __DRIscreen *screen, - __DRIid drawable, drm_drawable_t * hHWDrawable ); - - /** - * Destroy the server-side portion of the drawable. - */ - GLboolean (*destroyDrawable)( __DRIscreen *screen, __DRIid drawable ); - /** * This function is used to get information about the position, size, and * clip rects of a drawable. */ - GLboolean (* getDrawableInfo) ( __DRIscreen *screen, __DRIid drawable, + GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable, unsigned int * index, unsigned int * stamp, int * x, int * y, int * width, int * height, int * numClipRects, drm_clip_rect_t ** pClipRects, @@ -303,7 +292,8 @@ struct __DRIscreenRec { */ void *(*createNewDrawable)(__DRIscreen *screen, const __GLcontextModes *modes, - __DRIid draw, __DRIdrawable *pdraw, + __DRIdrawable *pdraw, + drm_drawable_t hwDrawable, int renderType, const int *attrs); /** diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 45ee93c5c3..229da5a584 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -85,7 +85,7 @@ static void GarbageCollectDRIDrawables(Display *dpy, int screen) __GLXdisplayPrivate * const priv = __glXInitialize(dpy); __GLXscreenConfigs *sc; __DRIid draw; - __DRIdrawable *pdraw; + __GLXdrawable *pdraw; XWindowAttributes xwa; int (*oldXErrorHandler)(Display *, XErrorEvent *); @@ -105,7 +105,8 @@ static void GarbageCollectDRIDrawables(Display *dpy, int screen) if (!windowExistsFlag) { /* Destroy the local drawable data, if the drawable no longer exists in the Xserver */ - (*pdraw->destroyDrawable)(pdraw->private); + (*pdraw->driDrawable.destroyDrawable)(pdraw->driDrawable.private); + XF86DRIDestroyDrawable(dpy, sc->scr, draw); Xfree(pdraw); } } while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1); diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 2ff73685e3..dce01d5528 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -796,39 +796,19 @@ __glXDRIDestroyContext(__DRIscreen *screen, __DRIid context_id) } static GLboolean -__glXDRICreateDrawable( __DRIscreen *screen, - __DRIid drawable, drm_drawable_t *hHWDrawable ) -{ - __GLXscreenConfigs *psc = - containerOf(screen, __GLXscreenConfigs, driScreen); - Display *dpy = psc->dpy; - - return XF86DRICreateDrawable(dpy, psc->scr, drawable, hHWDrawable); -} - -static GLboolean -__glXDRIDestroyDrawable(__DRIscreen *screen, __DRIid drawable) -{ - __GLXscreenConfigs *psc = - containerOf(screen, __GLXscreenConfigs, driScreen); - Display *dpy = psc->dpy; - - return XF86DRIDestroyDrawable(dpy, psc->scr, drawable); -} - -static GLboolean -__glXDRIGetDrawableInfo(__DRIscreen *screen, __DRIid drawable, +__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) { - __GLXscreenConfigs *psc = - containerOf(screen, __GLXscreenConfigs, driScreen); + __GLXdrawable *glxDraw = + containerOf(drawable, __GLXdrawable, driDrawable); + __GLXscreenConfigs *psc = glxDraw->psc; Display *dpy = psc->dpy; - return XF86DRIGetDrawableInfo(dpy, psc->scr, drawable, + return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable, index, stamp, X, Y, W, H, numClipRects, pClipRects, backX, backY, @@ -848,8 +828,6 @@ static const __DRIinterfaceMethods interface_methods = { __glXDRICreateContext, __glXDRIDestroyContext, - __glXDRICreateDrawable, - __glXDRIDestroyDrawable, __glXDRIGetDrawableInfo, __glXGetUST, @@ -1667,6 +1645,7 @@ 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; if (priv == NULL || priv->driDisplay.private == NULL) @@ -1684,22 +1663,27 @@ FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc) 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, - drawable, &pdraw->driDrawable, + &pdraw->driDrawable, + hwDrawable, GLX_WINDOW_BIT, empty_attribute_list); if (!pdraw->driDrawable.private) { - /* ERROR!!! */ + XF86DRIDestroyDrawable(dpy, sc->scr, drawable); Xfree(pdraw); return NULL; } if (__glxHashInsert(sc->drawHash, drawable, pdraw)) { (*pdraw->driDrawable.destroyDrawable)(pdraw->driDrawable.private); + XF86DRIDestroyDrawable(dpy, sc->scr, drawable); Xfree(pdraw); return NULL; } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 2b5d6f0a59..dd7068ad10 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -59,7 +59,8 @@ static int driQueryFrameTracking( void *priv, static void *driCreateNewDrawable(__DRIscreen *screen, const __GLcontextModes *modes, - __DRIid draw, __DRIdrawable *pdraw, + __DRIdrawable *pdraw, + drm_drawable_t hwDrawable, int renderType, const int *attrs); static void driDestroyDrawable(void *drawablePrivate); @@ -286,7 +287,7 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); - if (! (*dri_interface->getDrawableInfo)(pdp->driScreenPriv->psc, pdp->draw, + if (! (*dri_interface->getDrawableInfo)(pdp->pdraw, &pdp->index, &pdp->lastStamp, &pdp->x, &pdp->y, &pdp->w, &pdp->h, &pdp->numClipRects, &pdp->pClipRects, @@ -435,8 +436,8 @@ static void driCopySubBuffer( void *drawablePrivate, */ static void *driCreateNewDrawable(__DRIscreen *screen, const __GLcontextModes *modes, - __DRIid draw, __DRIdrawable *pdraw, + drm_drawable_t hwDrawable, int renderType, const int *attrs) { @@ -456,14 +457,7 @@ static void *driCreateNewDrawable(__DRIscreen *screen, return NULL; } - /* Ensure that modes->screen and screen are the same screen? */ - - if (!(*dri_interface->createDrawable)(screen, draw, &pdp->hHWDrawable)) { - _mesa_free(pdp); - return NULL; - } - - pdp->draw = draw; + pdp->hHWDrawable = hwDrawable; pdp->pdraw = pdraw; pdp->refcount = 0; pdp->pStamp = NULL; @@ -484,7 +478,6 @@ static void *driCreateNewDrawable(__DRIscreen *screen, if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, modes, renderType == GLX_PIXMAP_BIT)) { - (void)(*dri_interface->destroyDrawable)(screen, pdp->draw); _mesa_free(pdp); return NULL; } @@ -523,7 +516,6 @@ driDestroyDrawable(void *drawablePrivate) if (pdp) { psp = pdp->driScreenPriv; (*psp->DriverAPI.DestroyBuffer)(pdp); - (void)(*dri_interface->destroyDrawable)(psp->psc, pdp->draw); if (pdp->pClipRects) { _mesa_free(pdp->pClipRects); pdp->pClipRects = NULL; diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index cae170c5f8..cb9bb26051 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -248,7 +248,6 @@ struct __DRIdrawablePrivateRec { /** * X's drawable ID associated with this private drawable. */ - __DRIid draw; __DRIdrawable *pdraw; /** diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c index c20a76f29e..88f2175cc3 100644 --- a/src/mesa/drivers/dri/mga/mgastate.c +++ b/src/mesa/drivers/dri/mga/mgastate.c @@ -778,8 +778,6 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ) { __DRIdrawablePrivate *const driDrawable = mmesa->driDrawable; __DRIdrawablePrivate *const driReadable = mmesa->driReadable; - drm_mga_sarea_t *sarea = mmesa->sarea; - mmesa->dirty_cliprects = 0; @@ -790,9 +788,6 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ) mga_set_cliprects(mmesa); - sarea->req_drawable = driDrawable->draw; - sarea->req_draw_buffer = mmesa->draw_buffer; - mgaUpdateClipping( mmesa->glCtx ); mgaCalcViewport( mmesa->glCtx ); } -- cgit v1.2.3 From 8ed5c7ca0572a09375bdfd411c3804456dac78d6 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 10 May 2007 18:38:49 -0400 Subject: Drop createContext and destroyContext from DRIinterfaceMethods. As for createDrawable and destroyDrawable, these functions immediately upon entry to driCreateNewContext and immediately before exit from driDestroyContext. Instead of passing function pointers back and forth just obtain the drm_context_t prior to calling DRIscreen::createNewContext and pass it as a parameter. This change also lets us keep the DRI context XID in the libGL loader only. --- include/GL/internal/dri_interface.h | 14 ++------------ src/glx/x11/glxclient.h | 5 +++++ src/glx/x11/glxcmds.c | 14 ++++++++++++++ src/glx/x11/glxext.c | 28 +++------------------------- src/mesa/drivers/dri/common/dri_util.c | 14 +++----------- src/mesa/drivers/dri/common/dri_util.h | 5 ----- 6 files changed, 27 insertions(+), 53 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 0f90f49507..98271ad0af 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -183,17 +183,6 @@ struct __DRIinterfaceMethodsRec { */ /*@{*/ - /** - * Create the server-side portion of the GL context. - */ - GLboolean (* createContext)( __DRIscreen *screen, - int configID, void * contextID, drm_context_t * hw_context ); - - /** - * Destroy the server-side portion of the GL context. - */ - GLboolean (* destroyContext)( __DRIscreen *screen, __DRIid context ); - /** * This function is used to get information about the position, size, and * clip rects of a drawable. @@ -345,7 +334,8 @@ struct __DRIscreenRec { void * (*createNewContext)(__DRIscreen *screen, const __GLcontextModes *modes, int render_type, - void *sharedPrivate, __DRIcontext *pctx); + void *sharedPrivate, + drm_context_t hwContext, __DRIcontext *pctx); /** * Method to override base texture image with a driver specific 'offset'. diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index 7ed4549658..5697325175 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -361,6 +361,11 @@ struct __GLXcontextRec { * Pointer to the mode used to create this context. */ const __GLcontextModes * mode; + + /** + * XID for the server side drm_context_t + */ + XID hwContextID; #endif /** diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 229da5a584..b6c0c763e3 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -382,6 +382,7 @@ CreateContext(Display *dpy, XVisualInfo *vis, int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen; __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); const __GLcontextModes * mode; + drm_context_t hwContext; /* The value of fbconfig cannot change because it is tested * later in the function. @@ -402,10 +403,19 @@ CreateContext(Display *dpy, XVisualInfo *vis, if (psc && psc->driScreen.private) { void * const shared = (shareList != NULL) ? shareList->driContext.private : NULL; + + + if (!XF86DRICreateContextWithConfig(dpy, psc->scr, + mode->fbconfigID, + &gc->hwContextID, &hwContext)) + /* gah, handle this better */ + return NULL; + gc->driContext.private = (*psc->driScreen.createNewContext)( &psc->driScreen, mode, renderType, shared, + hwContext, &gc->driContext ); if (gc->driContext.private) { gc->isDirect = GL_TRUE; @@ -415,6 +425,9 @@ CreateContext(Display *dpy, XVisualInfo *vis, gc->fbconfigID = mode->fbconfigID; gc->mode = mode; } + else { + XF86DRIDestroyContext(dpy, psc->scr, gc->hwContextID); + } } } #endif @@ -524,6 +537,7 @@ DestroyContext(Display *dpy, GLXContext gc) if (gc->isDirect) { if (gc->driContext.private) { (*gc->driContext.destroyContext)(gc->driContext.private); + XF86DRIDestroyContext(dpy, gc->psc->scr, gc->hwContextID); gc->driContext.private = NULL; } GarbageCollectDRIDrawables(dpy, gc->screen); diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index dce01d5528..85c990d4fc 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -773,28 +773,6 @@ static void __glXReportDamage(__DRIdrawable *driDraw, #endif } -static GLboolean -__glXDRICreateContext(__DRIscreen *screen, int configID, - void *pid, drm_context_t *hHWContext) -{ - __GLXscreenConfigs *psc = - containerOf(screen, __GLXscreenConfigs, driScreen); - Display *dpy = psc->dpy; - - return XF86DRICreateContextWithConfig(dpy, psc->scr, - configID, pid, hHWContext); -} - -static GLboolean -__glXDRIDestroyContext(__DRIscreen *screen, __DRIid context_id) -{ - __GLXscreenConfigs *psc = - containerOf(screen, __GLXscreenConfigs, driScreen); - Display *dpy = psc->dpy; - - return XF86DRIDestroyContext(dpy, psc->scr, context_id); -} - static GLboolean __glXDRIGetDrawableInfo(__DRIdrawable *drawable, unsigned int *index, unsigned int *stamp, @@ -824,9 +802,6 @@ static const __DRIinterfaceMethods interface_methods = { _gl_context_modes_create, _gl_context_modes_destroy, - - __glXDRICreateContext, - __glXDRIDestroyContext, __glXDRIGetDrawableInfo, @@ -1816,6 +1791,9 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw, if (oldGC->driContext.private) { (*oldGC->driContext.destroyContext) (oldGC->driContext.private); + XF86DRIDestroyContext(oldGC->createDpy, + oldGC->psc->scr, + gc->hwContextID); oldGC->driContext.private = NULL; } } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index dd7068ad10..31438b8271 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -552,8 +552,6 @@ driDestroyContext(void *contextPrivate) if (pcp) { (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp); - (void) (*dri_interface->destroyContext)(pcp->driScreenPriv->psc, - pcp->contextID); _mesa_free(pcp); } } @@ -582,7 +580,8 @@ driDestroyContext(void *contextPrivate) */ static void * driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, - int render_type, void *sharedPrivate, __DRIcontext *pctx) + int render_type, void *sharedPrivate, + drm_context_t hwContext, __DRIcontext *pctx) { __DRIcontextPrivate *pcp; __DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate; @@ -596,12 +595,7 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, return NULL; } - if (! (*dri_interface->createContext)(screen, modes->fbconfigID, - &pcp->contextID, &pcp->hHWContext)) { - _mesa_free(pcp); - return NULL; - } - + pcp->hHWContext = hwContext; pcp->driScreenPriv = psp; pcp->driDrawablePriv = NULL; @@ -610,7 +604,6 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, */ if (!psp->dummyContextPriv.driScreenPriv) { - psp->dummyContextPriv.contextID = 0; psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context; psp->dummyContextPriv.driScreenPriv = psp; psp->dummyContextPriv.driDrawablePriv = NULL; @@ -623,7 +616,6 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, pctx->unbindContext = driUnbindContext; if ( !(*psp->DriverAPI.CreateContext)(modes, pcp, shareCtx) ) { - (void) (*dri_interface->destroyContext)(screen, pcp->contextID); _mesa_free(pcp); return NULL; } diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index cb9bb26051..612e24acb2 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -326,11 +326,6 @@ struct __DRIdrawablePrivateRec { * Per-context private driver information. */ struct __DRIcontextPrivateRec { - /** - * Kernel context handle used to access the device lock. - */ - __DRIid contextID; - /** * Kernel context handle used to access the device lock. */ -- cgit v1.2.3 From 5987a03f994af2bb413d1cf984ab01aa095c0943 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Fri, 11 May 2007 16:43:20 -0400 Subject: Convert all DRI entrypoints to take pointers to __DRI* types. The entrypoints take a mix of __DRIscreen * and void * (screen private) arguments (similarly for contexts and drawables). This patch does away with passing the private void pointer and always only passes the fully typed __DRIscreen pointer and always as the first argument. This makes the interface more consistent and increases type safety, and catches a bug where we would pass a screen private to DRIdrawable::getSBC. --- include/GL/internal/dri_interface.h | 40 +++++++++--------- src/glx/x11/glxcmds.c | 42 +++++++++---------- src/glx/x11/glxext.c | 8 ++-- src/mesa/drivers/dri/common/dri_util.c | 74 +++++++++++++++++----------------- 4 files changed, 80 insertions(+), 84 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 752dd417dc..178134270d 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -273,7 +273,7 @@ struct __DRIscreenRec { /** * Method to destroy the private DRI screen data. */ - void (*destroyScreen)(void *screenPrivate); + void (*destroyScreen)(__DRIscreen *screen); /** * Method to create the private DRI drawable data and initialize the @@ -298,7 +298,7 @@ struct __DRIscreenRec { * * \since Internal API version 20030317. */ - int (*getMSC)( void *screenPrivate, int64_t *msc ); + int (*getMSC)(__DRIscreen *screen, int64_t *msc); /** * Functions associated with MESA_allocate_memory. @@ -348,7 +348,7 @@ struct __DRIcontextRec { /** * Method to destroy the private DRI context data. */ - void (*destroyContext)(void *contextPrivate); + void (*destroyContext)(__DRIcontext *context); /** * Opaque pointer to private per context direct rendering data. @@ -362,9 +362,9 @@ struct __DRIcontextRec { * * \since Internal API version 20050727. */ - GLboolean (*bindContext)(__DRIdrawable *pdraw, - __DRIdrawable *pread, - __DRIcontext *ctx); + GLboolean (*bindContext)(__DRIcontext *ctx, + __DRIdrawable *pdraw, + __DRIdrawable *pread); /** * Method to unbind a DRI drawable from a DRI graphics context. @@ -384,12 +384,12 @@ struct __DRIdrawableRec { /** * Method to destroy the private DRI drawable data. */ - void (*destroyDrawable)(void *drawablePrivate); + void (*destroyDrawable)(__DRIdrawable *drawable); /** * Method to swap the front and back buffers. */ - void (*swapBuffers)(void *drawablePrivate); + void (*swapBuffers)(__DRIdrawable *drawable); /** * Opaque pointer to private per drawable direct rendering data. @@ -403,16 +403,16 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int (*getSBC)(void *drawablePrivate, int64_t *sbc ); + int (*getSBC)(__DRIdrawable *drawable, int64_t *sbc); /** * Wait for the SBC to be greater than or equal target_sbc. * * \since Internal API version 20030317. */ - int (*waitForSBC)( void *drawablePriv, - int64_t target_sbc, - int64_t * msc, int64_t * sbc ); + int (*waitForSBC)(__DRIdrawable *drawable, + int64_t target_sbc, + int64_t * msc, int64_t * sbc); /** * Wait for the MSC to equal target_msc, or, if that has already passed, @@ -422,9 +422,9 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int (*waitForMSC)( void *drawablePriv, - int64_t target_msc, int64_t divisor, int64_t remainder, - int64_t * msc, int64_t * sbc ); + int (*waitForMSC)(__DRIdrawable *drawable, + int64_t target_msc, int64_t divisor, int64_t remainder, + int64_t * msc, int64_t * sbc); /** * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once @@ -435,7 +435,7 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int64_t (*swapBuffersMSC)(void *drawablePrivate, + int64_t (*swapBuffersMSC)(__DRIdrawable *drawable, int64_t target_msc, int64_t divisor, int64_t remainder); @@ -444,16 +444,16 @@ struct __DRIdrawableRec { * * \since Internal API version 20030317. */ - int (*frameTracking)(void *drawablePrivate, GLboolean enable); + int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable); /** * Retrieve frame usage information. * * \since Internal API version 20030317. */ - int (*queryFrameTracking)(void *drawablePrivate, + int (*queryFrameTracking)(__DRIdrawable *drawable, int64_t * sbc, int64_t * missedFrames, - float * lastMissedUsage, float * usage ); + float * lastMissedUsage, float * usage); /** * Used by drivers that implement the GLX_SGI_swap_control or @@ -468,7 +468,7 @@ struct __DRIdrawableRec { * * \since Internal API version 20060314. */ - void (*copySubBuffer)(void *drawablePrivate, + void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h); }; diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 3131646381..6b8824d824 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -99,7 +99,7 @@ static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc) if (!windowExistsFlag) { /* Destroy the local drawable data, if the drawable no longer exists in the Xserver */ - (*pdraw->driDrawable.destroyDrawable)(pdraw->driDrawable.private); + (*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable); XF86DRIDestroyDrawable(dpy, sc->scr, draw); Xfree(pdraw); } @@ -530,7 +530,7 @@ DestroyContext(Display *dpy, GLXContext gc) /* Destroy the direct rendering context */ if (gc->isDirect) { if (gc->driContext.private) { - (*gc->driContext.destroyContext)(gc->driContext.private); + (*gc->driContext.destroyContext)(&gc->driContext); XF86DRIDestroyContext(dpy, gc->psc->scr, gc->hwContextID); gc->driContext.private = NULL; } @@ -859,7 +859,7 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, NULL ); if ( pdraw != NULL ) { - (*pdraw->swapBuffers)(pdraw->private); + (*pdraw->swapBuffers)(pdraw); return; } #endif @@ -1845,7 +1845,7 @@ static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable) if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking( pdraw->private, GL_TRUE ); + status = pdraw->frameTracking(pdraw, GL_TRUE); } #else (void) dpy; @@ -1865,7 +1865,7 @@ static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable) if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking( pdraw->private, GL_FALSE ); + status = pdraw->frameTracking(pdraw, GL_FALSE); } #else (void) dpy; @@ -1889,9 +1889,8 @@ static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, int64_t sbc, missedFrames; float lastMissedUsage; - status = pdraw->queryFrameTracking( pdraw->private, &sbc, - &missedFrames, &lastMissedUsage, - usage ); + status = pdraw->queryFrameTracking(pdraw, &sbc, &missedFrames, + &lastMissedUsage, usage); } #else (void) dpy; @@ -1916,9 +1915,8 @@ static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { float usage; - status = pdraw->queryFrameTracking( pdraw->private, sbc, - missedFrames, lastMissedUsage, - & usage ); + status = pdraw->queryFrameTracking(pdraw, sbc, missedFrames, + lastMissedUsage, &usage); } #else (void) dpy; @@ -1952,7 +1950,7 @@ static int __glXGetVideoSyncSGI(unsigned int *count) int ret; int64_t temp; - ret = psc->driScreen.getMSC( psc->driScreen.private, & temp ); + ret = psc->driScreen.getMSC(&psc->driScreen, &temp); *count = (unsigned) temp; return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } @@ -1983,9 +1981,8 @@ static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count int64_t msc; int64_t sbc; - ret = (*pdraw->waitForMSC)( pdraw->private, - 0, divisor, remainder, - & msc, & sbc ); + ret = (*pdraw->waitForMSC)(pdraw, 0, + divisor, remainder, &msc, &sbc); *count = (unsigned) msc; return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } @@ -2151,8 +2148,8 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, assert( (pdraw == NULL) || (i != -1) ); return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) - && ((*psc->driScreen.getMSC)( psc->driScreen.private, msc ) == 0) - && ((*pdraw->getSBC)( psc->driScreen.private, sbc ) == 0) + && ((*psc->driScreen.getMSC)(&psc->driScreen, msc) == 0) + && ((*pdraw->getSBC)(pdraw, sbc ) == 0) && (__glXGetUST( ust ) == 0) ); } #else @@ -2275,8 +2272,7 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable, if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - return (*pdraw->swapBuffersMSC)(pdraw->private, target_msc, - divisor, remainder); + return (*pdraw->swapBuffersMSC)(pdraw, target_msc, divisor, remainder); } #else (void) dpy; @@ -2310,8 +2306,8 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable, if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - ret = (*pdraw->waitForMSC)( pdraw->private, target_msc, - divisor, remainder, msc, sbc ); + ret = (*pdraw->waitForMSC)(pdraw, target_msc, + divisor, remainder, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. @@ -2350,7 +2346,7 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL) && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) { - ret = (*pdraw->waitForSBC)( pdraw->private, target_sbc, msc, sbc ); + ret = (*pdraw->waitForSBC)(pdraw, target_sbc, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. @@ -2508,7 +2504,7 @@ static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, if ( pdraw != NULL ) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); if ( __glXExtensionBitIsEnabled( psc, MESA_copy_sub_buffer_bit ) ) { - (*pdraw->copySubBuffer)(pdraw->private, x, y, width, height); + (*pdraw->copySubBuffer)(pdraw, x, y, width, height); } return; diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 45b1dde91b..8c12ae254a 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -360,7 +360,7 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv) #ifdef GLX_DIRECT_RENDERING /* Free the direct rendering per screen data */ if (psc->driScreen.private) - (*psc->driScreen.destroyScreen)(psc->driScreen.private); + (*psc->driScreen.destroyScreen)(&psc->driScreen); psc->driScreen.private = NULL; __glxHashDestroy(psc->drawHash); #endif @@ -1656,7 +1656,7 @@ FetchDRIDrawable( Display *dpy, GLXDrawable drawable, GLXContext gc) } if (__glxHashInsert(sc->drawHash, drawable, pdraw)) { - (*pdraw->driDrawable.destroyDrawable)(pdraw->driDrawable.private); + (*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable); XF86DRIDestroyDrawable(dpy, sc->scr, drawable); Xfree(pdraw); return NULL; @@ -1671,7 +1671,7 @@ static Bool BindContextWrapper( Display *dpy, GLXContext gc, __DRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc); __DRIdrawable *pread = FetchDRIDrawable(dpy, read, gc); - return (*gc->driContext.bindContext)(pdraw, pread, &gc->driContext); + return (*gc->driContext.bindContext)(&gc->driContext, pdraw, pread); } @@ -1789,7 +1789,7 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw, if (oldGC->isDirect) { if (oldGC->driContext.private) { (*oldGC->driContext.destroyContext) - (oldGC->driContext.private); + (&oldGC->driContext); XF86DRIDestroyContext(oldGC->createDpy, oldGC->psc->scr, gc->hwContextID); diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 31438b8271..48cde4c4e3 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -53,7 +53,7 @@ static const int empty_attribute_list[1] = { None }; static int api_ver = 0; /* forward declarations */ -static int driQueryFrameTracking( void *priv, +static int driQueryFrameTracking( __DRIdrawable *drawable, int64_t *sbc, int64_t *missedFrames, float *lastMissedUsage, float *usage ); @@ -63,7 +63,7 @@ static void *driCreateNewDrawable(__DRIscreen *screen, drm_drawable_t hwDrawable, int renderType, const int *attrs); -static void driDestroyDrawable(void *drawablePrivate); +static void driDestroyDrawable(__DRIdrawable *drawable); /** @@ -169,9 +169,9 @@ static GLboolean driUnbindContext(__DRIcontext *ctx) * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent * function. */ -static GLboolean DoBindContext(__DRIdrawable *pdraw, - __DRIdrawable *pread, - __DRIcontext *ctx) +static GLboolean DoBindContext(__DRIcontext *ctx, + __DRIdrawable *pdraw, + __DRIdrawable *pread) { __DRIdrawablePrivate *pdp; __DRIdrawablePrivate *prp; @@ -218,9 +218,9 @@ static GLboolean DoBindContext(__DRIdrawable *pdraw, * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent * function. */ -static GLboolean driBindContext(__DRIdrawable *pdraw, - __DRIdrawable *pread, - __DRIcontext * ctx) +static GLboolean driBindContext(__DRIcontext * ctx, + __DRIdrawable *pdraw, + __DRIdrawable *pread) { /* ** Assume error checking is done properly in glXMakeCurrent before @@ -230,7 +230,7 @@ static GLboolean driBindContext(__DRIdrawable *pdraw, if (ctx == NULL || pdraw == None || pread == None) return GL_FALSE; - return DoBindContext( pdraw, pread, ctx ); + return DoBindContext( ctx, pdraw, pread ); } /*@}*/ @@ -328,9 +328,9 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) * * Is called directly from glXSwapBuffers(). */ -static void driSwapBuffers(void *drawablePrivate) +static void driSwapBuffers(__DRIdrawable *drawable) { - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; + __DRIdrawablePrivate *dPriv = drawable->private; drm_clip_rect_t rect; dPriv->swapBuffers(dPriv); @@ -356,9 +356,9 @@ static void driSwapBuffers(void *drawablePrivate) /** * Called directly from a number of higher-level GLX functions. */ -static int driGetMSC( void *screenPrivate, int64_t *msc ) +static int driGetMSC( __DRIscreen *screen, int64_t *msc ) { - __DRIscreenPrivate *sPriv = (__DRIscreenPrivate *) screenPrivate; + __DRIscreenPrivate *sPriv = screen->private; return sPriv->DriverAPI.GetMSC( sPriv, msc ); } @@ -366,9 +366,9 @@ static int driGetMSC( void *screenPrivate, int64_t *msc ) /** * Called directly from a number of higher-level GLX functions. */ -static int driGetSBC( void *drawablePrivate, int64_t *sbc ) +static int driGetSBC(__DRIdrawable *drawable, int64_t *sbc) { - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; + __DRIdrawablePrivate *dPriv = drawable->private; __DRIswapInfo sInfo; int status; @@ -379,20 +379,20 @@ static int driGetSBC( void *drawablePrivate, int64_t *sbc ) return status; } -static int driWaitForSBC( void *drawablePriv, int64_t target_sbc, - int64_t * msc, int64_t * sbc ) +static int driWaitForSBC(__DRIdrawable *drawable, int64_t target_sbc, + int64_t * msc, int64_t * sbc) { - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv; + __DRIdrawablePrivate *dPriv = drawable->private; return dPriv->driScreenPriv->DriverAPI.WaitForSBC( dPriv, target_sbc, msc, sbc ); } -static int driWaitForMSC( void *drawablePriv, int64_t target_msc, - int64_t divisor, int64_t remainder, - int64_t * msc, int64_t * sbc ) +static int driWaitForMSC(__DRIdrawable *drawable, int64_t target_msc, + int64_t divisor, int64_t remainder, + int64_t * msc, int64_t * sbc) { - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv; + __DRIdrawablePrivate *dPriv = drawable->private; __DRIswapInfo sInfo; int status; @@ -414,20 +414,20 @@ static int driWaitForMSC( void *drawablePriv, int64_t target_msc, return status; } -static int64_t driSwapBuffersMSC( void *drawablePriv, int64_t target_msc, - int64_t divisor, int64_t remainder ) +static int64_t driSwapBuffersMSC(__DRIdrawable *drawable, int64_t target_msc, + int64_t divisor, int64_t remainder) { - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv; + __DRIdrawablePrivate *dPriv = drawable->private; return dPriv->driScreenPriv->DriverAPI.SwapBuffersMSC( dPriv, target_msc, divisor, remainder ); } -static void driCopySubBuffer( void *drawablePrivate, +static void driCopySubBuffer(__DRIdrawable *drawable, int x, int y, int w, int h) { - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; + __DRIdrawablePrivate *dPriv = drawable->private; dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h); } @@ -508,9 +508,9 @@ static void *driCreateNewDrawable(__DRIscreen *screen, } static void -driDestroyDrawable(void *drawablePrivate) +driDestroyDrawable(__DRIdrawable *drawable) { - __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *) drawablePrivate; + __DRIdrawablePrivate *pdp = drawable->private; __DRIscreenPrivate *psp; if (pdp) { @@ -546,9 +546,9 @@ driDestroyDrawable(void *drawablePrivate) * drmDestroyContext(), and finally frees \p contextPrivate. */ static void -driDestroyContext(void *contextPrivate) +driDestroyContext(__DRIcontext *context) { - __DRIcontextPrivate *pcp = (__DRIcontextPrivate *) contextPrivate; + __DRIcontextPrivate *pcp = context->private; if (pcp) { (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp); @@ -641,9 +641,9 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, * This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls * drmClose(), and finally frees \p screenPrivate. */ -static void driDestroyScreen(void *screenPrivate) +static void driDestroyScreen(__DRIscreen *screen) { - __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate; + __DRIscreenPrivate *psp = screen->private; if (psp) { /* No interaction with the X-server is possible at this point. This @@ -808,14 +808,14 @@ int driCompareGLXAPIVersion( GLint required_version ) static int -driQueryFrameTracking( void * priv, - int64_t * sbc, int64_t * missedFrames, - float * lastMissedUsage, float * usage ) +driQueryFrameTracking(__DRIdrawable *drawable, + int64_t * sbc, int64_t * missedFrames, + float * lastMissedUsage, float * usage) { __DRIswapInfo sInfo; int status; int64_t ust; - __DRIdrawablePrivate * dpriv = (__DRIdrawablePrivate *) priv; + __DRIdrawablePrivate * dpriv = drawable->private; status = dpriv->driScreenPriv->DriverAPI.GetSwapInfo( dpriv, & sInfo ); -- cgit v1.2.3 From efd03a278ae55b454509e9659c42899133983ebd Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 14 May 2007 16:37:19 -0400 Subject: Replace open-coded major, minor, and patch version fields with __DRIversionRec. --- src/mesa/drivers/dri/common/dri_util.c | 12 +++--------- src/mesa/drivers/dri/common/dri_util.h | 24 +++--------------------- src/mesa/drivers/dri/i915/intel_buffers.c | 2 +- src/mesa/drivers/dri/i915/intel_screen.c | 10 +++++----- src/mesa/drivers/dri/i965/intel_screen.c | 2 +- src/mesa/drivers/dri/mga/mga_xmesa.c | 4 ++-- src/mesa/drivers/dri/mga/mgaioctl.c | 4 ++-- src/mesa/drivers/dri/r128/r128_context.c | 2 +- src/mesa/drivers/dri/r128/r128_screen.c | 2 +- src/mesa/drivers/dri/r200/r200_context.c | 8 ++++---- src/mesa/drivers/dri/r300/radeon_context.c | 2 +- src/mesa/drivers/dri/radeon/radeon_context.c | 8 ++++---- src/mesa/drivers/dri/radeon/radeon_screen.c | 20 ++++++++++---------- src/mesa/drivers/dri/savage/savage_xmesa.c | 2 +- src/mesa/drivers/dri/savage/savagetex.c | 4 ++-- 15 files changed, 41 insertions(+), 65 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 48cde4c4e3..09fc2230fd 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -727,15 +727,9 @@ __driUtilCreateNewScreen(int scr, __DRIscreen *psc, */ psp->drawLockID = 1; - psp->drmMajor = drm_version->major; - psp->drmMinor = drm_version->minor; - psp->drmPatch = drm_version->patch; - psp->ddxMajor = ddx_version->major; - psp->ddxMinor = ddx_version->minor; - psp->ddxPatch = ddx_version->patch; - psp->driMajor = dri_version->major; - psp->driMinor = dri_version->minor; - psp->driPatch = dri_version->patch; + psp->drm_version = *drm_version; + psp->ddx_version = *ddx_version; + psp->dri_version = *dri_version; /* install driver's callback functions */ memcpy( &psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec) ); diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 612e24acb2..7a70bc7aa6 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -372,37 +372,19 @@ struct __DRIscreenPrivateRec { struct __DriverAPIRec DriverAPI; /** - * \name DDX version * DDX / 2D driver version information. - * \todo Replace these fields with a \c __DRIversionRec. */ - /*@{*/ - int ddxMajor; - int ddxMinor; - int ddxPatch; - /*@}*/ + __DRIversion ddx_version; /** - * \name DRI version * DRI X extension version information. - * \todo Replace these fields with a \c __DRIversionRec. */ - /*@{*/ - int driMajor; - int driMinor; - int driPatch; - /*@}*/ + __DRIversion dri_version; /** - * \name DRM version * DRM (kernel module) version information. - * \todo Replace these fields with a \c __DRIversionRec. */ - /*@{*/ - int drmMajor; - int drmMinor; - int drmPatch; - /*@}*/ + __DRIversion drm_version; /** * ID used when the client sets the drawable lock. diff --git a/src/mesa/drivers/dri/i915/intel_buffers.c b/src/mesa/drivers/dri/i915/intel_buffers.c index bd2e67fbed..46a67b141e 100644 --- a/src/mesa/drivers/dri/i915/intel_buffers.c +++ b/src/mesa/drivers/dri/i915/intel_buffers.c @@ -231,7 +231,7 @@ intelWindowMoved(struct intel_context *intel) } } - if (intel->intelScreen->driScrnPriv->ddxMinor >= 7) { + if (intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) { drmI830Sarea *sarea = intel->sarea; drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w, .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h }; diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 6ecde574b4..58dc02e24e 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -217,7 +217,7 @@ intel_recreate_static_regions(intelScreenPrivate *intelScreen) /* The rotated region is only used for old DDXes that didn't handle rotation \ * on their own. */ - if (intelScreen->driScrnPriv->ddxMinor < 8) { + if (intelScreen->driScrnPriv->ddx_version.minor < 8) { intelScreen->rotated_region = intel_recreate_static(intelScreen, intelScreen->rotated_region, @@ -377,7 +377,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelScreen->back.handle = sarea->back_handle; intelScreen->back.size = sarea->back_size; - if (intelScreen->driScrnPriv->ddxMinor >= 8) { + if (intelScreen->driScrnPriv->ddx_version.minor >= 8) { intelScreen->third.offset = sarea->third_offset; intelScreen->third.pitch = sarea->pitch * intelScreen->cpp; intelScreen->third.handle = sarea->third_handle; @@ -389,7 +389,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelScreen->depth.handle = sarea->depth_handle; intelScreen->depth.size = sarea->depth_size; - if (intelScreen->driScrnPriv->ddxMinor >= 9) { + if (intelScreen->driScrnPriv->ddx_version.minor >= 9) { intelScreen->front.bo_handle = sarea->front_bo_handle; intelScreen->back.bo_handle = sarea->back_bo_handle; intelScreen->third.bo_handle = sarea->third_bo_handle; @@ -488,7 +488,7 @@ intelInitDriver(__DRIscreenPrivate * sPriv) if (0) intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv); - intelScreen->drmMinor = sPriv->drmMinor; + intelScreen->drmMinor = sPriv->drm_version.minor; /* Determine if IRQs are active? */ { @@ -535,7 +535,7 @@ intelInitDriver(__DRIscreenPrivate * sPriv) */ intelScreen->ttm = GL_FALSE; if (getenv("INTEL_NO_TTM") == NULL && - intelScreen->driScrnPriv->ddxMinor >= 9 && + intelScreen->driScrnPriv->ddx_version.minor >= 9 && intelScreen->front.bo_handle != -1) { intelScreen->bufmgr = dri_bufmgr_ttm_init(sPriv->fd, DRM_FENCE_TYPE_EXE, diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 97ccba09d8..cb6824b7ee 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -316,7 +316,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) return GL_FALSE; } - intelScreen->drmMinor = sPriv->drmMinor; + intelScreen->drmMinor = sPriv->drm_version.minor; /* Determine if IRQs are active? */ { diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 5b9d09d0bf..b001f8696a 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -216,7 +216,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) mgaScreen->sPriv = sPriv; sPriv->private = (void *)mgaScreen; - if (sPriv->drmMinor >= 1) { + if (sPriv->drm_version.minor >= 1) { int ret; drm_mga_getparam_t gp; @@ -273,7 +273,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) * there is a new, in-kernel mechanism for handling the wait. */ - if (mgaScreen->sPriv->drmMinor < 2) { + if (mgaScreen->sPriv->drm_version.minor < 2) { mgaScreen->mmio.handle = serverInfo->registers.handle; mgaScreen->mmio.size = serverInfo->registers.size; if ( drmMap( sPriv->fd, diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c index f8587fc541..679d688925 100644 --- a/src/mesa/drivers/dri/mga/mgaioctl.c +++ b/src/mesa/drivers/dri/mga/mgaioctl.c @@ -55,7 +55,7 @@ mgaSetFence( mgaContextPtr mmesa, uint32_t * fence ) { int ret = ENOSYS; - if ( mmesa->driScreen->drmMinor >= 2 ) { + if ( mmesa->driScreen->drm_version.minor >= 2 ) { ret = drmCommandWriteRead( mmesa->driScreen->fd, DRM_MGA_SET_FENCE, fence, sizeof( uint32_t )); if (ret) { @@ -73,7 +73,7 @@ mgaWaitFence( mgaContextPtr mmesa, uint32_t fence, uint32_t * curr_fence ) { int ret = ENOSYS; - if ( mmesa->driScreen->drmMinor >= 2 ) { + if ( mmesa->driScreen->drm_version.minor >= 2 ) { uint32_t temp = fence; ret = drmCommandWriteRead( mmesa->driScreen->fd, diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c index 95e54a6af5..c9fe11f38b 100644 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ b/src/mesa/drivers/dri/r128/r128_context.c @@ -254,7 +254,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual, _tnl_allow_vertex_fog( ctx, GL_TRUE ); driInitExtensions( ctx, card_extensions, GL_TRUE ); - if (sPriv->drmMinor >= 4) + if (sPriv->drm_version.minor >= 4) _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" ); r128InitTriFuncs( ctx ); diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 9df9c65fae..01b33d6493 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -120,7 +120,7 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) r128Screen->IsPCI = r128DRIPriv->IsPCI; r128Screen->sarea_priv_offset = r128DRIPriv->sarea_priv_offset; - if (sPriv->drmMinor >= 3) { + if (sPriv->drm_version.minor >= 3) { drm_r128_getparam_t gp; int ret; diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 5a178442bd..8f43a2f312 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -277,14 +277,14 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, "def_max_anisotropy"); if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) { - if ( sPriv->drmMinor < 13 ) + if ( sPriv->drm_version.minor < 13 ) fprintf( stderr, "DRM version 1.%d too old to support HyperZ, " - "disabling.\n",sPriv->drmMinor ); + "disabling.\n", sPriv->drm_version.minor ); else rmesa->using_hyperz = GL_TRUE; } - if ( sPriv->drmMinor >= 15 ) + if ( sPriv->drm_version.minor >= 15 ) rmesa->texmicrotile = GL_TRUE; /* Init default driver functions then plug in our R200-specific functions @@ -317,7 +317,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, rmesa->dri.hwContext = driContextPriv->hHWContext; rmesa->dri.hwLock = &sPriv->pSAREA->lock; rmesa->dri.fd = sPriv->fd; - rmesa->dri.drmMinor = sPriv->drmMinor; + rmesa->dri.drmMinor = sPriv->drm_version.minor; rmesa->r200Screen = screen; rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA + diff --git a/src/mesa/drivers/dri/r300/radeon_context.c b/src/mesa/drivers/dri/r300/radeon_context.c index e9634b427a..6dfaf3c647 100644 --- a/src/mesa/drivers/dri/r300/radeon_context.c +++ b/src/mesa/drivers/dri/r300/radeon_context.c @@ -156,7 +156,7 @@ GLboolean radeonInitContext(radeonContextPtr radeon, radeon->dri.hwContext = driContextPriv->hHWContext; radeon->dri.hwLock = &sPriv->pSAREA->lock; radeon->dri.fd = sPriv->fd; - radeon->dri.drmMinor = sPriv->drmMinor; + radeon->dri.drmMinor = sPriv->drm_version.minor; radeon->radeonScreen = screen; radeon->sarea = (drm_radeon_sarea_t *) ((GLubyte *) sPriv->pSAREA + diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index b302275c71..defc82fa26 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -233,14 +233,14 @@ radeonCreateContext( const __GLcontextModes *glVisual, "def_max_anisotropy"); if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) { - if ( sPriv->drmMinor < 13 ) + if ( sPriv->drm_version.minor < 13 ) fprintf( stderr, "DRM version 1.%d too old to support HyperZ, " - "disabling.\n",sPriv->drmMinor ); + "disabling.\n", sPriv->drm_version.minor ); else rmesa->using_hyperz = GL_TRUE; } - if ( sPriv->drmMinor >= 15 ) + if ( sPriv->drm_version.minor >= 15 ) rmesa->texmicrotile = GL_TRUE; /* Init default driver functions then plug in our Radeon-specific functions @@ -271,7 +271,7 @@ radeonCreateContext( const __GLcontextModes *glVisual, rmesa->dri.hwContext = driContextPriv->hHWContext; rmesa->dri.hwLock = &sPriv->pSAREA->lock; rmesa->dri.fd = sPriv->fd; - rmesa->dri.drmMinor = sPriv->drmMinor; + rmesa->dri.drmMinor = sPriv->drm_version.minor; rmesa->radeonScreen = screen; rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA + diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 8f9509de5b..9801322cd8 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -395,13 +395,13 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret); return NULL; } - screen->drmSupportsCubeMapsR200 = (sPriv->drmMinor >= 7); - screen->drmSupportsBlendColor = (sPriv->drmMinor >= 11); - screen->drmSupportsTriPerf = (sPriv->drmMinor >= 16); - screen->drmSupportsFragShader = (sPriv->drmMinor >= 18); - screen->drmSupportsPointSprites = (sPriv->drmMinor >= 13); - screen->drmSupportsCubeMapsR100 = (sPriv->drmMinor >= 15); - screen->drmSupportsVertexProgram = (sPriv->drmMinor >= 25); + screen->drmSupportsCubeMapsR200 = (sPriv->drm_version.minor >= 7); + screen->drmSupportsBlendColor = (sPriv->drm_version.minor >= 11); + screen->drmSupportsTriPerf = (sPriv->drm_version.minor >= 16); + screen->drmSupportsFragShader = (sPriv->drm_version.minor >= 18); + screen->drmSupportsPointSprites = (sPriv->drm_version.minor >= 13); + screen->drmSupportsCubeMapsR100 = (sPriv->drm_version.minor >= 15); + screen->drmSupportsVertexProgram = (sPriv->drm_version.minor >= 25); } screen->mmio.handle = dri_priv->registerHandle; @@ -666,7 +666,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) return NULL; } if ((screen->chip_family == CHIP_FAMILY_R350 || screen->chip_family == CHIP_FAMILY_R300) && - sPriv->ddxMinor < 2) { + sPriv->ddx_version.minor < 2) { fprintf(stderr, "xf86-video-ati-6.6.2 or newer needed for Radeon 9500/9700/9800 cards.\n"); return NULL; } @@ -683,7 +683,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) screen->fbLocation = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff ) << 16; - if ( sPriv->drmMinor >= 10 ) { + if ( sPriv->drm_version.minor >= 10 ) { drm_radeon_setparam_t sp; sp.param = RADEON_SETPARAM_FB_LOCATION; @@ -701,7 +701,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) screen->depthPitch = dri_priv->depthPitch; /* Check if ddx has set up a surface reg to cover depth buffer */ - screen->depthHasSurface = ((sPriv->ddxMajor > 4) && + screen->depthHasSurface = ((sPriv->ddx_version.major > 4) && (screen->chip_flags & RADEON_CHIPSET_TCL)); if ( dri_priv->textureSize == 0 ) { diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index 9678c526aa..b2764f36f6 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -524,7 +524,7 @@ savageCreateContext( const __GLcontextModes *mesaVis, "enable_fastpath"); /* DRM versions before 2.1.3 would only render triangle lists. ELTS * support was added in 2.2.0. */ - if (imesa->enable_fastpath && sPriv->drmMinor < 2) { + if (imesa->enable_fastpath && sPriv->drm_version.minor < 2) { fprintf (stderr, "*** Disabling fast path because your DRM version is buggy " "or doesn't\n*** support ELTS. You need at least Savage DRM " diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c index 719e50f964..1dcfee291f 100644 --- a/src/mesa/drivers/dri/savage/savagetex.c +++ b/src/mesa/drivers/dri/savage/savagetex.c @@ -1016,7 +1016,7 @@ static void savageUploadTexImages( savageContextPtr imesa, savageTexObjPtr t ) /* Heap timestamps are only reliable with Savage DRM 2.3.x or * later. Earlier versions had only 16 bit time stamps which * would wrap too frequently. */ - if (imesa->savageScreen->driScrnPriv->drmMinor >= 3) { + if (imesa->savageScreen->driScrnPriv->drm_version.minor >= 3) { unsigned int heap = t->base.heap->heapId; LOCK_HARDWARE(imesa); savageWaitEvent (imesa, imesa->textureHeaps[heap]->timestamp); @@ -1713,7 +1713,7 @@ static void savageTimestampTextures( savageContextPtr imesa ) * Only useful with long-lived 32-bit event tags available * with Savage DRM 2.3.x or later. */ if ((imesa->CurrentTexObj[0] || imesa->CurrentTexObj[1]) && - imesa->savageScreen->driScrnPriv->drmMinor >= 3) { + imesa->savageScreen->driScrnPriv->drm_version.minor >= 3) { unsigned int e; FLUSH_BATCH(imesa); e = savageEmitEvent(imesa, SAVAGE_WAIT_3D); -- cgit v1.2.3 From 64106d0d9aeefa6974317042b6bc3e5eaabac5a2 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 14 May 2007 16:58:37 -0400 Subject: Pull createNewScreen entry point into dri_util.c. This pulls the top level createNewScreen entry point out of the drivers and rewrites __driUtilCreateNewScreen in dri_util.c to be the new entry point. The change moves more logic into the common/ layer and changes the createNewScreen entry point to only be defined in one place. --- src/mesa/drivers/dri/common/dri_util.c | 59 ++++++++-------- src/mesa/drivers/dri/common/dri_util.h | 12 ++-- src/mesa/drivers/dri/ffb/ffb_xmesa.c | 48 ++++--------- src/mesa/drivers/dri/i810/i810screen.c | 50 ++++---------- src/mesa/drivers/dri/i915/intel_screen.c | 73 ++++++++------------ src/mesa/drivers/dri/i965/intel_screen.c | 77 ++++++++------------- src/mesa/drivers/dri/mach64/mach64_screen.c | 75 +++++++------------- src/mesa/drivers/dri/mga/mga_xmesa.c | 84 +++++++++------------- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 96 ++++++++++---------------- src/mesa/drivers/dri/r128/r128_screen.c | 80 ++++++++------------- src/mesa/drivers/dri/radeon/radeon_screen.c | 96 ++++++++++---------------- src/mesa/drivers/dri/s3v/s3v_xmesa.c | 4 +- src/mesa/drivers/dri/savage/savage_xmesa.c | 80 ++++++++------------- src/mesa/drivers/dri/sis/sis_screen.c | 72 ++++++++----------- src/mesa/drivers/dri/tdfx/tdfx_screen.c | 86 +++++++++-------------- src/mesa/drivers/dri/trident/trident_context.c | 52 ++++++-------- src/mesa/drivers/dri/unichrome/via_screen.c | 76 ++++++++------------ 17 files changed, 421 insertions(+), 699 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 09fc2230fd..9c96392654 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -667,9 +667,12 @@ static void driDestroyScreen(__DRIscreen *screen) /** - * Utility function used to create a new driver-private screen structure. + * This is the bootstrap function for the driver. libGL supplies all of the + * requisite information about the system, and the driver initializes itself. + * This routine also fills in the linked list pointed to by \c driver_modes + * with the \c __GLcontextModes that the driver can support for windows or + * pbuffers. * - * \param dpy Display pointer * \param scrn Index of the screen * \param psc DRI screen data (not driver private) * \param modes Linked list of known display modes. This list is, at a @@ -690,35 +693,34 @@ static void driDestroyScreen(__DRIscreen *screen) * driver and libGL. * \param driverAPI Driver API functions used by other routines in dri_util.c. * - * \note - * There is no need to check the minimum API version in this function. Since - * the \c __driCreateNewScreen function is versioned, it is impossible for a - * loader that is too old to even load this driver. + * \note There is no need to check the minimum API version in this + * function. Since the name of this function is versioned, it is + * impossible for a loader that is too old to even load this driver. */ -__DRIscreenPrivate * -__driUtilCreateNewScreen(int scr, __DRIscreen *psc, - __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drm_sarea_t *pSAREA, - int fd, - int internal_api_version, - const struct __DriverAPIRec *driverAPI) +PUBLIC +void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + const __DRIinterfaceMethods * interface, + __GLcontextModes ** driver_modes ) + { __DRIscreenPrivate *psp; - + dri_interface = interface; api_ver = internal_api_version; - psp = (__DRIscreenPrivate *)_mesa_malloc(sizeof(__DRIscreenPrivate)); - if (!psp) { + psp = _mesa_malloc(sizeof(*psp)); + if (!psp) return NULL; - } psp->psc = psc; - psp->modes = modes; + psp->modes = NULL; /* ** NOT_DONE: This is used by the X server to detect when the client @@ -731,9 +733,6 @@ __driUtilCreateNewScreen(int scr, __DRIscreen *psc, psp->ddx_version = *ddx_version; psp->dri_version = *dri_version; - /* install driver's callback functions */ - memcpy( &psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec) ); - psp->pSAREA = pSAREA; psp->pFB = frame_buffer->base; @@ -746,7 +745,7 @@ __driUtilCreateNewScreen(int scr, __DRIscreen *psc, psp->fbBPP = psp->fbStride * 8 / frame_buffer->width; psp->fd = fd; - psp->myNum = scr; + psp->myNum = scrn; /* ** Do not init dummy context here; actual initialization will be @@ -763,17 +762,15 @@ __driUtilCreateNewScreen(int scr, __DRIscreen *psc, if (internal_api_version >= 20070121) psc->setTexOffset = psp->DriverAPI.setTexOffset; - if ( (psp->DriverAPI.InitDriver != NULL) - && !(*psp->DriverAPI.InitDriver)(psp) ) { - _mesa_free( psp ); + *driver_modes = __driDriverInitScreen(psp); + if (*driver_modes == NULL) { + _mesa_free(psp); return NULL; } - return psp; } - /** * Compare the current GLX API version with a driver supplied required version. * diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 7a70bc7aa6..f56f1fa96a 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -66,6 +66,13 @@ typedef struct __DRIswapInfoRec __DRIswapInfo; typedef struct __DRIutilversionRec2 __DRIutilversion2; +/** + * Driver specific entry point. Implemented by the driver. Called + * from the top level createNewScreen entry point to initialize the + * __DRIscreenPrivate struct. + */ +extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp); + /** * Used by DRI_VALIDATE_DRAWABLE_INFO */ @@ -109,11 +116,6 @@ do { \ * this structure. */ struct __DriverAPIRec { - /** - * Driver initialization callback - */ - GLboolean (*InitDriver)(__DRIscreenPrivate *driScrnPriv); - /** * Screen destruction callback */ diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c index 4cd5b9a208..3a5551eeb3 100644 --- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c +++ b/src/mesa/drivers/dri/ffb/ffb_xmesa.c @@ -605,7 +605,6 @@ void ffbXMesaUpdateState(ffbContextPtr fmesa) } static const struct __DriverAPIRec ffbAPI = { - .InitDriver = ffbInitDriver, .DestroyScreen = ffbDestroyScreen, .CreateContext = ffbCreateContext, .DestroyContext = ffbDestroyContext, @@ -704,49 +703,28 @@ ffbFillInModes( unsigned pixel_bits, unsigned depth_bits, /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 0, 1, 1 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 0, 0, 1 }; - dri_interface = interface; - if ( ! driCheckDriDdxDrmVersions2( "ffb", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) return NULL; - } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &ffbAPI); - if ( psp != NULL ) { - *driver_modes = ffbFillInModes( 32, 16, 0, GL_TRUE ); - } + psp->DriverAPI = ffbAPI; + + if (!ffbInitDriver(psp)) + return NULL; - return (void *) psp; + return ffbFillInModes( 32, 16, 0, GL_TRUE ); } diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c index b04bc38327..3c7ec96ff3 100644 --- a/src/mesa/drivers/dri/i810/i810screen.c +++ b/src/mesa/drivers/dri/i810/i810screen.c @@ -403,7 +403,6 @@ i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv) static const struct __DriverAPIRec i810API = { - .InitDriver = i810InitDriver, .DestroyScreen = i810DestroyScreen, .CreateContext = i810CreateContext, .DestroyContext = i810DestroyContext, @@ -421,51 +420,30 @@ static const struct __DriverAPIRec i810API = { /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. + * + * \todo maybe fold this into intelInitDriver * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void *__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) +PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 0, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 1, 2, 0 }; - dri_interface = interface; - if ( ! driCheckDriDdxDrmVersions2( "i810", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) { return NULL; } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &i810API); - if ( psp != NULL ) { - *driver_modes = i810FillInModes( 16, - 16, 0, - 1); - driInitExtensions( NULL, card_extensions, GL_TRUE ); - } + psp->DriverAPI = i810API; + driInitExtensions( NULL, card_extensions, GL_TRUE ); + + if (!i810InitDriver(psp)) + return NULL; - return (void *) psp; + return i810FillInModes(16, 16, 0, 1); } diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 58dc02e24e..a75133ec73 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -771,7 +771,6 @@ intelCreateContext(const __GLcontextModes * mesaVis, static const struct __DriverAPIRec intelAPI = { - .InitDriver = intelInitDriver, .DestroyScreen = intelDestroyScreen, .CreateContext = intelCreateContext, .DestroyContext = intelDestroyContext, @@ -876,64 +875,46 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits, /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, - __DRIscreen * psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) +PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 5, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 1, 5, 0 }; + I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv; - dri_interface = interface; + psp->DriverAPI = intelAPI; if (!driCheckDriDdxDrmVersions2("i915", - dri_version, &dri_expected, - ddx_version, &ddx_expected, - drm_version, &drm_expected)) { + &psp->dri_version, &dri_expected, + &psp->ddx_version, &ddx_expected, + &psp->drm_version, &drm_expected)) { return NULL; } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &intelAPI); - if (psp != NULL) { - I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv; - *driver_modes = intelFillInModes(dri_priv->cpp * 8, - (dri_priv->cpp == 2) ? 16 : 24, - (dri_priv->cpp == 2) ? 0 : 8, 1); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions(NULL, card_extensions, GL_FALSE); - } + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions(NULL, card_extensions, GL_FALSE); + + if (!intelInitDriver(psp)) + return NULL; - return (void *) psp; + return intelFillInModes(dri_priv->cpp * 8, + (dri_priv->cpp == 2) ? 16 : 24, + (dri_priv->cpp == 2) ? 0 : 8, 1); } struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen) diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index cb6824b7ee..f0bce146b0 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -540,7 +540,6 @@ static GLboolean intelCreateContext( const __GLcontextModes *mesaVis, static const struct __DriverAPIRec intelAPI = { - .InitDriver = intelInitDriver, .DestroyScreen = intelDestroyScreen, .CreateContext = intelCreateContext, .DestroyContext = intelDestroyContext, @@ -639,62 +638,44 @@ intelFillInModes( unsigned pixel_bits, unsigned depth_bits, /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 6, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 1, 3, 0 }; + I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv; - dri_interface = interface; - + psp->DriverAPI = intelAPI; if ( ! driCheckDriDdxDrmVersions2( "i915", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { - return NULL; + &psp->dri_version, &dri_expected, + &psp->ddx_version, &ddx_expected, + &psp->drm_version, &drm_expected ) ) { + return NULL; } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &intelAPI); - if ( psp != NULL ) { - I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv; - *driver_modes = intelFillInModes( dri_priv->cpp * 8, - (dri_priv->cpp == 2) ? 16 : 24, - (dri_priv->cpp == 2) ? 0 : 8, - GL_TRUE ); - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - intelInitExtensions(NULL, GL_FALSE); - } + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + intelInitExtensions(NULL, GL_FALSE); + + if (!intelInitDriver(psp)) + return NULL; - return (void *) psp; + return intelFillInModes( dri_priv->cpp * 8, + (dri_priv->cpp == 2) ? 16 : 24, + (dri_priv->cpp == 2) ? 0 : 8, + GL_TRUE ); } diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index 733a16b6ae..ff261c841d 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -476,7 +476,6 @@ mach64InitDriver( __DRIscreenPrivate *driScreen ) static struct __DriverAPIRec mach64API = { - .InitDriver = mach64InitDriver, .DestroyScreen = mach64DestroyScreen, .CreateContext = mach64CreateContext, .DestroyContext = mach64DestroyContext, @@ -494,63 +493,41 @@ static struct __DriverAPIRec mach64API = { /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 6, 4, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 2, 0, 0 }; + ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv; - dri_interface = interface; - + psp->DriverAPI = mach64API; if ( ! driCheckDriDdxDrmVersions2( "Mach64", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) { return NULL; } + + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, card_extensions, GL_FALSE ); + + if (!mach64InitDriver(psp)) + return NULL; - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &mach64API); - if ( psp != NULL ) { - ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv; - *driver_modes = mach64FillInModes( dri_priv->cpp * 8, - 16, - 0, - 1); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - } - - return (void *) psp; + return mach64FillInModes( dri_priv->cpp * 8, 16, 0, 1); } diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index b001f8696a..5b4693983a 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -934,7 +934,6 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) static const struct __DriverAPIRec mgaAPI = { - .InitDriver = mgaInitDriver, .DestroyScreen = mgaDestroyScreen, .CreateContext = mgaCreateContext, .DestroyContext = mgaDestroyContext, @@ -952,69 +951,50 @@ static const struct __DriverAPIRec mgaAPI = { /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 3, 0, 0 }; + MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv; - dri_interface = interface; - + psp->DriverAPI = mgaAPI; if ( ! driCheckDriDdxDrmVersions2( "MGA", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) return NULL; - } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &mgaAPI); - if ( psp != NULL ) { - MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv; - *driver_modes = mgaFillInModes( dri_priv->cpp * 8, - (dri_priv->cpp == 2) ? 16 : 24, - (dri_priv->cpp == 2) ? 0 : 8, - (dri_priv->backOffset != dri_priv->depthOffset) ); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - driInitExtensions( NULL, g400_extensions, GL_FALSE ); - driInitSingleExtension( NULL, ARB_vp_extension ); - driInitExtensions( NULL, NV_vp_extensions, GL_FALSE ); - } + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + + driInitExtensions( NULL, card_extensions, GL_FALSE ); + driInitExtensions( NULL, g400_extensions, GL_FALSE ); + driInitSingleExtension( NULL, ARB_vp_extension ); + driInitExtensions( NULL, NV_vp_extensions, GL_FALSE ); + + if (!mgaInitDriver(psp)) + return NULL; - return (void *) psp; + return mgaFillInModes( dri_priv->cpp * 8, + (dri_priv->cpp == 2) ? 16 : 24, + (dri_priv->cpp == 2) ? 0 : 8, + (dri_priv->backOffset != dri_priv->depthOffset) ); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index cab53f41ad..3e7bab63f3 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -195,7 +195,6 @@ nouveauGetSwapInfo(__DRIdrawablePrivate *dpriv, __DRIswapInfo *sInfo) } static const struct __DriverAPIRec nouveauAPI = { - .InitDriver = nouveauInitDriver, .DestroyScreen = nouveauDestroyScreen, .CreateContext = nouveauCreateContext, .DestroyContext = nouveauDestroyContext, @@ -285,81 +284,62 @@ nouveauFillInModes( unsigned pixel_bits, unsigned depth_bits, /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; + NOUVEAUDRIPtr dri_priv = (NOUVEAUDRIPtr)psp->pDevPriv; + #if NOUVEAU_DRM_HEADER_PATCHLEVEL != 10 #error nouveau_drm.h version doesn't match expected version #endif - dri_interface = interface; if (!driCheckDriDdxDrmVersions2("nouveau", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected)) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected)) return NULL; - } // temporary lock step versioning - if (drm_expected.patch!=drm_version->patch) { + if (drm_expected.patch != psp->drm_version.patch) { __driUtilMessage("%s: wrong DRM version, expected %d, got %d\n", - __func__, - drm_expected.patch, drm_version->patch); + __func__, + drm_expected.patch, psp->drm_version.patch); return NULL; } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &nouveauAPI); - if ( psp != NULL ) { - NOUVEAUDRIPtr dri_priv = (NOUVEAUDRIPtr)psp->pDevPriv; - - *driver_modes = nouveauFillInModes(dri_priv->bpp, - (dri_priv->bpp == 16) ? 16 : 24, - (dri_priv->bpp == 16) ? 0 : 8, - 1 - ); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, common_extensions, GL_FALSE ); - driInitExtensions( NULL, nv10_extensions, GL_FALSE ); - driInitExtensions( NULL, nv10_extensions, GL_FALSE ); - driInitExtensions( NULL, nv30_extensions, GL_FALSE ); - driInitExtensions( NULL, nv40_extensions, GL_FALSE ); - driInitExtensions( NULL, nv50_extensions, GL_FALSE ); - } + psp->DriverAPI = nouveauAPI; + + /* Calling driInitExtensions here, with a NULL context + * pointer, does not actually enable the extensions. It just + * makes sure that all the dispatch offsets for all the + * extensions that *might* be enables are known. This is + * needed because the dispatch offsets need to be known when + * _mesa_context_create is called, but we can't enable the + * extensions until we have a context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, common_extensions, GL_FALSE ); + driInitExtensions( NULL, nv10_extensions, GL_FALSE ); + driInitExtensions( NULL, nv10_extensions, GL_FALSE ); + driInitExtensions( NULL, nv30_extensions, GL_FALSE ); + driInitExtensions( NULL, nv40_extensions, GL_FALSE ); + driInitExtensions( NULL, nv50_extensions, GL_FALSE ); + + if (!nouveauInitDriver(psp)) + return NULL; - return (void *) psp; + return nouveauFillInModes(dri_priv->bpp, + (dri_priv->bpp == 16) ? 16 : 24, + (dri_priv->bpp == 16) ? 0 : 8, + 1); } diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 01b33d6493..446280c399 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -403,7 +403,6 @@ r128InitDriver( __DRIscreenPrivate *sPriv ) static struct __DriverAPIRec r128API = { - .InitDriver = r128InitDriver, .DestroyScreen = r128DestroyScreen, .CreateContext = r128CreateContext, .DestroyContext = r128DestroyContext, @@ -503,64 +502,43 @@ r128FillInModes( unsigned pixel_bits, unsigned depth_bits, /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 4, 0, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 2, 2, 0 }; + R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv; - - dri_interface = interface; - + psp->DriverAPI = r128API; if ( ! driCheckDriDdxDrmVersions2( "Rage128", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) return NULL; - } - - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &r128API); - if ( psp != NULL ) { - R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv; - *driver_modes = r128FillInModes( dri_priv->bpp, - (dri_priv->bpp == 16) ? 16 : 24, - (dri_priv->bpp == 16) ? 0 : 8, - (dri_priv->backOffset != dri_priv->depthOffset) ); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - } - return (void *) psp; + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, card_extensions, GL_FALSE ); + + if (!r128InitDriver(psp)) + return NULL; + + return r128FillInModes( dri_priv->bpp, + (dri_priv->bpp == 16) ? 16 : 24, + (dri_priv->bpp == 16) ? 0 : 8, + (dri_priv->backOffset != dri_priv->depthOffset) ); } diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 9801322cd8..b7e0b5a0fa 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -938,7 +938,6 @@ static void radeonDestroyContext(__DRIcontextPrivate * driContextPriv) #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)) static struct __DriverAPIRec radeonAPI = { - .InitDriver = radeonInitDriver, .DestroyScreen = radeonDestroyScreen, .CreateContext = radeonCreateContext, .DestroyContext = radeonDestroyContext, @@ -959,7 +958,6 @@ static struct __DriverAPIRec radeonAPI = { }; #else static const struct __DriverAPIRec r200API = { - .InitDriver = radeonInitDriver, .DestroyScreen = radeonDestroyScreen, .CreateContext = r200CreateContext, .DestroyContext = r200DestroyContext, @@ -978,29 +976,16 @@ static const struct __DriverAPIRec r200API = { }; #endif + /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. + * + * \todo maybe fold this into intelInitDriver * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \return the __GLcontextModes supported by this driver */ -PUBLIC void * -__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; #if !RADEON_COMMON static const char *driver_name = "Radeon"; static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 }; @@ -1017,57 +1002,46 @@ __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 1, 24, 0 }; #endif - - dri_interface = interface; + RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv; if ( ! driCheckDriDdxDrmVersions3( driver_name, - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) { return NULL; } #if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)) - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &radeonAPI); + psp->DriverAPI = radeonAPI; #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &r200API); + psp->DriverAPI = r200API; #endif - if ( psp != NULL ) { - RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv; - if (driver_modes) { - *driver_modes = radeonFillInModes( dri_priv->bpp, - (dri_priv->bpp == 16) ? 16 : 24, - (dri_priv->bpp == 16) ? 0 : 8, - (dri_priv->backOffset != dri_priv->depthOffset) ); - } - - /* Calling driInitExtensions here, with a NULL context pointer, - * does not actually enable the extensions. It just makes sure - * that all the dispatch offsets for all the extensions that - * *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create - * is called, but we can't enable the extensions until we have a - * context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create + * is called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, card_extensions, GL_FALSE ); #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) - driInitExtensions( NULL, blend_extensions, GL_FALSE ); - driInitSingleExtension( NULL, ARB_vp_extension ); - driInitSingleExtension( NULL, NV_vp_extension ); - driInitSingleExtension( NULL, ATI_fs_extension ); - driInitExtensions( NULL, point_extensions, GL_FALSE ); + driInitExtensions( NULL, blend_extensions, GL_FALSE ); + driInitSingleExtension( NULL, ARB_vp_extension ); + driInitSingleExtension( NULL, NV_vp_extension ); + driInitSingleExtension( NULL, ATI_fs_extension ); + driInitExtensions( NULL, point_extensions, GL_FALSE ); #endif - } - return (void *) psp; + if (!radeonInitDriver(psp)) + return NULL; + + return radeonFillInModes( dri_priv->bpp, + (dri_priv->bpp == 16) ? 16 : 24, + (dri_priv->bpp == 16) ? 0 : 8, + (dri_priv->backOffset != dri_priv->depthOffset) ); } diff --git a/src/mesa/drivers/dri/s3v/s3v_xmesa.c b/src/mesa/drivers/dri/s3v/s3v_xmesa.c index c66fd6dac3..7b0b006b69 100644 --- a/src/mesa/drivers/dri/s3v/s3v_xmesa.c +++ b/src/mesa/drivers/dri/s3v/s3v_xmesa.c @@ -329,7 +329,6 @@ s3vUnbindContext( __DRIcontextPrivate *driContextPriv ) static struct __DriverAPIRec s3vAPI = { - s3vInitDriver, s3vDestroyScreen, s3vCreateContext, s3vDestroyContext, @@ -355,6 +354,9 @@ void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, DEBUG(("__driCreateScreen: psp = %p\n", psp)); psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &s3vAPI); DEBUG(("__driCreateScreen: psp = %p\n", psp)); + if (!s3vInitDriver(psp)) + return NULLL + return (void *) psp; } #endif diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index b2764f36f6..3750c8948a 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -919,7 +919,6 @@ void savageGetLock( savageContextPtr imesa, GLuint flags ) static const struct __DriverAPIRec savageAPI = { - savageInitDriver, savageDestroyScreen, savageCreateContext, savageDestroyContext, @@ -1016,63 +1015,44 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits, /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes ) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 2, 0, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 2, 1, 0 }; - - dri_interface = interface; + SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv; if ( ! driCheckDriDdxDrmVersions2( "Savage", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) return NULL; - } - - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &savageAPI); - if ( psp != NULL ) { - SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv; - *driver_modes = savageFillInModes( dri_priv->cpp*8, - (dri_priv->cpp == 2) ? 16 : 24, - (dri_priv->cpp == 2) ? 0 : 8, - (dri_priv->backOffset != dri_priv->depthOffset) ); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - } - return (void *) psp; + psp->DriverAPI = savageAPI; + + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, card_extensions, GL_FALSE ); + + if (!savageInitDriver(psp)) + return NULL; + + return savageFillInModes( dri_priv->cpp*8, + (dri_priv->cpp == 2) ? 16 : 24, + (dri_priv->cpp == 2) ? 0 : 8, + (dri_priv->backOffset != dri_priv->depthOffset) ); } diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c index a1275f0026..79682a7253 100644 --- a/src/mesa/drivers/dri/sis/sis_screen.c +++ b/src/mesa/drivers/dri/sis/sis_screen.c @@ -304,7 +304,6 @@ sisInitDriver( __DRIscreenPrivate *sPriv ) } static struct __DriverAPIRec sisAPI = { - .InitDriver = sisInitDriver, .DestroyScreen = sisDestroyScreen, .CreateContext = sisCreateContext, .DestroyContext = sisDestroyContext, @@ -323,59 +322,42 @@ static struct __DriverAPIRec sisAPI = { /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. + * + * \todo maybe fold this into intelInitDriver * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes *modes, - const __DRIversion *ddx_version, - const __DRIversion *dri_version, - const __DRIversion *drm_version, - const __DRIframebuffer *frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes **driver_modes) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = {0, 8, 0}; static const __DRIversion dri_expected = {4, 0, 0}; static const __DRIversion drm_expected = {1, 0, 0}; static const char *driver_name = "SiS"; - dri_interface = interface; + SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv; - if (!driCheckDriDdxDrmVersions2(driver_name, dri_version, &dri_expected, - ddx_version, &ddx_expected, - drm_version, &drm_expected)) { + if (!driCheckDriDdxDrmVersions2(driver_name, + &psp->dri_version, &dri_expected, + &psp->ddx_version, &ddx_expected, + &psp->drm_version, &drm_expected)) return NULL; - } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &sisAPI); - if (psp != NULL) { - SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv; - *driver_modes = sisFillInModes(dri_priv->bytesPerPixel * 8); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - } + psp->DriverAPI = sisAPI; + + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, card_extensions, GL_FALSE ); + + if (!sisInitDriver(psp)) + return NULL; - return (void *)psp; + return sisFillInModes(dri_priv->bytesPerPixel * 8); } diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c index e9033c5ef3..081a534035 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c @@ -345,7 +345,6 @@ tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv ) static const struct __DriverAPIRec tdfxAPI = { - .InitDriver = tdfxInitDriver, .DestroyScreen = tdfxDestroyScreen, .CreateContext = tdfxCreateContext, .DestroyContext = tdfxDestroyContext, @@ -431,69 +430,50 @@ static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits, } /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. + * + * \todo maybe fold this into intelInitDriver * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void *__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 1, 1, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 1, 0, 0 }; - dri_interface = interface; + /* divined from tdfx_dri.c, sketchy */ + TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv; + + /* XXX i wish it was like this */ + /* bpp = dri_priv->bpp */ + int bpp = (dri_priv->cpp > 2) ? 24 : 16; if ( ! driCheckDriDdxDrmVersions2( "tdfx", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) return NULL; - } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &tdfxAPI); - - if (psp != NULL) { - /* divined from tdfx_dri.c, sketchy */ - TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv; - int bpp = (dri_priv->cpp > 2) ? 24 : 16; + psp->DriverAPI = tdfxAPI; + + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, card_extensions, GL_FALSE ); + driInitExtensions( NULL, napalm_extensions, GL_FALSE ); - /* XXX i wish it was like this */ - /* bpp = dri_priv->bpp */ + if (!tdfxInitDriver(psp)) + return NULL; - *driver_modes = tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24, - (bpp == 16) ? 0 : 8, - (dri_priv->backOffset!=dri_priv->depthOffset)); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - driInitExtensions( NULL, napalm_extensions, GL_FALSE ); - } - - return (void *)psp; + return tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24, + (bpp == 16) ? 0 : 8, + (dri_priv->backOffset!=dri_priv->depthOffset)); } diff --git a/src/mesa/drivers/dri/trident/trident_context.c b/src/mesa/drivers/dri/trident/trident_context.c index 1d2a49e6f4..81098bc9cd 100644 --- a/src/mesa/drivers/dri/trident/trident_context.c +++ b/src/mesa/drivers/dri/trident/trident_context.c @@ -418,7 +418,6 @@ tridentInitDriver(__DRIscreenPrivate *sPriv) } static struct __DriverAPIRec tridentAPI = { - tridentInitDriver, tridentDestroyScreen, tridentCreateContext, tridentDestroyContext, @@ -430,43 +429,36 @@ static struct __DriverAPIRec tridentAPI = { }; -PUBLIC void * -__DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) +/** + * This is the driver specific part of the createNewScreen entry point. + * + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver + */ +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { 4, 0, 0 }; static const __DRIversion dri_expected = { 3, 1, 0 }; static const __DRIversion drm_expected = { 1, 0, 0 }; - - dri_interface = interface; - + if ( ! driCheckDriDdxDrmVersions2( "Trident", - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected ) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected ) ) return NULL; - } - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &tridentAPI); + psp->DriverAPI = tridentAPI; + + if (!tridentInitDriver(psp)) + return NULL; - if ( psp != NULL ) { + /* Wait... what? This driver doesn't report any modes... */ #if 0 - TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv; - *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8, - GL_TRUE ); + TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv; + *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8, + GL_TRUE ); #endif - } - return (void *) psp; + + return NULL; } diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index 22e4bcebc9..53f4c5c564 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -325,7 +325,6 @@ viaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) static struct __DriverAPIRec viaAPI = { - .InitDriver = viaInitDriver, .DestroyScreen = viaDestroyScreen, .CreateContext = viaCreateContext, .DestroyContext = viaDestroyContext, @@ -407,66 +406,47 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer ) /** - * This is the bootstrap function for the driver. libGL supplies all of the - * requisite information about the system, and the driver initializes itself. - * This routine also fills in the linked list pointed to by \c driver_modes - * with the \c __GLcontextModes that the driver can support for windows or - * pbuffers. + * This is the driver specific part of the createNewScreen entry point. * - * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on - * failure. + * \todo maybe fold this into intelInitDriver + * + * \return the __GLcontextModes supported by this driver */ -PUBLIC -void * __DRI_CREATE_NEW_SCREEN(int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, - const __DRIversion * ddx_version, - const __DRIversion * dri_version, - const __DRIversion * drm_version, - const __DRIframebuffer * frame_buffer, - drmAddress pSAREA, int fd, - int internal_api_version, - const __DRIinterfaceMethods * interface, - __GLcontextModes ** driver_modes) - +__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) { - __DRIscreenPrivate *psp; static const __DRIversion ddx_expected = { VIA_DRIDDX_VERSION_MAJOR, VIA_DRIDDX_VERSION_MINOR, VIA_DRIDDX_VERSION_PATCH }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 2, 3, 0 }; static const char *driver_name = "Unichrome"; - - dri_interface = interface; + VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv; if ( ! driCheckDriDdxDrmVersions2( driver_name, - dri_version, & dri_expected, - ddx_version, & ddx_expected, - drm_version, & drm_expected) ) { + &psp->dri_version, & dri_expected, + &psp->ddx_version, & ddx_expected, + &psp->drm_version, & drm_expected) ) return NULL; - } - - psp = __driUtilCreateNewScreen(scrn, psc, NULL, - ddx_version, dri_version, drm_version, - frame_buffer, pSAREA, fd, - internal_api_version, &viaAPI); - if ( psp != NULL ) { - VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv; - *driver_modes = viaFillInModes( dri_priv->bytesPerPixel * 8, - GL_TRUE ); - - /* Calling driInitExtensions here, with a NULL context pointer, does not actually - * enable the extensions. It just makes sure that all the dispatch offsets for all - * the extensions that *might* be enables are known. This is needed because the - * dispatch offsets need to be known when _mesa_context_create is called, but we can't - * enable the extensions until we have a context pointer. - * - * Hello chicken. Hello egg. How are you two today? - */ - driInitExtensions( NULL, card_extensions, GL_FALSE ); - } - return (void *) psp; + psp->DriverAPI = viaAPI; + + /* Calling driInitExtensions here, with a NULL context pointer, + * does not actually enable the extensions. It just makes sure + * that all the dispatch offsets for all the extensions that + * *might* be enables are known. This is needed because the + * dispatch offsets need to be known when _mesa_context_create is + * called, but we can't enable the extensions until we have a + * context pointer. + * + * Hello chicken. Hello egg. How are you two today? + */ + driInitExtensions( NULL, card_extensions, GL_FALSE ); + + if (!viaInitDriver(psp)) + return NULL; + + return viaFillInModes( dri_priv->bytesPerPixel * 8, GL_TRUE ); + } -- cgit v1.2.3 From 295dc2d225ccac1951c0fcc2c08119f31d1b575c Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 14 May 2007 17:07:16 -0400 Subject: Stop passing in unused fbconfigs to createNewScreen. --- include/GL/internal/dri_interface.h | 1 - src/glx/x11/glxext.c | 4 +--- src/mesa/drivers/dri/common/dri_util.c | 5 ----- src/mesa/drivers/dri/common/dri_util.h | 11 ----------- 4 files changed, 1 insertion(+), 20 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 178134270d..aa2b1cf805 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -115,7 +115,6 @@ typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) (__DRIscreen *screen, #define __DRI_INTERFACE_VERSION 20070105 typedef void *(CREATENEWSCREENFUNC)(int scr, __DRIscreen *psc, - const __GLcontextModes * modes, const __DRIversion * ddx_version, const __DRIversion * dri_version, const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer, void * pSAREA, int fd, int internal_api_version, diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 8c12ae254a..ee8e238bec 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -957,7 +957,6 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc, err_extra = NULL; psp = (*createNewScreen)(scrn, &psc->driScreen, - psc->configs, & ddx_version, & dri_version, & drm_version, @@ -968,8 +967,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc, & interface_methods, & driver_modes ); - filter_modes( & psc->configs, - driver_modes ); + filter_modes(&psc->configs, driver_modes); _gl_context_modes_destroy( driver_modes ); } } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 9c96392654..84a6d819de 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -657,9 +657,6 @@ static void driDestroyScreen(__DRIscreen *screen) (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize); (void)drmCloseOnce(psp->fd); - if ( psp->modes != NULL ) { - (*dri_interface->destroyContextModes)( psp->modes ); - } _mesa_free(psp); } @@ -699,7 +696,6 @@ static void driDestroyScreen(__DRIscreen *screen) */ PUBLIC void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, - const __GLcontextModes * modes, const __DRIversion * ddx_version, const __DRIversion * dri_version, const __DRIversion * drm_version, @@ -720,7 +716,6 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, return NULL; psp->psc = psc; - psp->modes = NULL; /* ** NOT_DONE: This is used by the X server to detect when the client diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index f56f1fa96a..5ac2eea722 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -458,17 +458,6 @@ struct __DRIscreenPrivateRec { */ void *private; - /** - * GLX visuals / FBConfigs for this screen. These are stored as a - * linked list. - * - * \note - * This field is \b only used in conjunction with the old interfaces. If - * the new interfaces are used, this field will be set to \c NULL and will - * not be dereferenced. - */ - __GLcontextModes *modes; - /** * Pointer back to the \c __DRIscreen that contains this structure. */ -- cgit v1.2.3 From f616a263a25eda135800bea7d3a863c569b93e30 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 15 May 2007 12:31:31 -0400 Subject: Implement new screen extension API. This new API lets the loader examine DRI level extensions provided by the driver in a forward compatible manner. Much of the churn in the DRI interface is adding support for new extensions or removing old, unused extensions. This new extension mechanism lets the loader query the extensions provided by the driver and implement the extensions it knows about. Deprecating extensions is done by not exporting that extension in the list, which doesn't require keeping old function pointers around to preserve ABI. --- include/GL/internal/dri_interface.h | 20 ++++++++++++++++++++ src/glx/x11/glxext.c | 14 ++++++++++++++ src/mesa/drivers/dri/common/dri_util.c | 9 +++++++++ 3 files changed, 43 insertions(+) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index aa2b1cf805..ee73233771 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -56,9 +56,24 @@ typedef struct __DRIdriverRec __DRIdriver; typedef struct __DRIframebufferRec __DRIframebuffer; typedef struct __DRIversionRec __DRIversion; typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods; + +typedef struct __DRIextensionRec __DRIextension; /*@}*/ +/** + * Extension struct. Drivers 'inherit' from this struct by embedding + * it as the first element in the extension struct. The + * __DRIscreen::getExtensions entry point will return a list of these + * structs and the loader can use the extensions it knows about by + * casting it to a more specific extension and optionally advertising + * the GLX extension. See below for examples. + */ +struct __DRIextensionRec { + const char *name; +}; + + /** * \name Functions provided by the driver loader. */ @@ -274,6 +289,11 @@ struct __DRIscreenRec { */ void (*destroyScreen)(__DRIscreen *screen); + /** + * Method to get screen extensions. + */ + const __DRIextension **(*getExtensions)(__DRIscreen *screen); + /** * Method to create the private DRI drawable data and initialize the * drawable dependent methods. diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index ee8e238bec..cb187717f1 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -1011,6 +1011,18 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc, return psp; } + +static void queryExtensions(__GLXscreenConfigs *psc) +{ + const __DRIextension **extensions; + int i; + + extensions = psc->driScreen.getExtensions(&psc->driScreen); + for (i = 0; extensions[i]; i++) { + /* Unknown extension, just ignore... */ + } +} + #endif /* GLX_DIRECT_RENDERING */ @@ -1205,6 +1217,8 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv) CallCreateNewScreen(dpy, i, psc, & priv->driDisplay, priv->driDisplay.createNewScreen[i] ); + if (psc->driScreen.private != NULL) + queryExtensions(psc); } } #endif diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 84a6d819de..c8be7b0706 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -624,6 +624,14 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, } /*@}*/ +static const __DRIextension ** +driGetExtensions(__DRIscreen *screen) +{ + __DRIscreenPrivate *psp = screen->private; + static const __DRIextension *extensions[1]; + + return extensions; +} /*****************************************************************/ /** \name Screen handling functions */ @@ -750,6 +758,7 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, psp->dummyContextPriv.driScreenPriv = NULL; psc->destroyScreen = driDestroyScreen; + psc->getExtensions = driGetExtensions; psc->createNewDrawable = driCreateNewDrawable; psc->getMSC = driGetMSC; psc->createNewContext = driCreateNewContext; -- cgit v1.2.3 From ac3e838fa748c8c8a6ffc04d1ab13da71f75f103 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 15 May 2007 15:17:30 -0400 Subject: Move the copySubBuffer extension over to the new mechanism. --- include/GL/internal/dri_interface.h | 18 ++++++++++-------- src/glx/x11/glxclient.h | 5 +++++ src/glx/x11/glxcmds.c | 6 +++--- src/glx/x11/glxext.c | 10 +++++++++- src/mesa/drivers/dri/common/dri_util.c | 14 ++++++++------ src/mesa/drivers/dri/common/dri_util.h | 11 ++++++++++- src/mesa/drivers/dri/i915/intel_screen.c | 10 ++++++++-- src/mesa/drivers/dri/i965/intel_screen.c | 7 ++++++- src/mesa/drivers/dri/radeon/radeon_screen.c | 7 ++++++- 9 files changed, 65 insertions(+), 23 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index ee73233771..e2050c16b4 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -58,6 +58,7 @@ typedef struct __DRIversionRec __DRIversion; typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods; typedef struct __DRIextensionRec __DRIextension; +typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension; /*@}*/ @@ -73,6 +74,15 @@ struct __DRIextensionRec { const char *name; }; +/** + * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension. + */ +#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer" +struct __DRIcopySubBufferExtensionRec { + __DRIextension base; + void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h); +}; + /** * \name Functions provided by the driver loader. @@ -481,14 +491,6 @@ struct __DRIdrawableRec { * \since Internal API version 20030317. */ unsigned swap_interval; - - /** - * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension. - * - * \since Internal API version 20060314. - */ - void (*copySubBuffer)(__DRIdrawable *drawable, - int x, int y, int w, int h); }; #endif diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index 5697325175..2c73028239 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -476,6 +476,11 @@ struct __GLXscreenConfigsRec { __glxHashTable *drawHash; Display *dpy; int scr; + +#ifdef __DRI_COPY_SUB_BUFFER + __DRIcopySubBufferExtension *copySubBuffer; +#endif + #endif /** diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 6b8824d824..1bc5fff957 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -2498,13 +2498,13 @@ static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr; CARD8 opcode; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_COPY_SUB_BUFFER int screen; __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen ); if ( pdraw != NULL ) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); - if ( __glXExtensionBitIsEnabled( psc, MESA_copy_sub_buffer_bit ) ) { - (*pdraw->copySubBuffer)(pdraw, x, y, width, height); + if (psc->copySubBuffer != NULL) { + (*psc->copySubBuffer->copySubBuffer)(pdraw, x, y, width, height); } return; diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index cb187717f1..d0a7a64445 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -1019,7 +1019,15 @@ static void queryExtensions(__GLXscreenConfigs *psc) extensions = psc->driScreen.getExtensions(&psc->driScreen); for (i = 0; extensions[i]; i++) { - /* Unknown extension, just ignore... */ +#ifdef __DRI_COPY_SUB_BUFFER + if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) { + psc->copySubBuffer = (__DRIcopySubBufferExtension *) extensions[i]; + __glXScrEnableExtension(&psc->driScreen, + "GLX_MESA_copy_sub_buffer"); + + } +#endif + /* Ignore unknown extensions */ } } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index c8be7b0706..fc7755797d 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -431,6 +431,10 @@ static void driCopySubBuffer(__DRIdrawable *drawable, dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h); } +const __DRIcopySubBufferExtension driCopySubBufferExtension = { + { __DRI_COPY_SUB_BUFFER }, driCopySubBuffer +}; + /** * This is called via __DRIscreenRec's createNewDrawable pointer. */ @@ -493,9 +497,6 @@ static void *driCreateNewDrawable(__DRIscreen *screen, pdraw->frameTracking = NULL; pdraw->queryFrameTracking = driQueryFrameTracking; - if (driCompareGLXAPIVersion (20060314) >= 0) - pdraw->copySubBuffer = driCopySubBuffer; - /* This special default value is replaced with the configured * default value when the drawable is first bound to a direct * rendering context. @@ -624,13 +625,13 @@ driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, } /*@}*/ + static const __DRIextension ** driGetExtensions(__DRIscreen *screen) { __DRIscreenPrivate *psp = screen->private; - static const __DRIextension *extensions[1]; - return extensions; + return psp->extensions; } /*****************************************************************/ @@ -715,7 +716,7 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, { __DRIscreenPrivate *psp; - + static const __DRIextension emptyExtensionList[] = { NULL }; dri_interface = interface; api_ver = internal_api_version; @@ -747,6 +748,7 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, psp->pDevPriv = frame_buffer->dev_priv; psp->fbBPP = psp->fbStride * 8 / frame_buffer->width; + psp->extensions = emptyExtensionList; psp->fd = fd; psp->myNum = scrn; diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 5ac2eea722..59bb66d21b 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -73,6 +73,11 @@ typedef struct __DRIutilversionRec2 __DRIutilversion2; */ extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp); +/** + * Extensions. + */ +extern const __DRIcopySubBufferExtension driCopySubBufferExtension; + /** * Used by DRI_VALIDATE_DRAWABLE_INFO */ @@ -461,8 +466,12 @@ struct __DRIscreenPrivateRec { /** * Pointer back to the \c __DRIscreen that contains this structure. */ - __DRIscreen *psc; + + /** + * Extensions provided by this driver. + */ + const __DRIextension **extensions; }; diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index a75133ec73..792f26b5ed 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -419,9 +419,13 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, intelPrintSAREA(sarea); } +static const __DRIextension *intelExtensions[] = { + &driCopySubBufferExtension.base, + NULL +}; -static GLboolean -intelInitDriver(__DRIscreenPrivate * sPriv) + +static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) { intelScreenPrivate *intelScreen; I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv; @@ -522,6 +526,8 @@ intelInitDriver(__DRIscreenPrivate * sPriv) } } + sPriv->extensions = intelExtensions; + if (glx_enable_extension != NULL) { (*glx_enable_extension) (sPriv->psc, "GLX_SGI_swap_control"); (*glx_enable_extension) (sPriv->psc, "GLX_SGI_video_sync"); diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index f0bce146b0..1f74103f65 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -264,6 +264,10 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, intelPrintSAREA(sarea); } +static const __DRIextension *intelExtensions[] = { + &driCopySubBufferExtension.base, + NULL +}; static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) { @@ -350,13 +354,14 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) } } + sPriv->extensions = intelExtensions; + if (glx_enable_extension != NULL) { (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" ); (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_copy_sub_buffer" ); } return GL_TRUE; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index b7e0b5a0fa..7e533fef2c 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -332,6 +332,10 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_bits, return modes; } +static const __DRIextension *radeonExtensions[] = { + &driCopySubBufferExtension.base, + NULL +}; /* Create the device specific screen private data struct. */ @@ -731,6 +735,8 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) dri_priv->log2GARTTexGran; } + sPriv->extensions = radeonExtensions; + if ( glx_enable_extension != NULL ) { if ( screen->irq != 0 ) { (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); @@ -742,7 +748,6 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) if (IS_R200_CLASS(screen)) (*glx_enable_extension)( sPriv->psc, "GLX_MESA_allocate_memory" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_copy_sub_buffer" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); } -- cgit v1.2.3 From efaf90b03e8b69e04909bce071f8ef6b65cc0e9d Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 15 May 2007 16:09:44 -0400 Subject: Move swap_interval to new extension mechanism. --- include/GL/internal/dri_interface.h | 19 +++++++++++-------- src/glx/x11/glxclient.h | 4 ++++ src/glx/x11/glxcmds.c | 25 +++++++++++-------------- src/glx/x11/glxext.c | 12 ++++++++++++ src/mesa/drivers/dri/common/dri_util.c | 28 ++++++++++++++++++++++++---- src/mesa/drivers/dri/common/dri_util.h | 7 +++++++ src/mesa/drivers/dri/common/vblank.c | 10 +++++----- src/mesa/drivers/dri/i915/intel_context.c | 2 +- src/mesa/drivers/dri/i915/intel_screen.c | 3 +-- src/mesa/drivers/dri/i965/intel_screen.c | 3 +-- src/mesa/drivers/dri/mach64/mach64_screen.c | 8 ++++++-- src/mesa/drivers/dri/mach64/mach64_screen.h | 2 ++ src/mesa/drivers/dri/mga/mga_xmesa.c | 9 +++++++-- src/mesa/drivers/dri/r128/r128_screen.c | 7 +++++-- src/mesa/drivers/dri/r128/r128_screen.h | 2 ++ src/mesa/drivers/dri/radeon/radeon_screen.c | 14 ++++++-------- src/mesa/drivers/dri/radeon/radeon_screen.h | 2 ++ src/mesa/drivers/dri/unichrome/via_screen.c | 7 +++++-- src/mesa/drivers/dri/unichrome/via_screen.h | 2 ++ 19 files changed, 114 insertions(+), 52 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index e2050c16b4..7eb168a1b9 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -59,6 +59,7 @@ typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods; typedef struct __DRIextensionRec __DRIextension; typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension; +typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension; /*@}*/ @@ -83,6 +84,16 @@ struct __DRIcopySubBufferExtensionRec { void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h); }; +/** + * Used by drivers that implement the GLX_SGI_swap_control or + * GLX_MESA_swap_control extension. + */ +#define __DRI_SWAP_CONTROL "DRI_SwapControl" +struct __DRIswapControlExtensionRec { + __DRIextension base; + void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval); + unsigned int (*getSwapInterval)(__DRIdrawable *drawable); +}; /** * \name Functions provided by the driver loader. @@ -483,14 +494,6 @@ struct __DRIdrawableRec { int (*queryFrameTracking)(__DRIdrawable *drawable, int64_t * sbc, int64_t * missedFrames, float * lastMissedUsage, float * usage); - - /** - * Used by drivers that implement the GLX_SGI_swap_control or - * GLX_MESA_swap_control extension. - * - * \since Internal API version 20030317. - */ - unsigned swap_interval; }; #endif diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index 2c73028239..09ae70212a 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -481,6 +481,10 @@ struct __GLXscreenConfigsRec { __DRIcopySubBufferExtension *copySubBuffer; #endif +#ifdef __DRI_SWAP_CONTROL + __DRIswapControlExtension *swapControl; +#endif + #endif /** diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 1bc5fff957..6fda5125db 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -1731,16 +1731,15 @@ static int __glXSwapIntervalSGI(int interval) return GLX_BAD_VALUE; } -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_CONTROL if ( gc->isDirect ) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); __DRIdrawable * const pdraw = GetDRIDrawable( gc->currentDpy, gc->currentDrawable, NULL ); - if ( __glXExtensionBitIsEnabled( psc, SGI_swap_control_bit ) - && (pdraw != NULL) ) { - pdraw->swap_interval = interval; + if (psc->swapControl != NULL && pdraw != NULL) { + psc->swapControl->setSwapInterval(pdraw, interval); return 0; } else { @@ -1778,7 +1777,7 @@ static int __glXSwapIntervalSGI(int interval) */ static int __glXSwapIntervalMESA(unsigned int interval) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_CONTROL GLXContext gc = __glXGetCurrentContext(); if ( interval < 0 ) { @@ -1789,12 +1788,11 @@ static int __glXSwapIntervalMESA(unsigned int interval) __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( (psc != NULL) && (psc->driScreen.private != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) { + if ( (psc != NULL) && (psc->driScreen.private != NULL) ) { __DRIdrawable * const pdraw = GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); - if ( pdraw != NULL ) { - pdraw->swap_interval = interval; + if (psc->swapControl != NULL && pdraw != NULL) { + psc->swapControl->setSwapInterval(pdraw, interval); return 0; } } @@ -1809,19 +1807,18 @@ static int __glXSwapIntervalMESA(unsigned int interval) static int __glXGetSwapIntervalMESA(void) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_CONTROL GLXContext gc = __glXGetCurrentContext(); if ( (gc != NULL) && gc->isDirect ) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( (psc != NULL) && (psc->driScreen.private != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) { + if ( (psc != NULL) && (psc->driScreen.private != NULL) ) { __DRIdrawable * const pdraw = GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); - if ( pdraw != NULL ) { - return pdraw->swap_interval; + if (psc->swapControl != NULL && pdraw != NULL) { + return psc->swapControl->getSwapInterval(pdraw); } } } diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index d0a7a64445..1563ca6394 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -1027,6 +1027,18 @@ static void queryExtensions(__GLXscreenConfigs *psc) } #endif + +#ifdef __DRI_SWAP_CONTROL + if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) { + psc->swapControl = (__DRIswapControlExtension *) extensions[i]; + __glXScrEnableExtension(&psc->driScreen, + "GLX_SGI_swap_control"); + __glXScrEnableExtension(&psc->driScreen, + "GLX_MESA_swap_control"); + + } +#endif + /* Ignore unknown extensions */ } } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index fc7755797d..ba677f6ff8 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -435,6 +435,27 @@ const __DRIcopySubBufferExtension driCopySubBufferExtension = { { __DRI_COPY_SUB_BUFFER }, driCopySubBuffer }; +static void driSetSwapInterval(__DRIdrawable *drawable, unsigned int interval) +{ + __DRIdrawablePrivate *dpriv = drawable->private; + + dpriv->swap_interval = interval; +} + +static unsigned int driGetSwapInterval(__DRIdrawable *drawable) +{ + __DRIdrawablePrivate *dpriv = drawable->private; + + return dpriv->swap_interval; +} + +const __DRIswapControlExtension driSwapControlExtension = { + { __DRI_SWAP_CONTROL }, + driSetSwapInterval, + driGetSwapInterval +}; + + /** * This is called via __DRIscreenRec's createNewDrawable pointer. */ @@ -501,7 +522,7 @@ static void *driCreateNewDrawable(__DRIscreen *screen, * default value when the drawable is first bound to a direct * rendering context. */ - pdraw->swap_interval = (unsigned)-1; + pdp->swap_interval = (unsigned)-1; pdp->swapBuffers = psp->DriverAPI.SwapBuffers; @@ -716,7 +737,7 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, { __DRIscreenPrivate *psp; - static const __DRIextension emptyExtensionList[] = { NULL }; + static const __DRIextension *emptyExtensionList[] = { NULL }; dri_interface = interface; api_ver = internal_api_version; @@ -868,8 +889,7 @@ driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust, if ( (*dri_interface->getMSCRate)(dPriv->pdraw, &n, &d) ) { - interval = (dPriv->pdraw->swap_interval != 0) - ? dPriv->pdraw->swap_interval : 1; + interval = (dPriv->swap_interval != 0) ? dPriv->swap_interval : 1; /* We want to calculate diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 59bb66d21b..78320307d6 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -77,6 +77,7 @@ extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp); * Extensions. */ extern const __DRIcopySubBufferExtension driCopySubBufferExtension; +extern const __DRIswapControlExtension driSwapControlExtension; /** * Used by DRI_VALIDATE_DRAWABLE_INFO @@ -327,6 +328,12 @@ struct __DRIdrawablePrivateRec { * Called via glXSwapBuffers(). */ void (*swapBuffers)( __DRIdrawablePrivate *dPriv ); + + /** + * Controls swap interval as used by GLX_SGI_swap_control and + * GLX_MESA_swap_control. + */ + unsigned int swap_interval; }; /** diff --git a/src/mesa/drivers/dri/common/vblank.c b/src/mesa/drivers/dri/common/vblank.c index e7ed545f13..3b5acfecb1 100644 --- a/src/mesa/drivers/dri/common/vblank.c +++ b/src/mesa/drivers/dri/common/vblank.c @@ -255,13 +255,13 @@ static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd ) void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags, GLuint *vbl_seq ) { - if ( priv->pdraw->swap_interval == (unsigned)-1 ) { + if ( priv->swap_interval == (unsigned)-1 ) { /* Get current vertical blank sequence */ drmVBlank vbl = { .request={ .type = DRM_VBLANK_RELATIVE, .sequence = 0 } }; do_wait( &vbl, vbl_seq, priv->driScreenPriv->fd ); - priv->pdraw->swap_interval = (flags & (VBLANK_FLAG_THROTTLE | - VBLANK_FLAG_SYNC)) != 0 ? 1 : 0; + priv->swap_interval = (flags & (VBLANK_FLAG_THROTTLE | + VBLANK_FLAG_SYNC)) != 0 ? 1 : 0; } } @@ -277,9 +277,9 @@ driGetVBlankInterval( const __DRIdrawablePrivate *priv, GLuint flags ) if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) { /* this must have been initialized when the drawable was first bound * to a direct rendering context. */ - assert ( priv->pdraw->swap_interval != (unsigned)-1 ); + assert ( priv->swap_interval != (unsigned)-1 ); - return priv->pdraw->swap_interval; + return priv->swap_interval; } else if ( (flags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) != 0 ) { return 1; diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index 041a155fe7..d7af432ad6 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -613,7 +613,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, if (intel->ctx.DrawBuffer == &intel_fb->Base) { if (intel->driDrawable != driDrawPriv) { - if (driDrawPriv->pdraw->swap_interval == (unsigned)-1) { + if (driDrawPriv->swap_interval == (unsigned)-1) { int i; intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0) diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 792f26b5ed..f507a3bf05 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -421,6 +421,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, static const __DRIextension *intelExtensions[] = { &driCopySubBufferExtension.base, + &driSwapControlExtension.base, NULL }; @@ -529,9 +530,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = intelExtensions; if (glx_enable_extension != NULL) { - (*glx_enable_extension) (sPriv->psc, "GLX_SGI_swap_control"); (*glx_enable_extension) (sPriv->psc, "GLX_SGI_video_sync"); - (*glx_enable_extension) (sPriv->psc, "GLX_MESA_swap_control"); (*glx_enable_extension) (sPriv->psc, "GLX_MESA_swap_frame_usage"); (*glx_enable_extension) (sPriv->psc, "GLX_SGI_make_current_read"); } diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 1f74103f65..c75a86bf5b 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -266,6 +266,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, static const __DRIextension *intelExtensions[] = { &driCopySubBufferExtension.base, + &driSwapControlExtension.base, NULL }; @@ -357,9 +358,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = intelExtensions; if (glx_enable_extension != NULL) { - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" ); (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); } diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index ff261c841d..46314b426f 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -210,6 +210,7 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv ) ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv; PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); + int i; if (sPriv->devPrivSize != sizeof(ATIDRIRec)) { fprintf(stderr,"\nERROR! sizeof(ATIDRIRec) does not match passed size from device driver\n"); @@ -318,15 +319,18 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv ) mach64Screen->driScreen = sPriv; + i = 0; if ( glx_enable_extension != NULL ) { if ( mach64Screen->irq != 0 ) { - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); + mach64Screen->extensions[i++] = &driSwapControlExtension.base; + (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" ); } (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); } + mach64Screen->extensions[i++] = NULL; + sPriv->extensions = mach64Screen->extensions; return mach64Screen; } diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.h b/src/mesa/drivers/dri/mach64/mach64_screen.h index 5305058e2f..36da715770 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.h +++ b/src/mesa/drivers/dri/mach64/mach64_screen.h @@ -73,6 +73,8 @@ typedef struct { __DRIscreenPrivate *driScreen; driOptionCache optionCache; + + const __DRIextension *extensions[2]; } mach64ScreenRec, *mach64ScreenPtr; #endif /* __MACH64_SCREEN_H__ */ diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 5b4693983a..eba96486f6 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -193,6 +193,11 @@ mgaFillInModes( unsigned pixel_bits, unsigned depth_bits, } +static const __DRIextension *mgaExtensions[] = { + &driSwapControlExtension.base, + NULL +}; + static GLboolean mgaInitDriver(__DRIscreenPrivate *sPriv) { @@ -234,11 +239,11 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) } } + sPriv->extensions = mgaExtensions; + if ( glx_enable_extension != NULL ) { - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" ); (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); } diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 446280c399..9e5c25d720 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -100,6 +100,7 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv; PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); + int i; if (sPriv->devPrivSize != sizeof(R128DRIRec)) { fprintf(stderr,"\nERROR! sizeof(R128DRIRec) does not match passed size from device driver\n"); @@ -225,15 +226,17 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) r128Screen->driScreen = sPriv; + i = 0; if ( glx_enable_extension != NULL ) { if ( r128Screen->irq != 0 ) { - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); + r128Screen->extensions[i++] = &driSwapControlExtension.base; (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" ); } (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); } + r128Screen->extensions[i++] = NULL; + sPriv->extensions = r128Screen->extensions; return r128Screen; } diff --git a/src/mesa/drivers/dri/r128/r128_screen.h b/src/mesa/drivers/dri/r128/r128_screen.h index 8db8eea358..9733927274 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.h +++ b/src/mesa/drivers/dri/r128/r128_screen.h @@ -78,6 +78,8 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; + const __DRIextension *extensions[2]; + } r128ScreenRec, *r128ScreenPtr; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 7e533fef2c..46160babb0 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -332,11 +332,6 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_bits, return modes; } -static const __DRIextension *radeonExtensions[] = { - &driCopySubBufferExtension.base, - NULL -}; - /* Create the device specific screen private data struct. */ static radeonScreenPtr @@ -347,6 +342,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) unsigned char *RADEONMMIO; PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); + int i; if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) { fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n"); @@ -735,13 +731,13 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) dri_priv->log2GARTTexGran; } - sPriv->extensions = radeonExtensions; + i = 0; + screen->extensions[i++] = &driCopySubBufferExtension.base; if ( glx_enable_extension != NULL ) { if ( screen->irq != 0 ) { - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); + screen->extensions[i++] = &driSwapControlExtension.base; (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" ); } (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); @@ -750,6 +746,8 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); } + screen->extensions[i++] = NULL; + sPriv->extensions = screen->extensions; #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) if (IS_R200_CLASS(screen)) { diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 25e6fcf399..eceab53f5f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -103,6 +103,8 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; + + const __DRIextension *extensions[3]; } radeonScreenRec, *radeonScreenPtr; #define IS_R100_CLASS(screen) \ diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index 53f4c5c564..153e401a16 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -100,6 +100,7 @@ viaInitDriver(__DRIscreenPrivate *sPriv) VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv; PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); + int i; if (sPriv->devPrivSize != sizeof(VIADRIRec)) { fprintf(stderr,"\nERROR! sizeof(VIADRIRec) does not match passed size from device driver\n"); @@ -174,16 +175,18 @@ viaInitDriver(__DRIscreenPrivate *sPriv) viaScreen->sareaPrivOffset = gDRIPriv->sarea_priv_offset; + i = 0; if ( glx_enable_extension != NULL ) { if ( viaScreen->irqEnabled ) { - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" ); + viaScreen->extensions[i++] = &driSwapControlExtension.base; (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" ); } (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); } + viaScreen->extensions[i++] = NULL; + sPriv->extensions = viaScreen->extensions; return GL_TRUE; } diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h index 84aa5aef88..85f87c4da3 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.h +++ b/src/mesa/drivers/dri/unichrome/via_screen.h @@ -70,6 +70,8 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; + + const __DRIextension *extensions[2]; } viaScreenPrivate; -- cgit v1.2.3 From a7a0a2beb54dcb78d7e0ab64cf2f5a6ede8191a4 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 16 May 2007 15:50:40 -0400 Subject: Move GLX_MESA_swap_frame_usage DRI entry points to the new mechanism. --- include/GL/internal/dri_interface.h | 41 ++++++++++++++++++----------- src/glx/x11/glxclient.h | 4 +++ src/glx/x11/glxcmds.c | 40 +++++++++++++--------------- src/glx/x11/glxext.c | 11 +++++--- src/mesa/drivers/dri/common/dri_util.c | 18 ++++++++----- src/mesa/drivers/dri/common/dri_util.h | 1 + src/mesa/drivers/dri/i915/intel_screen.c | 2 +- src/mesa/drivers/dri/i965/intel_screen.c | 2 +- src/mesa/drivers/dri/mach64/mach64_screen.c | 3 +-- src/mesa/drivers/dri/mach64/mach64_screen.h | 2 +- src/mesa/drivers/dri/mga/mga_xmesa.c | 2 +- src/mesa/drivers/dri/r128/r128_screen.c | 3 +-- src/mesa/drivers/dri/r128/r128_screen.h | 2 +- src/mesa/drivers/dri/radeon/radeon_screen.c | 2 +- src/mesa/drivers/dri/radeon/radeon_screen.h | 2 +- src/mesa/drivers/dri/unichrome/via_screen.c | 2 +- src/mesa/drivers/dri/unichrome/via_screen.h | 2 +- 17 files changed, 78 insertions(+), 61 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index fcf82523d9..c518fd0849 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -61,6 +61,7 @@ typedef struct __DRIextensionRec __DRIextension; typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension; typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension; typedef struct __DRIallocateExtensionRec __DRIallocateExtension; +typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension; /*@}*/ @@ -112,6 +113,30 @@ struct __DRIallocateExtensionRec { GLuint (*memoryOffset)(__DRIscreen *screen, const GLvoid *pointer); }; +/** + * Used by drivers that implement the GLX_MESA_swap_frame_usage extension. + */ +#define __DRI_FRAME_TRACKING "DRI_FrameTracking" +struct __DRIframeTrackingExtensionRec { + __DRIextension base; + + /** + * Enable or disable frame usage tracking. + * + * \since Internal API version 20030317. + */ + int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable); + + /** + * Retrieve frame usage information. + * + * \since Internal API version 20030317. + */ + int (*queryFrameTracking)(__DRIdrawable *drawable, + int64_t * sbc, int64_t * missedFrames, + float * lastMissedUsage, float * usage); +}; + /** * \name Functions provided by the driver loader. */ @@ -480,22 +505,6 @@ struct __DRIdrawableRec { int64_t (*swapBuffersMSC)(__DRIdrawable *drawable, int64_t target_msc, int64_t divisor, int64_t remainder); - - /** - * Enable or disable frame usage tracking. - * - * \since Internal API version 20030317. - */ - int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable); - - /** - * Retrieve frame usage information. - * - * \since Internal API version 20030317. - */ - int (*queryFrameTracking)(__DRIdrawable *drawable, - int64_t * sbc, int64_t * missedFrames, - float * lastMissedUsage, float * usage); }; #endif diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index b60d8a0b90..d9fc7a5a6c 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -489,6 +489,10 @@ struct __GLXscreenConfigsRec { __DRIallocateExtension *allocate; #endif +#ifdef __DRI_FRAME_TRACKING + __DRIframeTrackingExtension *frameTracking; +#endif + #endif /** diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index e2deca5968..2b0403d37c 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -1835,15 +1835,13 @@ static int __glXGetSwapIntervalMESA(void) static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking(pdraw, GL_TRUE); - } + if (pdraw != NULL && psc->frameTracking != NULL) + status = psc->frameTracking->frameTracking(pdraw, GL_TRUE); #else (void) dpy; (void) drawable; @@ -1855,15 +1853,13 @@ static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable) static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking(pdraw, GL_FALSE); - } + if (pdraw != NULL && psc->frameTracking != NULL) + status = psc->frameTracking->frameTracking(pdraw, GL_FALSE); #else (void) dpy; (void) drawable; @@ -1876,18 +1872,19 @@ static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, GLfloat *usage) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - int64_t sbc, missedFrames; - float lastMissedUsage; + if (pdraw != NULL && psc->frameTracking != NULL) { + int64_t sbc, missedFrames; + float lastMissedUsage; - status = pdraw->queryFrameTracking(pdraw, &sbc, &missedFrames, - &lastMissedUsage, usage); + status = psc->frameTracking->queryFrameTracking(pdraw, &sbc, + &missedFrames, + &lastMissedUsage, + usage); } #else (void) dpy; @@ -1903,17 +1900,16 @@ static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, GLfloat *lastMissedUsage) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { + if (pdraw != NULL && psc->frameTracking != NULL) { float usage; - status = pdraw->queryFrameTracking(pdraw, sbc, missedFrames, - lastMissedUsage, &usage); + status = psc->frameTracking->queryFrameTracking(pdraw, sbc, missedFrames, + lastMissedUsage, &usage); } #else (void) dpy; diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 8275b4b9e0..8a70e67734 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -1024,7 +1024,6 @@ static void queryExtensions(__GLXscreenConfigs *psc) psc->copySubBuffer = (__DRIcopySubBufferExtension *) extensions[i]; __glXScrEnableExtension(&psc->driScreen, "GLX_MESA_copy_sub_buffer"); - } #endif @@ -1035,7 +1034,6 @@ static void queryExtensions(__GLXscreenConfigs *psc) "GLX_SGI_swap_control"); __glXScrEnableExtension(&psc->driScreen, "GLX_MESA_swap_control"); - } #endif @@ -1046,7 +1044,14 @@ static void queryExtensions(__GLXscreenConfigs *psc) "GLX_SGI_swap_control"); __glXScrEnableExtension(&psc->driScreen, "GLX_MESA_swap_control"); - + } +#endif + +#ifdef __DRI_FRAME_TRACKING + if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) { + psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i]; + __glXScrEnableExtension(&psc->driScreen, + "GLX_MESA_swap_frame_usage"); } #endif diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index ba677f6ff8..7815f361a8 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -52,11 +52,6 @@ static const int empty_attribute_list[1] = { None }; */ static int api_ver = 0; -/* forward declarations */ -static int driQueryFrameTracking( __DRIdrawable *drawable, - int64_t *sbc, int64_t *missedFrames, - float *lastMissedUsage, float *usage ); - static void *driCreateNewDrawable(__DRIscreen *screen, const __GLcontextModes *modes, __DRIdrawable *pdraw, @@ -515,8 +510,6 @@ static void *driCreateNewDrawable(__DRIscreen *screen, pdraw->waitForSBC = driWaitForSBC; pdraw->waitForMSC = driWaitForMSC; pdraw->swapBuffersMSC = driSwapBuffersMSC; - pdraw->frameTracking = NULL; - pdraw->queryFrameTracking = driQueryFrameTracking; /* This special default value is replaced with the configured * default value when the drawable is first bound to a direct @@ -825,6 +818,12 @@ int driCompareGLXAPIVersion( GLint required_version ) } +static int +driFrameTracking(__DRIdrawable *drawable, GLboolean enable) +{ + return GLX_BAD_CONTEXT; +} + static int driQueryFrameTracking(__DRIdrawable *drawable, int64_t * sbc, int64_t * missedFrames, @@ -849,6 +848,11 @@ driQueryFrameTracking(__DRIdrawable *drawable, return status; } +const __DRIframeTrackingExtension driFrameTrackingExtension = { + { __DRI_FRAME_TRACKING }, + driFrameTracking, + driQueryFrameTracking +}; /** * Calculate amount of swap interval used between GLX buffer swaps. diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 78320307d6..a7149bc552 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -78,6 +78,7 @@ extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp); */ extern const __DRIcopySubBufferExtension driCopySubBufferExtension; extern const __DRIswapControlExtension driSwapControlExtension; +extern const __DRIframeTrackingExtension driFrameTrackingExtension; /** * Used by DRI_VALIDATE_DRAWABLE_INFO diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 27bf5e12a2..041ff6bef0 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -430,6 +430,7 @@ static const __DRIextension *intelExtensions[] = { &driCopySubBufferExtension.base, &driSwapControlExtension.base, &intelAllocateExtension.base, + &driFrameTrackingExtension.base, NULL }; @@ -539,7 +540,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) if (glx_enable_extension != NULL) { (*glx_enable_extension) (sPriv->psc, "GLX_SGI_video_sync"); - (*glx_enable_extension) (sPriv->psc, "GLX_MESA_swap_frame_usage"); (*glx_enable_extension) (sPriv->psc, "GLX_SGI_make_current_read"); } diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index c75a86bf5b..ed8d207a49 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -267,6 +267,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, static const __DRIextension *intelExtensions[] = { &driCopySubBufferExtension.base, &driSwapControlExtension.base, + &driFrameTrackingExtension.base, NULL }; @@ -359,7 +360,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) if (glx_enable_extension != NULL) { (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); } diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index 46314b426f..adbed09877 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -320,14 +320,13 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv ) mach64Screen->driScreen = sPriv; i = 0; + mach64Screen->extensions[i++] = &driFrameTrackingExtension.base; if ( glx_enable_extension != NULL ) { if ( mach64Screen->irq != 0 ) { mach64Screen->extensions[i++] = &driSwapControlExtension.base; (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); } - - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); } mach64Screen->extensions[i++] = NULL; sPriv->extensions = mach64Screen->extensions; diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.h b/src/mesa/drivers/dri/mach64/mach64_screen.h index 36da715770..732cb3f23a 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.h +++ b/src/mesa/drivers/dri/mach64/mach64_screen.h @@ -74,7 +74,7 @@ typedef struct { driOptionCache optionCache; - const __DRIextension *extensions[2]; + const __DRIextension *extensions[3]; } mach64ScreenRec, *mach64ScreenPtr; #endif /* __MACH64_SCREEN_H__ */ diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index eba96486f6..198c5d5ca9 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -195,6 +195,7 @@ mgaFillInModes( unsigned pixel_bits, unsigned depth_bits, static const __DRIextension *mgaExtensions[] = { &driSwapControlExtension.base, + &driFrameTrackingExtension.base, NULL }; @@ -242,7 +243,6 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = mgaExtensions; if ( glx_enable_extension != NULL ) { - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); } diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 9e5c25d720..c7bd876283 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -227,13 +227,12 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) r128Screen->driScreen = sPriv; i = 0; + r128Screen->extensions[i++] = &driFrameTrackingExtension.base; if ( glx_enable_extension != NULL ) { if ( r128Screen->irq != 0 ) { r128Screen->extensions[i++] = &driSwapControlExtension.base; (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); } - - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); } r128Screen->extensions[i++] = NULL; sPriv->extensions = r128Screen->extensions; diff --git a/src/mesa/drivers/dri/r128/r128_screen.h b/src/mesa/drivers/dri/r128/r128_screen.h index 9733927274..75dc084d9d 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.h +++ b/src/mesa/drivers/dri/r128/r128_screen.h @@ -78,7 +78,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[2]; + const __DRIextension *extensions[3]; } r128ScreenRec, *r128ScreenPtr; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 362d70f9e5..4eaff652c7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -744,6 +744,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) i = 0; screen->extensions[i++] = &driCopySubBufferExtension.base; + screen->extensions[i++] = &driFrameTrackingExtension.base; if ( glx_enable_extension != NULL ) { if ( screen->irq != 0 ) { @@ -751,7 +752,6 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); } - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); } diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 954096f677..1001210917 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -104,7 +104,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[4]; + const __DRIextension *extensions[5]; } radeonScreenRec, *radeonScreenPtr; #define IS_R100_CLASS(screen) \ diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index 153e401a16..025d8f63af 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -176,6 +176,7 @@ viaInitDriver(__DRIscreenPrivate *sPriv) viaScreen->sareaPrivOffset = gDRIPriv->sarea_priv_offset; i = 0; + viaScreen->extensions[i++] = &driFrameTrackingExtension.base; if ( glx_enable_extension != NULL ) { if ( viaScreen->irqEnabled ) { viaScreen->extensions[i++] = &driSwapControlExtension.base; @@ -183,7 +184,6 @@ viaInitDriver(__DRIscreenPrivate *sPriv) } (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" ); } viaScreen->extensions[i++] = NULL; sPriv->extensions = viaScreen->extensions; diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h index 85f87c4da3..3dc52ba96a 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.h +++ b/src/mesa/drivers/dri/unichrome/via_screen.h @@ -71,7 +71,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[2]; + const __DRIextension *extensions[3]; } viaScreenPrivate; -- cgit v1.2.3 From 106a6f29bbdc71982afd629bdf89369cefd1459e Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Wed, 16 May 2007 18:13:41 -0400 Subject: Move media stream counter entry points to new extension. --- include/GL/internal/dri_interface.h | 76 ++++++++++------------------- src/glx/x11/glxclient.h | 4 ++ src/glx/x11/glxcmds.c | 55 ++++++++++----------- src/glx/x11/glxext.c | 15 +++++- src/mesa/drivers/dri/common/dri_util.c | 45 ++--------------- src/mesa/drivers/dri/common/dri_util.h | 1 + src/mesa/drivers/dri/i915/intel_screen.c | 2 +- src/mesa/drivers/dri/i965/intel_screen.c | 5 +- src/mesa/drivers/dri/mach64/mach64_screen.c | 11 ++--- src/mesa/drivers/dri/mach64/mach64_screen.h | 2 +- src/mesa/drivers/dri/mga/mga_xmesa.c | 5 +- src/mesa/drivers/dri/r128/r128_screen.c | 10 ++-- src/mesa/drivers/dri/r128/r128_screen.h | 2 +- src/mesa/drivers/dri/radeon/radeon_screen.c | 13 ++--- src/mesa/drivers/dri/radeon/radeon_screen.h | 2 +- src/mesa/drivers/dri/unichrome/via_screen.c | 12 ++--- src/mesa/drivers/dri/unichrome/via_screen.h | 2 +- 17 files changed, 102 insertions(+), 160 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index c518fd0849..2c91876e0d 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -62,6 +62,7 @@ typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension; typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension; typedef struct __DRIallocateExtensionRec __DRIallocateExtension; typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension; +typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension; /*@}*/ @@ -137,6 +138,32 @@ struct __DRIframeTrackingExtensionRec { float * lastMissedUsage, float * usage); }; + +/** + * Used by drivers that implement the GLX_SGI_video_sync extension. + */ +#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter" +struct __DRImediaStreamCounterExtensionRec { + __DRIextension base; + + /** + * Get the number of vertical refreshes since some point in time before + * this function was first called (i.e., system start up). + */ + int (*getMSC)(__DRIscreen *screen, int64_t *msc); + + /** + * Wait for the MSC to equal target_msc, or, if that has already passed, + * the next time (MSC % divisor) is equal to remainder. If divisor is + * zero, the function will return as soon as MSC is greater than or equal + * to target_msc. + */ + int (*waitForMSC)(__DRIdrawable *drawable, + int64_t target_msc, int64_t divisor, int64_t remainder, + int64_t * msc, int64_t * sbc); +}; + + /** * \name Functions provided by the driver loader. */ @@ -374,14 +401,6 @@ struct __DRIscreenRec { */ void *private; - /** - * Get the number of vertical refreshes since some point in time before - * this function was first called (i.e., system start up). - * - * \since Internal API version 20030317. - */ - int (*getMSC)(__DRIscreen *screen, int64_t *msc); - /** * Method to create the private DRI context data and initialize the * context dependent methods. @@ -464,47 +483,6 @@ struct __DRIdrawableRec { * screen used to create this drawable. Never dereferenced in libGL. */ void *private; - - /** - * Get the number of completed swap buffers for this drawable. - * - * \since Internal API version 20030317. - */ - int (*getSBC)(__DRIdrawable *drawable, int64_t *sbc); - - /** - * Wait for the SBC to be greater than or equal target_sbc. - * - * \since Internal API version 20030317. - */ - int (*waitForSBC)(__DRIdrawable *drawable, - int64_t target_sbc, - int64_t * msc, int64_t * sbc); - - /** - * Wait for the MSC to equal target_msc, or, if that has already passed, - * the next time (MSC % divisor) is equal to remainder. If divisor is - * zero, the function will return as soon as MSC is greater than or equal - * to target_msc. - * - * \since Internal API version 20030317. - */ - int (*waitForMSC)(__DRIdrawable *drawable, - int64_t target_msc, int64_t divisor, int64_t remainder, - int64_t * msc, int64_t * sbc); - - /** - * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once - * rendering is complete, waits until MSC is equal to target_msc, or - * if that has already passed, waits until (MSC % divisor) is equal - * to remainder. If divisor is zero, the swap will happen as soon as - * MSC is greater than or equal to target_msc. - * - * \since Internal API version 20030317. - */ - int64_t (*swapBuffersMSC)(__DRIdrawable *drawable, - int64_t target_msc, - int64_t divisor, int64_t remainder); }; #endif diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index d9fc7a5a6c..0709f3ef26 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -493,6 +493,10 @@ struct __GLXscreenConfigsRec { __DRIframeTrackingExtension *frameTracking; #endif +#ifdef __DRI_MEDIA_STREAM_COUNTER + __DRImediaStreamCounterExtension *msc; +#endif + #endif /** diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 2b0403d37c..a680c646d9 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -1931,19 +1931,18 @@ static int __glXGetVideoSyncSGI(unsigned int *count) * FIXME: there should be a GLX encoding for this call. I can find no * FIXME: documentation for the GLX encoding. */ -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_MEDIA_STREAM_COUNTER GLXContext gc = __glXGetCurrentContext(); if ( (gc != NULL) && gc->isDirect ) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit ) - && psc->driScreen.private && psc->driScreen.getMSC) { + if (psc->msc != NULL && psc->driScreen.private != NULL) { int ret; int64_t temp; - ret = psc->driScreen.getMSC(&psc->driScreen, &temp); + ret = psc->msc->getMSC(&psc->driScreen, &temp); *count = (unsigned) temp; return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } @@ -1956,7 +1955,7 @@ static int __glXGetVideoSyncSGI(unsigned int *count) static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_MEDIA_STREAM_COUNTER GLXContext gc = __glXGetCurrentContext(); if ( divisor <= 0 || remainder < 0 ) @@ -1965,17 +1964,16 @@ static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count if ( (gc != NULL) && gc->isDirect ) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit ) - && psc->driScreen.private ) { + if (psc->msc != NULL && psc->driScreen.private ) { __DRIdrawable * const pdraw = GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); - if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) ) { + if (pdraw != NULL) { int ret; int64_t msc; int64_t sbc; - ret = (*pdraw->waitForMSC)(pdraw, 0, - divisor, remainder, &msc, &sbc); + ret = (*psc->msc->waitForMSC)(pdraw, 0, + divisor, remainder, &msc, &sbc); *count = (unsigned) msc; return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } @@ -2130,7 +2128,7 @@ static Bool __glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc) { -#ifdef GLX_DIRECT_RENDERING +#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER) __GLXdisplayPrivate * const priv = __glXInitialize(dpy); if ( priv != NULL ) { @@ -2139,11 +2137,10 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, __GLXscreenConfigs * const psc = &priv->screenConfigs[i]; assert( (pdraw == NULL) || (i != -1) ); - return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) - && ((*psc->driScreen.getMSC)(&psc->driScreen, msc) == 0) - && ((*pdraw->getSBC)(pdraw, sbc ) == 0) - && (__glXGetUST( ust ) == 0) ); + return ( (pdraw && psc->sbc && psc->msc) + && ((*psc->msc->getMSC)(&psc->driScreen, msc) == 0) + && ((*psc->sbc->getSBC)(pdraw, sbc) == 0) + && (__glXGetUST(ust) == 0) ); } #else (void) dpy; @@ -2248,7 +2245,7 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_BUFFER_COUNTER int screen; __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen ); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); @@ -2263,10 +2260,10 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable, if ( divisor > 0 && remainder >= divisor ) return -1; - if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - return (*pdraw->swapBuffersMSC)(pdraw, target_msc, divisor, remainder); - } + if (pdraw != NULL && psc->counters != NULL) + return (*psc->sbc->swapBuffersMSC)(pdraw, target_msc, + divisor, remainder); + #else (void) dpy; (void) drawable; @@ -2283,7 +2280,7 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_MEDIA_STREAM_COUNTER int screen; __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen ); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); @@ -2297,10 +2294,9 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable, if ( divisor > 0 && remainder >= divisor ) return False; - if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - ret = (*pdraw->waitForMSC)(pdraw, target_msc, - divisor, remainder, msc, sbc); + if (pdraw != NULL && psc->msc != NULL) { + ret = (*psc->msc->waitForMSC)(pdraw, target_msc, + divisor, remainder, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. @@ -2325,7 +2321,7 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc ) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_BUFFER_COUNTER int screen; __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen ); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); @@ -2337,9 +2333,8 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, if ( target_sbc < 0 ) return False; - if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) { - ret = (*pdraw->waitForSBC)(pdraw, target_sbc, msc, sbc); + if (pdraw != NULL && psc->sbc != NULL) { + ret = (*psc->sbc->waitForSBC)(pdraw, target_sbc, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 8a70e67734..643db487c5 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -1051,10 +1051,23 @@ static void queryExtensions(__GLXscreenConfigs *psc) if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) { psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i]; __glXScrEnableExtension(&psc->driScreen, - "GLX_MESA_swap_frame_usage"); + "GLX_MESA_swap_frame_usage"); } #endif +#ifdef __DRI_MEDIA_STREAM_COUNTER + if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) { + psc->msc = (__DRImediaStreamCounterExtension *) extensions[i]; + __glXScrEnableExtension(&psc->driScreen, + "GLX_SGI_video_sync"); + } +#endif + +#ifdef __DRI_SWAP_BUFFER_COUNTER + /* No driver supports this at this time and the extension is + * not defined in dri_interface.h. Will enable + * GLX_OML_sync_control if implemented. */ +#endif /* Ignore unknown extensions */ } } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 7815f361a8..e20c4fe5fa 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -358,31 +358,6 @@ static int driGetMSC( __DRIscreen *screen, int64_t *msc ) return sPriv->DriverAPI.GetMSC( sPriv, msc ); } -/** - * Called directly from a number of higher-level GLX functions. - */ -static int driGetSBC(__DRIdrawable *drawable, int64_t *sbc) -{ - __DRIdrawablePrivate *dPriv = drawable->private; - __DRIswapInfo sInfo; - int status; - - - status = dPriv->driScreenPriv->DriverAPI.GetSwapInfo( dPriv, & sInfo ); - *sbc = sInfo.swap_count; - - return status; -} - -static int driWaitForSBC(__DRIdrawable *drawable, int64_t target_sbc, - int64_t * msc, int64_t * sbc) -{ - __DRIdrawablePrivate *dPriv = drawable->private; - - return dPriv->driScreenPriv->DriverAPI.WaitForSBC( dPriv, target_sbc, - msc, sbc ); -} - static int driWaitForMSC(__DRIdrawable *drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc, int64_t * sbc) @@ -409,15 +384,11 @@ static int driWaitForMSC(__DRIdrawable *drawable, int64_t target_msc, return status; } -static int64_t driSwapBuffersMSC(__DRIdrawable *drawable, int64_t target_msc, - int64_t divisor, int64_t remainder) -{ - __DRIdrawablePrivate *dPriv = drawable->private; - - return dPriv->driScreenPriv->DriverAPI.SwapBuffersMSC( dPriv, target_msc, - divisor, - remainder ); -} +const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = { + { __DRI_MEDIA_STREAM_COUNTER }, + driGetMSC, + driWaitForMSC, +}; static void driCopySubBuffer(__DRIdrawable *drawable, int x, int y, int w, int h) @@ -506,11 +477,6 @@ static void *driCreateNewDrawable(__DRIscreen *screen, pdraw->destroyDrawable = driDestroyDrawable; pdraw->swapBuffers = driSwapBuffers; /* called by glXSwapBuffers() */ - pdraw->getSBC = driGetSBC; - pdraw->waitForSBC = driWaitForSBC; - pdraw->waitForMSC = driWaitForMSC; - pdraw->swapBuffersMSC = driSwapBuffersMSC; - /* This special default value is replaced with the configured * default value when the drawable is first bound to a direct * rendering context. @@ -776,7 +742,6 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, psc->destroyScreen = driDestroyScreen; psc->getExtensions = driGetExtensions; psc->createNewDrawable = driCreateNewDrawable; - psc->getMSC = driGetMSC; psc->createNewContext = driCreateNewContext; if (internal_api_version >= 20070121) diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index a7149bc552..e43a5b752e 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -79,6 +79,7 @@ extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp); extern const __DRIcopySubBufferExtension driCopySubBufferExtension; extern const __DRIswapControlExtension driSwapControlExtension; extern const __DRIframeTrackingExtension driFrameTrackingExtension; +extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension; /** * Used by DRI_VALIDATE_DRAWABLE_INFO diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 041ff6bef0..60d375874d 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -431,6 +431,7 @@ static const __DRIextension *intelExtensions[] = { &driSwapControlExtension.base, &intelAllocateExtension.base, &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, NULL }; @@ -539,7 +540,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = intelExtensions; if (glx_enable_extension != NULL) { - (*glx_enable_extension) (sPriv->psc, "GLX_SGI_video_sync"); (*glx_enable_extension) (sPriv->psc, "GLX_SGI_make_current_read"); } diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index ed8d207a49..a4d63599e5 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -268,6 +268,7 @@ static const __DRIextension *intelExtensions[] = { &driCopySubBufferExtension.base, &driSwapControlExtension.base, &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, NULL }; @@ -358,10 +359,8 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = intelExtensions; - if (glx_enable_extension != NULL) { - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); + if (glx_enable_extension != NULL) (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - } return GL_TRUE; } diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index adbed09877..04eb081514 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -208,8 +208,6 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv ) { mach64ScreenPtr mach64Screen; ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); int i; if (sPriv->devPrivSize != sizeof(ATIDRIRec)) { @@ -321,12 +319,9 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv ) i = 0; mach64Screen->extensions[i++] = &driFrameTrackingExtension.base; - if ( glx_enable_extension != NULL ) { - if ( mach64Screen->irq != 0 ) { - mach64Screen->extensions[i++] = &driSwapControlExtension.base; - - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - } + if ( mach64Screen->irq != 0 ) { + mach64Screen->extensions[i++] = &driSwapControlExtension.base; + mach64Screen->extensions[i++] = &driMediaStreamCounterExtension.base; } mach64Screen->extensions[i++] = NULL; sPriv->extensions = mach64Screen->extensions; diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.h b/src/mesa/drivers/dri/mach64/mach64_screen.h index 732cb3f23a..766554d7e4 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.h +++ b/src/mesa/drivers/dri/mach64/mach64_screen.h @@ -74,7 +74,7 @@ typedef struct { driOptionCache optionCache; - const __DRIextension *extensions[3]; + const __DRIextension *extensions[4]; } mach64ScreenRec, *mach64ScreenPtr; #endif /* __MACH64_SCREEN_H__ */ diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 198c5d5ca9..6f138351cc 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -196,6 +196,7 @@ mgaFillInModes( unsigned pixel_bits, unsigned depth_bits, static const __DRIextension *mgaExtensions[] = { &driSwapControlExtension.base, &driFrameTrackingExtension.base, + &driMediaStreamCounterExtension.base, NULL }; @@ -242,10 +243,8 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = mgaExtensions; - if ( glx_enable_extension != NULL ) { + if ( glx_enable_extension != NULL ) (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - } if (serverInfo->chipset != MGA_CARD_TYPE_G200 && serverInfo->chipset != MGA_CARD_TYPE_G400) { diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index c7bd876283..9d65ebddf7 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -98,8 +98,6 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) { r128ScreenPtr r128Screen; R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); int i; if (sPriv->devPrivSize != sizeof(R128DRIRec)) { @@ -228,11 +226,9 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) i = 0; r128Screen->extensions[i++] = &driFrameTrackingExtension.base; - if ( glx_enable_extension != NULL ) { - if ( r128Screen->irq != 0 ) { - r128Screen->extensions[i++] = &driSwapControlExtension.base; - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - } + if ( r128Screen->irq != 0 ) { + r128Screen->extensions[i++] = &driSwapControlExtension.base; + r128Screen->extensions[i++] = &driMediaStreamCounterExtension.base; } r128Screen->extensions[i++] = NULL; sPriv->extensions = r128Screen->extensions; diff --git a/src/mesa/drivers/dri/r128/r128_screen.h b/src/mesa/drivers/dri/r128/r128_screen.h index 75dc084d9d..c333713766 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.h +++ b/src/mesa/drivers/dri/r128/r128_screen.h @@ -78,7 +78,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[3]; + const __DRIextension *extensions[4]; } r128ScreenRec, *r128ScreenPtr; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 4eaff652c7..56493f5a3a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -745,15 +745,12 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) i = 0; screen->extensions[i++] = &driCopySubBufferExtension.base; screen->extensions[i++] = &driFrameTrackingExtension.base; - - if ( glx_enable_extension != NULL ) { - if ( screen->irq != 0 ) { - screen->extensions[i++] = &driSwapControlExtension.base; - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - } - - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); + if ( screen->irq != 0 ) { + screen->extensions[i++] = &driSwapControlExtension.base; + screen->extensions[i++] = &driMediaStreamCounterExtension.base; } + if ( glx_enable_extension != NULL ) + (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) if (IS_R200_CLASS(screen)) diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 1001210917..0caac17daf 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -104,7 +104,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[5]; + const __DRIextension *extensions[6]; } radeonScreenRec, *radeonScreenPtr; #define IS_R100_CLASS(screen) \ diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index 025d8f63af..fddf079934 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -177,14 +177,14 @@ viaInitDriver(__DRIscreenPrivate *sPriv) i = 0; viaScreen->extensions[i++] = &driFrameTrackingExtension.base; - if ( glx_enable_extension != NULL ) { - if ( viaScreen->irqEnabled ) { - viaScreen->extensions[i++] = &driSwapControlExtension.base; - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" ); - } + if ( viaScreen->irqEnabled ) { + viaScreen->extensions[i++] = &driSwapControlExtension.base; + viaScreen->extensions[i++] = &driMediaStreamCounterExtension.base; + } + if ( glx_enable_extension != NULL ) (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - } + viaScreen->extensions[i++] = NULL; sPriv->extensions = viaScreen->extensions; diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h index 3dc52ba96a..5e5bc851b0 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.h +++ b/src/mesa/drivers/dri/unichrome/via_screen.h @@ -71,7 +71,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[3]; + const __DRIextension *extensions[4]; } viaScreenPrivate; -- cgit v1.2.3 From f968f67e6214416f04b8875ce59a94a02f464c81 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 17 May 2007 14:39:06 -0400 Subject: Add a DRI_ReadDrawable marker extension to signal read drawable capability. --- include/GL/internal/dri_interface.h | 5 +++++ src/glx/x11/glxext.c | 7 +++++++ src/mesa/drivers/dri/common/dri_util.c | 8 ++++++++ src/mesa/drivers/dri/common/dri_util.h | 1 + src/mesa/drivers/dri/i915/intel_screen.c | 9 +-------- src/mesa/drivers/dri/i965/intel_screen.c | 6 +----- src/mesa/drivers/dri/mga/mga_xmesa.c | 6 +----- src/mesa/drivers/dri/radeon/radeon_screen.c | 6 ++---- src/mesa/drivers/dri/radeon/radeon_screen.h | 2 +- src/mesa/drivers/dri/savage/savage_xmesa.c | 11 +++++------ src/mesa/drivers/dri/tdfx/tdfx_screen.c | 10 +++++----- src/mesa/drivers/dri/unichrome/via_screen.c | 6 +----- src/mesa/drivers/dri/unichrome/via_screen.h | 2 +- 13 files changed, 39 insertions(+), 40 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 2c91876e0d..cce3b6fcf0 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -78,6 +78,11 @@ struct __DRIextensionRec { const char *name; }; +/** + * Used by drivers to indicate support for setting the read drawable. + */ +#define __DRI_READ_DRAWABLE "DRI_ReadDrawable" + /** * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension. */ diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index 643db487c5..3db163af1e 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -1068,6 +1068,13 @@ static void queryExtensions(__GLXscreenConfigs *psc) * not defined in dri_interface.h. Will enable * GLX_OML_sync_control if implemented. */ #endif + +#ifdef __DRI_READ_DRAWABLE + if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) { + __glXScrEnableExtension(&psc->driScreen, + "GLX_SGI_make_current_read"); + } +#endif /* Ignore unknown extensions */ } } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index e20c4fe5fa..b88592313e 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -46,6 +46,14 @@ const __DRIinterfaceMethods * dri_interface = NULL; static const int empty_attribute_list[1] = { None }; +/** + * This is just a token extension used to signal that the driver + * supports setting a read drawable. + */ +const __DRIextension driReadDrawableExtension = { + __DRI_READ_DRAWABLE +}; + /** * Cached copy of the internal API version used by libGL and the client-side * DRI driver. diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index e43a5b752e..91992a9a24 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -76,6 +76,7 @@ extern __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp); /** * Extensions. */ +extern const __DRIextension driReadDrawableExtension; extern const __DRIcopySubBufferExtension driCopySubBufferExtension; extern const __DRIswapControlExtension driSwapControlExtension; extern const __DRIframeTrackingExtension driFrameTrackingExtension; diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 60d375874d..191d26e84b 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -427,6 +427,7 @@ static const __DRIallocateExtension intelAllocateExtension = { }; static const __DRIextension *intelExtensions[] = { + &driReadDrawableExtension, &driCopySubBufferExtension.base, &driSwapControlExtension.base, &intelAllocateExtension.base, @@ -442,10 +443,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv; drmI830Sarea *sarea; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface-> - getProcAddress("glxEnableExtension")); - if (sPriv->devPrivSize != sizeof(I830DRIRec)) { fprintf(stderr, "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n"); @@ -539,10 +536,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = intelExtensions; - if (glx_enable_extension != NULL) { - (*glx_enable_extension) (sPriv->psc, "GLX_SGI_make_current_read"); - } - /* If we've got a new enough DDX that's initializing TTM and giving us * object handles for the shared buffers, use that. */ diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index a4d63599e5..e35f7da938 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -265,6 +265,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen, } static const __DRIextension *intelExtensions[] = { + &driReadDrawableExtension, &driCopySubBufferExtension.base, &driSwapControlExtension.base, &driFrameTrackingExtension.base, @@ -276,8 +277,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) { intelScreenPrivate *intelScreen; I830DRIPtr gDRIPriv = (I830DRIPtr)sPriv->pDevPriv; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); volatile drmI830Sarea *sarea; if (sPriv->devPrivSize != sizeof(I830DRIRec)) { @@ -358,9 +357,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) } sPriv->extensions = intelExtensions; - - if (glx_enable_extension != NULL) - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 6f138351cc..99a2ea0491 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -194,6 +194,7 @@ mgaFillInModes( unsigned pixel_bits, unsigned depth_bits, static const __DRIextension *mgaExtensions[] = { + &driReadDrawableExtension, &driSwapControlExtension.base, &driFrameTrackingExtension.base, &driMediaStreamCounterExtension.base, @@ -205,8 +206,6 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) { mgaScreenPrivate *mgaScreen; MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); if (sPriv->devPrivSize != sizeof(MGADRIRec)) { fprintf(stderr,"\nERROR! sizeof(MGADRIRec) does not match passed size from device driver\n"); @@ -243,9 +242,6 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) sPriv->extensions = mgaExtensions; - if ( glx_enable_extension != NULL ) - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - if (serverInfo->chipset != MGA_CARD_TYPE_G200 && serverInfo->chipset != MGA_CARD_TYPE_G400) { FREE(mgaScreen); diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 56493f5a3a..269620cec4 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -351,8 +351,6 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) radeonScreenPtr screen; RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv; unsigned char *RADEONMMIO; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); int i; if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) { @@ -745,12 +743,12 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) i = 0; screen->extensions[i++] = &driCopySubBufferExtension.base; screen->extensions[i++] = &driFrameTrackingExtension.base; + screen->extensions[i++] = &driReadDrawableExtension; + if ( screen->irq != 0 ) { screen->extensions[i++] = &driSwapControlExtension.base; screen->extensions[i++] = &driMediaStreamCounterExtension.base; } - if ( glx_enable_extension != NULL ) - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) if (IS_R200_CLASS(screen)) diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 0caac17daf..68755c985a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -104,7 +104,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[6]; + const __DRIextension *extensions[7]; } radeonScreenRec, *radeonScreenPtr; #define IS_R100_CLASS(screen) \ diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index 3750c8948a..013e88216f 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -168,6 +168,10 @@ static const struct tnl_pipeline_stage *savage_pipeline[] = { }; +static const __DRIextension *savageExtensions[] = { + &driReadDrawableExtension, +}; + /* this is first function called in dirver*/ static GLboolean @@ -175,9 +179,6 @@ savageInitDriver(__DRIscreenPrivate *sPriv) { savageScreenPrivate *savageScreen; SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); - if (sPriv->devPrivSize != sizeof(SAVAGEDRIRec)) { fprintf(stderr,"\nERROR! sizeof(SAVAGEDRIRec) does not match passed size from device driver\n"); @@ -265,9 +266,7 @@ savageInitDriver(__DRIscreenPrivate *sPriv) driParseOptionInfo (&savageScreen->optionCache, __driConfigOptions, __driNConfigOptions); - if (glx_enable_extension != NULL) { - (*glx_enable_extension)(sPriv->psc, "GLX_SGI_make_current_read"); - } + sPriv->extensions = savageExtensions; #if 0 savageDDFastPathInit(); diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c index 081a534035..5bdb446d15 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c @@ -63,6 +63,10 @@ DRI_CONF_BEGIN DRI_CONF_SECTION_END DRI_CONF_END; +static const __DRIextension *tdfxExtensions[] = { + &driReadDrawableExtension, +}; + static const GLuint __driNConfigOptions = 1; extern const struct dri_extension card_extensions[]; @@ -73,8 +77,6 @@ tdfxCreateScreen( __DRIscreenPrivate *sPriv ) { tdfxScreenPrivate *fxScreen; TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); if (sPriv->devPrivSize != sizeof(TDFXDRIRec)) { fprintf(stderr,"\nERROR! sizeof(TDFXDRIRec) does not match passed size from device driver\n"); @@ -115,9 +117,7 @@ tdfxCreateScreen( __DRIscreenPrivate *sPriv ) return GL_FALSE; } - if (glx_enable_extension != NULL) { - (*glx_enable_extension)(sPriv->psc, "GLX_SGI_make_current_read"); - } + sPriv->extensions = tdfxExtensions; return GL_TRUE; } diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index fddf079934..f3912ac352 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -98,8 +98,6 @@ viaInitDriver(__DRIscreenPrivate *sPriv) { viaScreenPrivate *viaScreen; VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv; - PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension = - (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension")); int i; if (sPriv->devPrivSize != sizeof(VIADRIRec)) { @@ -177,14 +175,12 @@ viaInitDriver(__DRIscreenPrivate *sPriv) i = 0; viaScreen->extensions[i++] = &driFrameTrackingExtension.base; + viaScreen->extensions[i++] = &driReadDrawableExtension; if ( viaScreen->irqEnabled ) { viaScreen->extensions[i++] = &driSwapControlExtension.base; viaScreen->extensions[i++] = &driMediaStreamCounterExtension.base; } - if ( glx_enable_extension != NULL ) - (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" ); - viaScreen->extensions[i++] = NULL; sPriv->extensions = viaScreen->extensions; diff --git a/src/mesa/drivers/dri/unichrome/via_screen.h b/src/mesa/drivers/dri/unichrome/via_screen.h index 5e5bc851b0..c3ef722ff0 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.h +++ b/src/mesa/drivers/dri/unichrome/via_screen.h @@ -71,7 +71,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[4]; + const __DRIextension *extensions[5]; } viaScreenPrivate; -- cgit v1.2.3 From ecdb45cb29e3209287cc297081596126e955ff2b Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 17 May 2007 16:11:19 -0400 Subject: Convert a left-over private void * to __DRIcontext *. --- include/GL/internal/dri_interface.h | 2 +- src/glx/x11/glxcmds.c | 4 ++-- src/mesa/drivers/dri/common/dri_util.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 657e3828cc..46f1f441d0 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -377,7 +377,7 @@ struct __DRIscreenRec { void * (*createNewContext)(__DRIscreen *screen, const __GLcontextModes *modes, int render_type, - void *sharedPrivate, + __DRIcontext *shared, drm_context_t hwContext, __DRIcontext *pctx); /** diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index a680c646d9..0a49e94586 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -395,8 +395,8 @@ CreateContext(Display *dpy, XVisualInfo *vis, } if (psc && psc->driScreen.private) { - void * const shared = (shareList != NULL) - ? shareList->driContext.private : NULL; + __DRIcontext *shared = (shareList != NULL) + ? &shareList->driContext : NULL; if (!XF86DRICreateContextWithConfig(dpy, psc->scr, diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index b88592313e..20fee27f0a 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -553,7 +553,7 @@ driDestroyContext(__DRIcontext *context) * \param modes Mode used to create the new context. * \param render_type Type of rendering target. \c GLX_RGBA is the only * type likely to ever be supported for direct-rendering. - * \param sharedPrivate The shared context dependent methods or \c NULL if + * \param shared The shared context dependent methods or \c NULL if * non-existent. * \param pctx DRI context to receive the context dependent methods. * @@ -569,11 +569,11 @@ driDestroyContext(__DRIcontext *context) */ static void * driCreateNewContext(__DRIscreen *screen, const __GLcontextModes *modes, - int render_type, void *sharedPrivate, + int render_type, __DRIcontext *shared, drm_context_t hwContext, __DRIcontext *pctx) { __DRIcontextPrivate *pcp; - __DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate; + __DRIcontextPrivate *pshare = (shared != NULL) ? shared->private : NULL; __DRIscreenPrivate *psp; void * const shareCtx = (pshare != NULL) ? pshare->driverPrivate : NULL; -- cgit v1.2.3 From f29f0ae8383888a6493b615edc3bab254cf6df39 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Tue, 22 May 2007 12:26:02 -0400 Subject: Move new texOffset extension to the new extension mechanism. --- include/GL/internal/dri_interface.h | 29 +++++++++++++++++------------ src/mesa/drivers/dri/common/dri_util.c | 3 --- src/mesa/drivers/dri/radeon/radeon_screen.c | 14 ++++++++++---- src/mesa/drivers/dri/radeon/radeon_screen.h | 2 +- 4 files changed, 28 insertions(+), 20 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 46f1f441d0..1efae11d62 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -63,6 +63,7 @@ typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension; typedef struct __DRIallocateExtensionRec __DRIallocateExtension; typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension; typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension; +typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension; /*@}*/ @@ -169,6 +170,22 @@ struct __DRImediaStreamCounterExtensionRec { }; +#define __DRI_TEX_OFFSET "DRI_TexOffset" +struct __DRItexOffsetExtensionRec { + __DRIextension base; + + /** + * Method to override base texture image with a driver specific 'offset'. + * The depth passed in allows e.g. to ignore the alpha channel of texture + * images where the non-alpha components don't occupy a whole texel. + * + * For GLX_EXT_texture_from_pixmap with AIGLX. + */ + void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname, + unsigned long long offset, GLint depth, GLuint pitch); +}; + + /** * Macros for building symbol and strings. Standard CPP two step... */ @@ -379,18 +396,6 @@ struct __DRIscreenRec { int render_type, __DRIcontext *shared, drm_context_t hwContext, __DRIcontext *pctx); - - /** - * Method to override base texture image with a driver specific 'offset'. - * The depth passed in allows e.g. to ignore the alpha channel of texture - * images where the non-alpha components don't occupy a whole texel. - * - * For GLX_EXT_texture_from_pixmap with AIGLX. - * - * \since Internal API version 20070121. - */ - void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname, - unsigned long long offset, GLint depth, GLuint pitch); }; /** diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 20fee27f0a..2209321978 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -752,9 +752,6 @@ void * __DRI_CREATE_NEW_SCREEN( int scrn, __DRIscreen *psc, psc->createNewDrawable = driCreateNewDrawable; psc->createNewContext = driCreateNewContext; - if (internal_api_version >= 20070121) - psc->setTexOffset = psp->DriverAPI.setTexOffset; - *driver_modes = __driDriverInitScreen(psp); if (*driver_modes == NULL) { _mesa_free(psp); diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 269620cec4..84c6885d50 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -333,14 +333,19 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_bits, } #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) - static const __DRIallocateExtension r200AllocateExtension = { { __DRI_ALLOCATE }, r200AllocateMemoryMESA, r200FreeMemoryMESA, r200GetMemoryOffsetMESA }; +#endif +#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) +static const __DRItexOffsetExtension r300texOffsetExtension = { + { __DRI_TEX_OFFSET }, + r300SetTexOffset, +}; #endif /* Create the device specific screen private data struct. @@ -755,6 +760,10 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv ) screen->extensions[i++] = &r200AllocateExtension.base; #endif +#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) + screen->extensions[i++] = &r300texOffsetExtension.base; +#endif + screen->extensions[i++] = NULL; sPriv->extensions = screen->extensions; @@ -956,9 +965,6 @@ static struct __DriverAPIRec radeonAPI = { .WaitForSBC = NULL, .SwapBuffersMSC = NULL, .CopySubBuffer = radeonCopySubBuffer, -#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) - .setTexOffset = r300SetTexOffset, -#endif }; #else static const struct __DriverAPIRec r200API = { diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 68755c985a..184b0d225e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -104,7 +104,7 @@ typedef struct { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[7]; + const __DRIextension *extensions[8]; } radeonScreenRec, *radeonScreenPtr; #define IS_R100_CLASS(screen) \ -- cgit v1.2.3 From ccff0cb26378ce370fc8697a2a2ada138d2e119e Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Thu, 7 Jun 2007 19:35:54 -0400 Subject: Add a version field to __DRIextension. --- include/GL/internal/dri_interface.h | 23 +++++++++++++++++++++++ src/mesa/drivers/dri/common/dri_util.c | 11 ++++++----- src/mesa/drivers/dri/i915/intel_screen.c | 2 +- src/mesa/drivers/dri/radeon/radeon_screen.c | 4 ++-- 4 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src/mesa/drivers/dri/common') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 1efae11d62..e7fbf8e8b8 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -74,20 +74,38 @@ typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension; * structs and the loader can use the extensions it knows about by * casting it to a more specific extension and optionally advertising * the GLX extension. See below for examples. + * + * We never break API in for a DRI extension. If we need to change + * the way things work in a non-backwards compatible manner, we + * introduce a new extension. During a transition period, we can + * leave both the old and the new extension in the driver, which + * allows us to move to the new interface without having to update the + * loader(s) in lock step. + * + * However, we can add entry points to an extension over time as long + * as we don't break the old ones. As we add entry points to an + * extension, we increase the version number. The corresponding + * #define can be used to guard code that accesses the new entry + * points at compile time and the version field in the extension + * struct can be used at run-time to determine how to use the + * extension. */ struct __DRIextensionRec { const char *name; + int version; }; /** * Used by drivers to indicate support for setting the read drawable. */ #define __DRI_READ_DRAWABLE "DRI_ReadDrawable" +#define __DRI_READ_DRAWABLE_VERSION 1 /** * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension. */ #define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer" +#define __DRI_COPY_SUB_BUFFER_VERSION 1 struct __DRIcopySubBufferExtensionRec { __DRIextension base; void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h); @@ -98,6 +116,7 @@ struct __DRIcopySubBufferExtensionRec { * GLX_MESA_swap_control extension. */ #define __DRI_SWAP_CONTROL "DRI_SwapControl" +#define __DRI_SWAP_CONTROL_VERSION 1 struct __DRIswapControlExtensionRec { __DRIextension base; void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval); @@ -108,6 +127,7 @@ struct __DRIswapControlExtensionRec { * Used by drivers that implement the GLX_MESA_allocate_memory. */ #define __DRI_ALLOCATE "DRI_Allocate" +#define __DRI_ALLOCATE_VERSION 1 struct __DRIallocateExtensionRec { __DRIextension base; @@ -124,6 +144,7 @@ struct __DRIallocateExtensionRec { * Used by drivers that implement the GLX_MESA_swap_frame_usage extension. */ #define __DRI_FRAME_TRACKING "DRI_FrameTracking" +#define __DRI_FRAME_TRACKING_VERSION 1 struct __DRIframeTrackingExtensionRec { __DRIextension base; @@ -149,6 +170,7 @@ struct __DRIframeTrackingExtensionRec { * Used by drivers that implement the GLX_SGI_video_sync extension. */ #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter" +#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1 struct __DRImediaStreamCounterExtensionRec { __DRIextension base; @@ -171,6 +193,7 @@ struct __DRImediaStreamCounterExtensionRec { #define __DRI_TEX_OFFSET "DRI_TexOffset" +#define __DRI_TEX_OFFSET_VERSION 1 struct __DRItexOffsetExtensionRec { __DRIextension base; diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 2209321978..d59ea0ddad 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -51,7 +51,7 @@ static const int empty_attribute_list[1] = { None }; * supports setting a read drawable. */ const __DRIextension driReadDrawableExtension = { - __DRI_READ_DRAWABLE + __DRI_READ_DRAWABLE, __DRI_READ_DRAWABLE_VERSION }; /** @@ -393,7 +393,7 @@ static int driWaitForMSC(__DRIdrawable *drawable, int64_t target_msc, } const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = { - { __DRI_MEDIA_STREAM_COUNTER }, + { __DRI_MEDIA_STREAM_COUNTER, __DRI_MEDIA_STREAM_COUNTER_VERSION }, driGetMSC, driWaitForMSC, }; @@ -406,7 +406,8 @@ static void driCopySubBuffer(__DRIdrawable *drawable, } const __DRIcopySubBufferExtension driCopySubBufferExtension = { - { __DRI_COPY_SUB_BUFFER }, driCopySubBuffer + { __DRI_COPY_SUB_BUFFER, __DRI_COPY_SUB_BUFFER_VERSION }, + driCopySubBuffer }; static void driSetSwapInterval(__DRIdrawable *drawable, unsigned int interval) @@ -424,7 +425,7 @@ static unsigned int driGetSwapInterval(__DRIdrawable *drawable) } const __DRIswapControlExtension driSwapControlExtension = { - { __DRI_SWAP_CONTROL }, + { __DRI_SWAP_CONTROL, __DRI_SWAP_CONTROL_VERSION }, driSetSwapInterval, driGetSwapInterval }; @@ -819,7 +820,7 @@ driQueryFrameTracking(__DRIdrawable *drawable, } const __DRIframeTrackingExtension driFrameTrackingExtension = { - { __DRI_FRAME_TRACKING }, + { __DRI_FRAME_TRACKING, __DRI_FRAME_TRACKING_VERSION }, driFrameTracking, driQueryFrameTracking }; diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 191d26e84b..b5eab5ba00 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -420,7 +420,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, } static const __DRIallocateExtension intelAllocateExtension = { - { __DRI_ALLOCATE }, + { __DRI_ALLOCATE, __DRI_ALLOCATE_VERSION }, intelAllocateMemoryMESA, intelFreeMemoryMESA, intelGetMemoryOffsetMESA diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 84c6885d50..10d3c2b27c 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -334,7 +334,7 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_bits, #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200) static const __DRIallocateExtension r200AllocateExtension = { - { __DRI_ALLOCATE }, + { __DRI_ALLOCATE, __DRI_ALLOCATE_VERSION }, r200AllocateMemoryMESA, r200FreeMemoryMESA, r200GetMemoryOffsetMESA @@ -343,7 +343,7 @@ static const __DRIallocateExtension r200AllocateExtension = { #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) static const __DRItexOffsetExtension r300texOffsetExtension = { - { __DRI_TEX_OFFSET }, + { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION }, r300SetTexOffset, }; #endif -- cgit v1.2.3