summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/common/vblank.c
diff options
context:
space:
mode:
authorJon Smirl <[email protected]>2003-10-21 06:05:39 +0000
committerJon Smirl <[email protected]>2003-10-21 06:05:39 +0000
commitbcc6eddd335e97d49ed2ef3a1440f94d58dce12d (patch)
treeff4883dd4da6ce65500940aebe2c268716311fe6 /src/mesa/drivers/dri/common/vblank.c
parent906449753f126f74ad3321d0af897f6609880c17 (diff)
Update DRI drivers to current DRI CVS and make them work.
Diffstat (limited to 'src/mesa/drivers/dri/common/vblank.c')
-rw-r--r--src/mesa/drivers/dri/common/vblank.c64
1 files changed, 51 insertions, 13 deletions
diff --git a/src/mesa/drivers/dri/common/vblank.c b/src/mesa/drivers/dri/common/vblank.c
index e91dd65260c..d20f743bc9a 100644
--- a/src/mesa/drivers/dri/common/vblank.c
+++ b/src/mesa/drivers/dri/common/vblank.c
@@ -33,6 +33,7 @@
#include "macros.h"
#include "dd.h"
#include "vblank.h"
+#include "xmlpool.h"
/****************************************************************************/
@@ -127,7 +128,7 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
/* FIXME: This doesn't seem like the right thing to return here.
*/
-#ifndef _SOLO
+#ifndef _SOLO
return GLX_BAD_CONTEXT;
#else
return -1;
@@ -163,9 +164,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
/* FIXME: This doesn't seem like the right thing to return here.
*/
#ifndef _SOLO
- return GLX_BAD_CONTEXT;
+ return GLX_BAD_CONTEXT;
#else
- return -1;
+ return -1;
#endif
}
}
@@ -183,20 +184,35 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
/****************************************************************************/
/**
* Gets a set of default vertical-blank-wait flags based on the internal GLX
- * API version and several environment variables.
+ * API version and several configuration options.
*/
-GLuint driGetDefaultVBlankFlags( void )
+GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache )
{
GLuint flags = 0;
-
+ int vblank_mode;
flags |= (driCompareGLXAPIVersion( 20030317 ) >= 0)
? VBLANK_FLAG_INTERVAL : 0;
- flags |= (getenv("LIBGL_SYNC_REFRESH") != NULL)
- ? VBLANK_FLAG_SYNC : 0;
- flags |= (getenv("LIBGL_THROTTLE_REFRESH") != NULL)
- ? 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;
}
@@ -204,6 +220,22 @@ GLuint driGetDefaultVBlankFlags( void )
/****************************************************************************/
/**
+ * Sets the default swap interval when the drawable is first bound to a
+ * direct rendering context.
+ */
+
+void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags )
+{
+#ifndef _SOLO
+ if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
+ priv->pdraw->swap_interval = (flags & VBLANK_FLAG_THROTTLE) != 0 ? 1 : 0;
+ }
+#endif
+}
+
+
+/****************************************************************************/
+/**
* 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
@@ -265,7 +297,10 @@ driWaitForVBlank( const __DRIdrawablePrivate *priv, GLuint * vbl_seq,
*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;
}
@@ -293,11 +328,14 @@ driWaitForVBlank( const __DRIdrawablePrivate *priv, GLuint * vbl_seq,
vbl.request.type = DRM_VBLANK_ABSOLUTE;
if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
-#ifndef _SOLO
+#ifndef _SOLO
interval = priv->pdraw->swap_interval;
#else
interval = 0;
-#endif
+#endif
+ /* 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;