From: Kristian Høgsberg Date: Tue, 15 May 2007 19:17:30 +0000 (-0400) Subject: Move the copySubBuffer extension over to the new mechanism. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac3e838fa748c8c8a6ffc04d1ab13da71f75f103;p=mesa.git Move the copySubBuffer extension over to the new mechanism. --- diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index ee73233771c..e2050c16b4f 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 56973251758..2c730282397 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 6b8824d8243..1bc5fff957c 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 cb187717f1e..d0a7a64445a 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 c8be7b07064..fc7755797d6 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 5ac2eea7221..59bb66d21bc 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 a75133ec738..792f26b5ed4 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 f0bce146b08..1f74103f651 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 b7e0b5a0fa3..7e533fef2cc 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" ); }