Hi all,

I attached a patch against the config-0-0-1-branch that includes a
vblank configuration cleanup as proposed in a previous mail. I've tested
this briefly with the radeon driver and it seems to work all right. The
default setting is now as defined in the GLX_SGI_swap_control spec a
swap interval of 1.

The patch also removes all non-functional or unimplemented options from
the drivers. With these change I think I have the config branch in the
shape I want it to be before merging it with the trunk.

There are two potential issues with this patch but I believe they are
solved correctly (please correct me if I'm wrong or overlooked something
else):

1. Binary compatibility: I changed the default swap_interval in
driCreateDrawable to a special value with the idea that it gets set when
the drawable is first bound to a dri context. As dri_util.c is linked
with the driver, both should interpret that special value in the same
way and binary compatibility should be no problem.

2. Reading the swap_interval with glXGetSwapIntervalMESA: As this
function works with a a current context it will only return the
swap_interval of drawables that are bound to a dri context. Thus it
should never expose the special default value to the application.

If no one objects I'll commit this on monday. Otherwise we can discuss
it on IRC on monday.

There are more issues with the vblank implementation in general. I
intend to look into that after the merge. I'd like to talk about that on
IRC on monday as well.

Best regards,
  Felix

------------    __\|/__    ___     ___       -------------------------
 Felix       ___\_e -_/___/ __\___/ __\_____   You can do anything,
   Kühling  (_____\Ä/____/ /_____/ /________)  just not everything
 [EMAIL PROTECTED]       \___/   \___/   U        at the same time.
--- ./dri/dri_util.c.~1.13.~    2003-05-23 12:18:29.000000000 +0200
+++ ./dri/dri_util.c    2003-08-30 18:27:45.000000000 +0200
@@ -807,8 +807,10 @@
         pdraw->frameTracking = NULL;
         pdraw->queryFrameTracking = driQueryFrameTracking;
 
-        pdraw->swap_interval = (getenv( "LIBGL_THROTTLE_REFRESH" ) == NULL)
-           ? 0 : 1;
+        /* This special default value is replaced with the configured
+        * default value when the drawable is first bound to a direct
+        * rendering context. */
+        pdraw->swap_interval = (unsigned)-1;
     }
 
     pdp->swapBuffers = psp->DriverAPI.SwapBuffers;
--- ./mesa/src/drv/common/vblank.c.~1.4.2.1.~   2003-05-30 22:59:04.000000000 +0200
+++ ./mesa/src/drv/common/vblank.c      2003-08-30 14:17:13.000000000 +0200
@@ -33,6 +33,7 @@
 #include "macros.h"
 #include "dd.h"
 #include "vblank.h"
+#include "xmlpool.h"
 
 
 /****************************************************************************/
@@ -181,16 +182,29 @@
 GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache )
 {
    GLuint  flags = 0;
-
+   int vblank_mode;
 
    flags |= (driCompareGLXAPIVersion( 20030317 ) >= 0) 
        ? VBLANK_FLAG_INTERVAL : 0;
-   if ( driCheckOption( optionCache, "sync_refresh", DRI_BOOL ) )
-      flags |= driQueryOptionb( optionCache, "sync_refresh" )
-        ? VBLANK_FLAG_SYNC : 0;
-   if ( driCheckOption( optionCache, "throttle_refresh", DRI_BOOL ) )
-      flags |= driQueryOptionb( optionCache, "throttle_refresh" )
-        ? VBLANK_FLAG_THROTTLE : 0;
+
+   if ( driCheckOption( optionCache, "vblank_mode", DRI_ENUM ) )
+      vblank_mode = driQueryOptioni( optionCache, "vblank_mode" );
+   else
+      vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
+
+   switch (vblank_mode) {
+   case DRI_CONF_VBLANK_NEVER:
+      flags = 0;
+      break;
+   case DRI_CONF_VBLANK_DEF_INTERVAL_0:
+      break;
+   case DRI_CONF_VBLANK_DEF_INTERVAL_1:
+      flags |= VBLANK_FLAG_THROTTLE;
+      break;
+   case DRI_CONF_VBLANK_ALWAYS_SYNC:
+      flags |= VBLANK_FLAG_SYNC;
+      break;
+   }
 
    return flags;
 }
@@ -198,6 +212,21 @@
 
 /****************************************************************************/
 /**
+ * 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
  * wrap the error message logging.  The error message should only be logged
  * the first time the \c drmWaitVBlank fails.  If \c drmWaitVBlank is
@@ -259,7 +288,10 @@
 
 
    *missed_deadline = GL_FALSE;
-   if ( (flags & VBLANK_FLAG_NO_IRQ) != 0 ) {
+   if ( (flags & (VBLANK_FLAG_INTERVAL |
+                 VBLANK_FLAG_THROTTLE |
+                 VBLANK_FLAG_SYNC)) == 0 ||
+       (flags & VBLANK_FLAG_NO_IRQ) != 0 ) {
       return 0;
    }
 
@@ -288,6 +320,9 @@
 
    if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
       interval = priv->pdraw->swap_interval;
+      /* this must have been initialized when the drawable was first bound
+       * to a direct rendering context. */
+      assert ( interval != (unsigned)-1 );
    }
    else if ( (flags & VBLANK_FLAG_THROTTLE) != 0 ) {
       interval = 1;
--- ./mesa/src/drv/common/vblank.h.~1.4.2.1.~   2003-05-30 22:38:59.000000000 +0200
+++ ./mesa/src/drv/common/vblank.h      2003-08-30 14:15:38.000000000 +0200
@@ -47,6 +47,7 @@
 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 int driWaitForVBlank( const __DRIdrawablePrivate *priv,
     GLuint * vbl_seq, GLuint flags, GLboolean * missed_deadline );
 
--- ./mesa/src/drv/common/xmlpool.h.~1.1.2.5.~  2003-08-30 00:01:22.000000000 +0200
+++ ./mesa/src/drv/common/xmlpool.h     2003-08-30 18:54:40.000000000 +0200
@@ -162,6 +162,7 @@
                 DRI_CONF_ENUM(3,"Umgehe MESA's Pipeline mit zustandsbasierter 
Codegenerierung") \
         DRI_CONF_DESC_END \
 DRI_CONF_OPT_END
+
 #define DRI_CONF_FTHROTTLE_BUSY 0
 #define DRI_CONF_FTHROTTLE_USLEEPS 1
 #define DRI_CONF_FTHROTTLE_IRQS 2
@@ -178,27 +179,13 @@
                 DRI_CONF_ENUM(2,"Sortware Interrutps") \
         DRI_CONF_DESC_END \
 DRI_CONF_OPT_END
-#define DRI_CONF_FORCE_TCL(def) \
-DRI_CONF_OPT_BEGIN(force_tcl,bool,def) \
-        DRI_CONF_DESC(en,"Force hardware T&L (dangerous!)") \
-        DRI_CONF_DESC(de,"Erzwinge Hardware T&L (gefährlich!)") \
-DRI_CONF_OPT_END
-#define DRI_CONF_SYNC_REFRESH(def) \
-DRI_CONF_OPT_BEGIN(sync_refresh,bool,def) \
-        DRI_CONF_DESC(en,"Synchronize to CRT refresh") \
-        DRI_CONF_DESC(de,"Synchronisation mit Kathodenstrahlrücklauf") \
-DRI_CONF_OPT_END
-#define DRI_CONF_THROTTLE_REFRESH(def) \
-DRI_CONF_OPT_BEGIN(throttle_refresh,bool,def) \
-        DRI_CONF_DESC(en,"Throttle frame rate to CRT refresh rate") \
-        DRI_CONF_DESC(de,"Begrenze Framerate auf Bildwiederholfrequenz") \
-DRI_CONF_OPT_END
-#define DRI_CONF_VSYNC_NEVER 0
-#define DRI_CONF_VSYNC_DEF_INTERVAL_0 1
-#define DRI_CONF_VSYNC_DEF_INTERVAL_1 2
-#define DRI_CONF_VSYNC_ALWAYS_SYNC 3
-#define DRI_CONF_VSYNC_MODE(def) \
-DRI_CONF_OPT_BEGIN_V(vsync,enum,def,"0:3") \
+
+#define DRI_CONF_VBLANK_NEVER 0
+#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
+#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
+#define DRI_CONF_VBLANK_ALWAYS_SYNC 3
+#define DRI_CONF_VBLANK_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(vblank_mode,enum,def,"0:3") \
         DRI_CONF_DESC_BEGIN(en,"Synchronization with vertical refresh (swap 
intervals)") \
                 DRI_CONF_ENUM(0,"Never, FPS rulez!") \
                 DRI_CONF_ENUM(1,"Application preference, default interval 0") \
--- ./mesa/src/drv/mga/mga_xmesa.c.~1.52.2.1.~  2003-06-11 23:16:08.000000000 +0200
+++ ./mesa/src/drv/mga/mga_xmesa.c      2003-08-30 18:03:27.000000000 +0200
@@ -65,11 +65,10 @@
 const char __driConfigOptions[] =
 DRI_CONF_BEGIN
     DRI_CONF_SECTION_PERFORMANCE
-        DRI_CONF_SYNC_REFRESH(false)
-        DRI_CONF_THROTTLE_REFRESH(false)
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
     DRI_CONF_SECTION_END
 DRI_CONF_END;
-const GLuint __driNConfigOptions = 2;
+const GLuint __driNConfigOptions = 1;
 
 #ifndef MGA_DEBUG
 int MGA_DEBUG = 0;
@@ -640,6 +639,7 @@
       mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
 
       if (mmesa->driDrawable != driDrawPriv) {
+        driDrawableInitVBlank( driDrawPriv, mmesa->vblank_flags );
         mmesa->driDrawable = driDrawPriv;
         mmesa->dirty = ~0; 
         mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK); 
--- ./mesa/src/drv/r128/r128_context.c.~1.23.2.2.~      2003-08-29 23:54:45.000000000 
+0200
+++ ./mesa/src/drv/r128/r128_context.c  2003-08-30 16:10:55.000000000 +0200
@@ -71,14 +71,13 @@
     DRI_CONF_SECTION_END
 #endif
     DRI_CONF_SECTION_PERFORMANCE
-        DRI_CONF_SYNC_REFRESH(false)
-        DRI_CONF_THROTTLE_REFRESH(false)
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
     DRI_CONF_SECTION_END
 DRI_CONF_END;
 #if ENABLE_PERF_BOXES
-const GLuint __driNConfigOptions = 4;
+const GLuint __driNConfigOptions = 2;
 #else
-const GLuint __driNConfigOptions = 3;
+const GLuint __driNConfigOptions = 1;
 #endif
 
 #ifndef R128_DEBUG
@@ -326,6 +325,7 @@
         newR128Ctx->dirty = R128_UPLOAD_ALL;
       }
 
+      driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags );
       newR128Ctx->driDrawable = driDrawPriv;
 
       _mesa_make_current2( newR128Ctx->glCtx,
--- ./mesa/src/drv/r200/r200_context.c.~1.25.2.2.~      2003-08-29 23:49:05.000000000 
+0200
+++ ./mesa/src/drv/r200/r200_context.c  2003-08-30 16:13:14.000000000 +0200
@@ -77,17 +77,15 @@
 const char __driConfigOptions[] =
 DRI_CONF_BEGIN
     DRI_CONF_SECTION_DEBUG
-        DRI_CONF_PERFORMANCE_BOXES(false)
         DRI_CONF_NO_RAST(false)
     DRI_CONF_SECTION_END
     DRI_CONF_SECTION_PERFORMANCE
         DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
         DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
-        DRI_CONF_SYNC_REFRESH(false)
-        DRI_CONF_THROTTLE_REFRESH(false)
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
     DRI_CONF_SECTION_END
 DRI_CONF_END;
-const GLuint __driNConfigOptions = 6;
+const GLuint __driNConfigOptions = 4;
 
 
 /* Return the width and height of the given buffer.
@@ -577,7 +575,8 @@
         fprintf(stderr, "%s ctx %p\n", __FUNCTION__, newCtx->glCtx);
 
       if ( newCtx->dri.drawable != driDrawPriv ) {
+        driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
         newCtx->dri.drawable = driDrawPriv;
         r200UpdateWindow( newCtx->glCtx );
         r200UpdateViewportOffset( newCtx->glCtx );
--- ./mesa/src/drv/radeon/radeon_context.c.~1.37.2.7.~  2003-08-29 23:48:21.000000000 
+0200
+++ ./mesa/src/drv/radeon/radeon_context.c      2003-08-30 18:57:54.000000000 +0200
@@ -76,21 +76,15 @@
 const char __driConfigOptions[] =
 DRI_CONF_BEGIN
     DRI_CONF_SECTION_DEBUG
-        DRI_CONF_DEBUG_DMA(false) /* not implemented */
-        DRI_CONF_PERFORMANCE_BOXES(false) /* doesn't really work */
         DRI_CONF_NO_RAST(false)
     DRI_CONF_SECTION_END
-    DRI_CONF_SECTION_TEXTURE
-        DRI_CONF_PREFERRED_BPT(0,"0,16,32") /* not implemented */
-    DRI_CONF_SECTION_END
     DRI_CONF_SECTION_PERFORMANCE
         DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
         DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
-        DRI_CONF_SYNC_REFRESH(false)
-        DRI_CONF_THROTTLE_REFRESH(false)
+        DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
     DRI_CONF_SECTION_END
 DRI_CONF_END;
-const GLuint __driNConfigOptions = 8;
+const GLuint __driNConfigOptions = 4;
 
 /* Return the width and height of the given buffer.
  */
@@ -371,7 +365,7 @@
       MIN2( ctx->Const.MaxArrayLockSize, 
            RADEON_BUFFER_SIZE / RADEON_MAX_TCL_VERTSIZE ); 
 
-   rmesa->boxes = driQueryOptionb(&rmesa->optionCache, "performance_boxes");
+   rmesa->boxes = 0;
 
    /* Initialize the software rasterizer and helper modules.
     */
@@ -586,6 +580,7 @@
         fprintf(stderr, "%s ctx %p\n", __FUNCTION__, newCtx->glCtx);
 
       if ( newCtx->dri.drawable != driDrawPriv ) {
+        driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
         newCtx->dri.drawable = driDrawPriv;
         radeonUpdateWindow( newCtx->glCtx );
         radeonUpdateViewportOffset( newCtx->glCtx );

Reply via email to