Make driDrawableInitVBlank() initialize the sequence number.
authorMichel Dänzer <michel@daenzer.net>
Thu, 28 Sep 2006 14:02:05 +0000 (14:02 +0000)
committerMichel Dänzer <michel@daenzer.net>
Thu, 28 Sep 2006 14:02:05 +0000 (14:02 +0000)
This prevents the first wait for vertical blank from timing out when the X
server has been running for a long time.

src/mesa/drivers/dri/common/vblank.c
src/mesa/drivers/dri/common/vblank.h
src/mesa/drivers/dri/i915/intel_context.c
src/mesa/drivers/dri/mach64/mach64_context.c
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/r128/r128_context.c
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/r300/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/unichrome/via_context.c

index eebe42d96a1f08d352c47931b3818c14f69dc3c3..25b912e82427b15dd4735a3a12450cb58a66be7b 100644 (file)
@@ -208,20 +208,6 @@ GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache )
 }
 
 
-/****************************************************************************/
-/**
- * Sets the default swap interval when the drawable is first bound to a
- * direct rendering context.
- */
-
-void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags )
-{
-   if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
-      priv->pdraw->swap_interval = (flags & VBLANK_FLAG_THROTTLE) != 0 ? 1 : 0;
-   }
-}
-
-
 /****************************************************************************/
 /**
  * Wrapper to call \c drmWaitVBlank.  The main purpose of this function is to
@@ -260,6 +246,25 @@ static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd )
 }
 
 
+/****************************************************************************/
+/**
+ * Sets the default swap interval when the drawable is first bound to a
+ * direct rendering context.
+ */
+
+void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags,
+                           GLuint *vbl_seq )
+{
+   if ( priv->pdraw->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) != 0 ? 1 : 0;
+   }
+}
+
+
 /****************************************************************************/
 /**
  * Waits for the vertical blank for use with glXSwapBuffers.
index 3dc965def1a790c22cea7bd6b1fc7e4bd46a4c6d..2663956858dd7eef82eb15de56fab2be36afc62a 100644 (file)
@@ -47,7 +47,8 @@ extern int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count );
 extern int driWaitForMSC32( __DRIdrawablePrivate *priv,
     int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc );
 extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache );
-extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv, GLuint flags );
+extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv, GLuint flags,
+                                   GLuint *vbl_seq );
 extern int driWaitForVBlank( const __DRIdrawablePrivate *priv,
     GLuint * vbl_seq, GLuint flags, GLboolean * missed_deadline );
 
index 770b330d0a374db0d27e0f9bcef7d6405bf0a301..45d8fb32616110272cce0e94e6ca175ba73b4de0 100644 (file)
@@ -596,7 +596,8 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
 
       if ( intel->driDrawable != driDrawPriv ) {
         /* Shouldn't the readbuffer be stored also? */
-        driDrawableInitVBlank( driDrawPriv, intel->vblank_flags );
+        driDrawableInitVBlank( driDrawPriv, intel->vblank_flags,
+                               &intel->vbl_seq );
 
         intel->driDrawable = driDrawPriv;
         intelWindowMoved( intel );
index 717b9b9e8d8a099958a2ce1be6659788f9bb55af..03ec96a222efe7284896fdc2553d3190862bfa68 100644 (file)
@@ -308,7 +308,8 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
       }
 
       
-      driDrawableInitVBlank( driDrawPriv, newMach64Ctx->vblank_flags );
+      driDrawableInitVBlank( driDrawPriv, newMach64Ctx->vblank_flags,
+                            &newMach64Ctx->vbl_seq );
 
       if ( newMach64Ctx->driDrawable != driDrawPriv ) {
         newMach64Ctx->driDrawable = driDrawPriv;
index 6450340a48c3fc4bdbea0bb20e83c55dda79dc27..73bcfcce738c465c7882a349728a9652a9b5f7a8 100644 (file)
@@ -878,7 +878,8 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
       mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
 
       if (mmesa->driDrawable != driDrawPriv) {
-        driDrawableInitVBlank( driDrawPriv, mmesa->vblank_flags );
+        driDrawableInitVBlank( driDrawPriv, mmesa->vblank_flags,
+                               &mmesa->vbl_seq );
         mmesa->driDrawable = driDrawPriv;
         mmesa->dirty = ~0; 
         mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK); 
index 2f30bd253bfee60ca52adfc695250ab96fd1ed02..8ec027542ad0620231da90346f33411b113f721b 100644 (file)
@@ -345,7 +345,8 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
         newR128Ctx->dirty = R128_UPLOAD_ALL;
       }
 
-      driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags );
+      driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags,
+                            &newR128Ctx->vbl_seq );
       newR128Ctx->driDrawable = driDrawPriv;
 
       _mesa_make_current( newR128Ctx->glCtx,
index 7a8f270160f1a60b1e09c2eb3af0f922f77d9c59..37abaa38de8e6a2252f170466f40f8a8b942f749 100644 (file)
@@ -694,7 +694,8 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
         fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)newCtx->glCtx);
 
       if ( newCtx->dri.drawable != driDrawPriv ) {
-        driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
+        driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags,
+                               &newCtx->vbl_seq );
         newCtx->dri.drawable = driDrawPriv;
         r200UpdateWindow( newCtx->glCtx );
         r200UpdateViewportOffset( newCtx->glCtx );
index 463b3cf85b1d2edc09bf6056726f048c2abde8ec..bfedae4dbdb8946fd8b7d02d3494d96c7b9ae364 100644 (file)
@@ -285,7 +285,8 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
 
                if (radeon->dri.drawable != driDrawPriv) {
                        driDrawableInitVBlank(driDrawPriv,
-                                             radeon->vblank_flags);
+                                             radeon->vblank_flags,
+                                             &radeon->vbl_seq);
                        radeon->dri.drawable = driDrawPriv;
                        
                        r300UpdateWindow(radeon->glCtx);
index 2167e7afe824109a91b507a0ca2719f68f26b8a4..edfa36fcc50089064d630d841327f1faea3e8bc8 100644 (file)
@@ -620,7 +620,8 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
 
       if ( newCtx->dri.drawable != driDrawPriv ) {
          /* XXX we may need to validate the drawable here!!! */
-        driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
+        driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags,
+                               &newCtx->vbl_seq );
         newCtx->dri.drawable = driDrawPriv;
         radeonUpdateWindow( newCtx->glCtx );
         radeonUpdateViewportOffset( newCtx->glCtx );
index ffde1b66b766c84fe0ed3cb60033fb3761ed63e0..2459336bd6675add6338b237cb838ddc8c3820fe 100644 (file)
@@ -815,7 +815,8 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
         readBuffer = (GLframebuffer *)driReadPriv->driverPrivate;
 
        if ( vmesa->driDrawable != driDrawPriv ) {
-          driDrawableInitVBlank( driDrawPriv, vmesa->vblank_flags );
+          driDrawableInitVBlank( driDrawPriv, vmesa->vblank_flags,
+                                 &vmesa->vbl_seq );
           vmesa->driDrawable = driDrawPriv;
           if ( ! calculate_buffer_parameters( vmesa, drawBuffer ) ) {
              return GL_FALSE;