Move the copySubBuffer extension over to the new mechanism.
authorKristian Høgsberg <krh@hinata.boston.redhat.com>
Tue, 15 May 2007 19:17:30 +0000 (15:17 -0400)
committerKristian Høgsberg <krh@redhat.com>
Wed, 10 Oct 2007 22:57:57 +0000 (18:57 -0400)
include/GL/internal/dri_interface.h
src/glx/x11/glxclient.h
src/glx/x11/glxcmds.c
src/glx/x11/glxext.c
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/intel_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.c

index ee73233771c40e50f07a5c67ccfd8bd1cd7a702a..e2050c16b4fc5ae358aade2128371fd36416ce09 100644 (file)
@@ -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
index 56973251758579fda6091c2a8fe047dca5c7d83b..2c7302823975526f5a793221e366359f06e1517e 100644 (file)
@@ -476,6 +476,11 @@ struct __GLXscreenConfigsRec {
     __glxHashTable *drawHash;
     Display *dpy;
     int scr;
+
+#ifdef __DRI_COPY_SUB_BUFFER
+    __DRIcopySubBufferExtension *copySubBuffer;
+#endif
+
 #endif
 
     /**
index 6b8824d8243778575af26c20eb85183af26cf0ed..1bc5fff957c83c1d74397ff1fc55750d351444cb 100644 (file)
@@ -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;
index cb187717f1e15ef2a33027000996f2860e695813..d0a7a64445a06d3efff30b46fe64ee2f735b8b0f 100644 (file)
@@ -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 */
     }
 }
 
index c8be7b070647e5d3edce4424beb9a5c492c3502a..fc7755797d65027e5f7ead0062015adb13cf0efe 100644 (file)
@@ -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;
 
index 5ac2eea72215428e70b62025c191fb025b494b69..59bb66d21bce3b47e09c4faac24e9468ad4caf5c 100644 (file)
@@ -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;
 };
 
 
index a75133ec73829105b5f3501f00e34f1340dfc704..792f26b5ed402d018ad764a5011e0b834289ff41 100644 (file)
@@ -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");
index f0bce146b0835d7ee27b95a6798769a1319a837e..1f74103f6516d5a886d624eb40ea3b50e14f9e6a 100644 (file)
@@ -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;
index b7e0b5a0fa3ec34220df02893fd389776e566073..7e533fef2ccf62273ebb6901fbbeb5d69265090e 100644 (file)
@@ -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" );
    }