Move GLX_MESA_swap_frame_usage DRI entry points to the new mechanism.
authorKristian Høgsberg <krh@hinata.boston.redhat.com>
Wed, 16 May 2007 19:50:40 +0000 (15:50 -0400)
committerKristian Høgsberg <krh@redhat.com>
Thu, 11 Oct 2007 15:11:12 +0000 (11:11 -0400)
17 files changed:
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/mach64/mach64_screen.c
src/mesa/drivers/dri/mach64/mach64_screen.h
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/r128/r128_screen.c
src/mesa/drivers/dri/r128/r128_screen.h
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.h
src/mesa/drivers/dri/unichrome/via_screen.c
src/mesa/drivers/dri/unichrome/via_screen.h

index fcf82523d994f884fb2f1819d30f95819da91c23..c518fd0849c2f898cb16eb3c576eb2651bce8e33 100644 (file)
@@ -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
index b60d8a0b904ecbcf6df1b96cc2aa9a2deb303fb1..d9fc7a5a6c39bc622c778cddd6d44ebbdd1fb4e4 100644 (file)
@@ -489,6 +489,10 @@ struct __GLXscreenConfigsRec {
     __DRIallocateExtension *allocate;
 #endif
 
+#ifdef __DRI_FRAME_TRACKING
+    __DRIframeTrackingExtension *frameTracking;
+#endif
+
 #endif
 
     /**
index e2deca596867d7fde89245ca3e35f5182f68d2ab..2b0403d37c9c06ab3bb31547ea1f05e3182cf933 100644 (file)
@@ -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;
index 8275b4b9e07a5b8ac7dadef8da5f4d51961c6816..8a70e677342bbe1930941c7202f9b98c6a9eb51b 100644 (file)
@@ -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
 
index ba677f6ff866e25ecd01eb41a0090309c29d5d06..7815f361a83e0d9e153c11111dd5ec32c2bc6e6b 100644 (file)
@@ -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.
index 78320307d60dca8504e0423e351816b2a207b01e..a7149bc55252342f6a2e827171f204b92ca63e94 100644 (file)
@@ -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
index 27bf5e12a200684d8e26fc46ecc5ccaf93e2b3c6..041ff6bef087113d0f019a5b6d28fbbf2df99551 100644 (file)
@@ -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");
    }
 
index c75a86bf5b2db712ad009fe6c9c20ccb632636c2..ed8d207a49478ce430cb3c98c0aa5047bd3d2692 100644 (file)
@@ -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" );
    }
    
index 46314b426f7c79d1be145f9b9a1b0a0ba424d7ef..adbed098777feb14b4fbd0af476a100c81d1af1c 100644 (file)
@@ -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;
index 36da7157707d13083b9a5f7b19974639ad507d46..732cb3f23ad454ec41aaa1d7f8c4fb9ec85d7196 100644 (file)
@@ -74,7 +74,7 @@ typedef struct {
 
    driOptionCache optionCache;
 
-   const __DRIextension *extensions[2];
+   const __DRIextension *extensions[3];
 } mach64ScreenRec, *mach64ScreenPtr;
 
 #endif /* __MACH64_SCREEN_H__ */
index eba96486f6756cc17fdd8cbfa85d164eaa8b2226..198c5d5ca95523e6caa08e8c6ffb7621fd359c4b 100644 (file)
@@ -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" );
    }
index 9e5c25d7207e06a713441fbb8019c571ac6ac841..c7bd876283196597aade028c3a0996495e37b056 100644 (file)
@@ -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;
index 9733927274223a4a53a1ca21d3d35b01e7bc1e5c..75dc084d9d1017304f8fcdc949e67f178b42da63 100644 (file)
@@ -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;
 
index 362d70f9e577cc8ad335b066db28e21710c9c16e..4eaff652c7caf1c1fbde44be5927ea7dcb178226 100644 (file)
@@ -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" );
    }
 
index 954096f6770b99944348fbaf7808f9f139a12b11..100121091799d2bd27634cd3182d2b6b3799ac35 100644 (file)
@@ -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) \
index 153e401a1651e147e2a78dcb68a269d8d0c7821e..025d8f63af499ffaeb4d03a107de70b4972874f1 100644 (file)
@@ -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;
index 85f87c4da394305108b6d7dfc81c5ee252e2aae4..3dc52ba96a845c72bd3f1d848895029710c1d4d3 100644 (file)
@@ -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;