diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-07-24 19:03:22 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-07-24 19:03:22 +0000 |
commit | c72e0a1f0262c8847cd3641897acabe86ca15d88 (patch) | |
tree | 45396e9607c1551506c0a4faaf3721d1b7b4f547 /dist | |
parent | 0be1a8dd2728d0a7ea05ead17a5f89630accfd32 (diff) |
Two patches cherry picked from mesa master just after 7.8 was branched
(but never made it into the 7.8 branch).
first:
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date: Thu Apr 22 12:47:41 2010 -0700
DRI2: add config query extension
Add a new DRI2 configuration query extension. Allows for DRI2
client code to query for common DRI2 configuration options.
second:
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date: Thu Apr 22 12:49:03 2010 -0700
DRI2/GLX: check for vblank_mode in DRI2 GLX code
Re-add support for the vblank_mode environment and configuration
variable. Useful for benchmarking and app control.
The final affect being that config and environment variables for
controlling swap mode work with dri2 now. which helps me a lot with
debugging.
ok matthieu@.
Diffstat (limited to 'dist')
-rw-r--r-- | dist/Mesa/include/GL/internal/dri_interface.h | 14 | ||||
-rw-r--r-- | dist/Mesa/src/glx/dri2_glx.c | 41 | ||||
-rw-r--r-- | dist/Mesa/src/glx/dri_common.c | 5 | ||||
-rw-r--r-- | dist/Mesa/src/glx/glxclient.h | 4 | ||||
-rw-r--r-- | dist/Mesa/src/mesa/drivers/dri/common/dri_util.c | 57 | ||||
-rw-r--r-- | dist/Mesa/src/mesa/drivers/dri/common/dri_util.h | 4 | ||||
-rw-r--r-- | dist/Mesa/src/mesa/drivers/dri/intel/intel_screen.c | 1 | ||||
-rw-r--r-- | dist/Mesa/src/mesa/drivers/dri/nouveau/nouveau_screen.c | 1 | ||||
-rw-r--r-- | dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c | 2 | ||||
-rw-r--r-- | dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h | 2 |
10 files changed, 128 insertions, 3 deletions
diff --git a/dist/Mesa/include/GL/internal/dri_interface.h b/dist/Mesa/include/GL/internal/dri_interface.h index 1d4e82e15..635f5c0c4 100644 --- a/dist/Mesa/include/GL/internal/dri_interface.h +++ b/dist/Mesa/include/GL/internal/dri_interface.h @@ -806,4 +806,18 @@ struct __DRIimageLookupExtensionRec { void *loaderPrivate); }; +/** + * This extension allows for common DRI2 options + */ +#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY" +#define __DRI2_CONFIG_QUERY_VERSION 1 + +typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension; +struct __DRI2configQueryExtensionRec { + __DRIextension base; + + int (*configQueryb)(__DRIscreen *screen, const char *var, GLboolean *val); + int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val); + int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val); +}; #endif diff --git a/dist/Mesa/src/glx/dri2_glx.c b/dist/Mesa/src/glx/dri2_glx.c index 1c344489c..6058c721d 100644 --- a/dist/Mesa/src/glx/dri2_glx.c +++ b/dist/Mesa/src/glx/dri2_glx.c @@ -47,7 +47,12 @@ #include "xf86drm.h" #include "dri2.h" #include "dri_common.h" -#include "../../mesa/drivers/dri/common/dri_util.h" + +/* From xmlpool/options.h, user exposed so should be stable */ +#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 #undef DRI2_MINOR #define DRI2_MINOR 1 @@ -177,6 +182,7 @@ dri2CreateDrawable(__GLXscreenConfigs * psc, __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; __GLXdisplayPrivate *dpyPriv; __GLXDRIdisplayPrivate *pdp; + GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; pdraw = Xmalloc(sizeof(*pdraw)); if (!pdraw) @@ -187,9 +193,24 @@ dri2CreateDrawable(__GLXscreenConfigs * psc, pdraw->base.drawable = drawable; pdraw->base.psc = psc; pdraw->bufferCount = 0; - pdraw->swap_interval = 1; + pdraw->swap_interval = 1; /* default may be overridden below */ pdraw->have_back = 0; + if (psc->config) + psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode); + + switch (vblank_mode) { + case DRI_CONF_VBLANK_NEVER: + case DRI_CONF_VBLANK_DEF_INTERVAL_0: + pdraw->swap_interval = 0; + break; + case DRI_CONF_VBLANK_DEF_INTERVAL_1: + case DRI_CONF_VBLANK_ALWAYS_SYNC: + default: + pdraw->swap_interval = 1; + break; + } + DRI2CreateDrawable(psc->dpy, xDrawable); dpyPriv = __glXInitialize(psc->dpy); @@ -477,7 +498,23 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable, static void dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval) { + __GLXscreenConfigs *psc = pdraw->psc; __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw; + GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; + + if (psc->config) + psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode); + + switch (vblank_mode) { + case DRI_CONF_VBLANK_NEVER: + return; + case DRI_CONF_VBLANK_ALWAYS_SYNC: + if (interval <= 0) + return; + break; + default: + break; + } DRI2SwapInterval(priv->base.psc->dpy, pdraw->xDrawable, interval); priv->swap_interval = interval; diff --git a/dist/Mesa/src/glx/dri_common.c b/dist/Mesa/src/glx/dri_common.c index d26bdfff4..c56cb9def 100644 --- a/dist/Mesa/src/glx/dri_common.c +++ b/dist/Mesa/src/glx/dri_common.c @@ -403,6 +403,11 @@ dri2BindExtensions(__GLXscreenConfigs *psc) /* internal driver extension, no GL extension exposed */ } #endif + +#ifdef __DRI2_CONFIG_QUERY + if ((strcmp(extensions[i]->name, __DRI2_CONFIG_QUERY) == 0)) + psc->config = (__DRI2configQueryExtension *) extensions[i]; +#endif } } diff --git a/dist/Mesa/src/glx/glxclient.h b/dist/Mesa/src/glx/glxclient.h index 958e1526c..57d254ea9 100644 --- a/dist/Mesa/src/glx/glxclient.h +++ b/dist/Mesa/src/glx/glxclient.h @@ -557,6 +557,10 @@ struct __GLXscreenConfigsRec const __DRI2flushExtension *f; #endif +#ifdef __DRI2_CONFIG_QUERY + const __DRI2configQueryExtension *config; +#endif + #endif /** diff --git a/dist/Mesa/src/mesa/drivers/dri/common/dri_util.c b/dist/Mesa/src/mesa/drivers/dri/common/dri_util.c index 75c98825b..e971b55f5 100644 --- a/dist/Mesa/src/mesa/drivers/dri/common/dri_util.c +++ b/dist/Mesa/src/mesa/drivers/dri/common/dri_util.c @@ -31,6 +31,17 @@ #include "dri_util.h" #include "drm_sarea.h" #include "utils.h" +#include "vblank.h" +#include "xmlpool.h" + +PUBLIC const char __dri2ConfigOptions[] = + DRI_CONF_BEGIN + DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1) + DRI_CONF_SECTION_END + DRI_CONF_END; + +static const uint __dri2NConfigOptions = 1; #ifndef GLX_OML_sync_control typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t *numerator, int32_t *denominator); @@ -495,6 +506,41 @@ dri2CreateNewDrawable(__DRIscreen *screen, return pdraw; } +static int +dri2ConfigQueryb(__DRIscreen *screen, const char *var, GLboolean *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_BOOL)) + return -1; + + *val = driQueryOptionb(&screen->optionCache, var); + + return 0; +} + +static int +dri2ConfigQueryi(__DRIscreen *screen, const char *var, GLint *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_INT) && + !driCheckOption(&screen->optionCache, var, DRI_ENUM)) + return -1; + + *val = driQueryOptioni(&screen->optionCache, var); + + return 0; +} + +static int +dri2ConfigQueryf(__DRIscreen *screen, const char *var, GLfloat *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_FLOAT)) + return -1; + + *val = driQueryOptionf(&screen->optionCache, var); + + return 0; +} + + static void dri_get_drawable(__DRIdrawable *pdp) { pdp->refcount++; @@ -785,6 +831,7 @@ dri2CreateNewScreen(int scrn, int fd, static const __DRIextension *emptyExtensionList[] = { NULL }; __DRIscreen *psp; drmVersionPtr version; + driOptionCache options; if (driDriverAPI.InitScreen2 == NULL) return NULL; @@ -817,6 +864,9 @@ dri2CreateNewScreen(int scrn, int fd, psp->DriverAPI = driDriverAPI; + driParseOptionInfo(&options, __dri2ConfigOptions, __dri2NConfigOptions); + driParseConfigFiles(&psp->optionCache, &options, psp->myNum, "dri2"); + return psp; } @@ -859,6 +909,13 @@ const __DRIdri2Extension driDRI2Extension = { dri2CreateNewContext, }; +const __DRI2configQueryExtension dri2ConfigQueryExtension = { + { __DRI2_CONFIG_QUERY, __DRI2_CONFIG_QUERY_VERSION }, + dri2ConfigQueryb, + dri2ConfigQueryi, + dri2ConfigQueryf, +}; + static int driFrameTracking(__DRIdrawable *drawable, GLboolean enable) { diff --git a/dist/Mesa/src/mesa/drivers/dri/common/dri_util.h b/dist/Mesa/src/mesa/drivers/dri/common/dri_util.h index 99c0f1e44..3c25e0b35 100644 --- a/dist/Mesa/src/mesa/drivers/dri/common/dri_util.h +++ b/dist/Mesa/src/mesa/drivers/dri/common/dri_util.h @@ -51,6 +51,7 @@ #include <drm.h> #include <drm_sarea.h> #include <xf86drm.h> +#include "xmlconfig.h" #include "main/glheader.h" #include "GL/internal/glcore.h" #include "GL/internal/dri_interface.h" @@ -70,6 +71,7 @@ extern const __DRIcopySubBufferExtension driCopySubBufferExtension; extern const __DRIswapControlExtension driSwapControlExtension; extern const __DRIframeTrackingExtension driFrameTrackingExtension; extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension; +extern const __DRI2configQueryExtension dri2ConfigQueryExtension; /** * Used by DRI_VALIDATE_DRAWABLE_INFO @@ -549,6 +551,8 @@ struct __DRIscreenRec { /* The lock actually in use, old sarea or DRI2 */ drmLock *lock; + + driOptionCache optionCache; }; extern void diff --git a/dist/Mesa/src/mesa/drivers/dri/intel/intel_screen.c b/dist/Mesa/src/mesa/drivers/dri/intel/intel_screen.c index 6e4bb6436..2845fd5e9 100644 --- a/dist/Mesa/src/mesa/drivers/dri/intel/intel_screen.c +++ b/dist/Mesa/src/mesa/drivers/dri/intel/intel_screen.c @@ -225,6 +225,7 @@ static const __DRIextension *intelScreenExtensions[] = { &intelTexBufferExtension.base, &intelFlushExtension.base, &intelImageExtension.base, + &dri2ConfigQueryExtension.base, NULL }; diff --git a/dist/Mesa/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/dist/Mesa/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 18db12f62..78987f633 100644 --- a/dist/Mesa/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/dist/Mesa/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -236,6 +236,7 @@ static const struct __DRItexBufferExtensionRec nouveau_texbuffer_extension = { static const __DRIextension *nouveau_screen_extensions[] = { &nouveau_flush_extension.base, &nouveau_texbuffer_extension.base, + &dri2ConfigQueryExtension.base, NULL }; diff --git a/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c b/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c index 8d607f0f6..3f1f8ee60 100644 --- a/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -1213,6 +1213,8 @@ radeonCreateScreen( __DRIscreen *sPriv ) screen->extensions[i++] = &r600texOffsetExtension.base; #endif + screen->extensions[i++] = &dri2ConfigQueryExtension.base; + screen->extensions[i++] = NULL; sPriv->extensions = screen->extensions; diff --git a/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h b/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h index 49c9871a1..2f4641a81 100644 --- a/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/dist/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -104,7 +104,7 @@ typedef struct radeon_screen { /* Configuration cache with default values for all contexts */ driOptionCache optionCache; - const __DRIextension *extensions[16]; + const __DRIextension *extensions[17]; int num_gb_pipes; int num_z_pipes; |