typedef struct __DRIextensionRec __DRIextension;
typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
+typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
/*@}*/
void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
};
+/**
+ * Used by drivers that implement the GLX_SGI_swap_control or
+ * GLX_MESA_swap_control extension.
+ */
+#define __DRI_SWAP_CONTROL "DRI_SwapControl"
+struct __DRIswapControlExtensionRec {
+ __DRIextension base;
+ void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
+ unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
+};
/**
* \name Functions provided by the driver loader.
int (*queryFrameTracking)(__DRIdrawable *drawable,
int64_t * sbc, int64_t * missedFrames,
float * lastMissedUsage, float * usage);
-
- /**
- * Used by drivers that implement the GLX_SGI_swap_control or
- * GLX_MESA_swap_control extension.
- *
- * \since Internal API version 20030317.
- */
- unsigned swap_interval;
};
#endif
__DRIcopySubBufferExtension *copySubBuffer;
#endif
+#ifdef __DRI_SWAP_CONTROL
+ __DRIswapControlExtension *swapControl;
+#endif
+
#endif
/**
return GLX_BAD_VALUE;
}
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_CONTROL
if ( gc->isDirect ) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
__DRIdrawable * const pdraw = GetDRIDrawable( gc->currentDpy,
gc->currentDrawable,
NULL );
- if ( __glXExtensionBitIsEnabled( psc, SGI_swap_control_bit )
- && (pdraw != NULL) ) {
- pdraw->swap_interval = interval;
+ if (psc->swapControl != NULL && pdraw != NULL) {
+ psc->swapControl->setSwapInterval(pdraw, interval);
return 0;
}
else {
*/
static int __glXSwapIntervalMESA(unsigned int interval)
{
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_CONTROL
GLXContext gc = __glXGetCurrentContext();
if ( interval < 0 ) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
- if ( (psc != NULL) && (psc->driScreen.private != NULL)
- && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) {
+ if ( (psc != NULL) && (psc->driScreen.private != NULL) ) {
__DRIdrawable * const pdraw =
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
- if ( pdraw != NULL ) {
- pdraw->swap_interval = interval;
+ if (psc->swapControl != NULL && pdraw != NULL) {
+ psc->swapControl->setSwapInterval(pdraw, interval);
return 0;
}
}
static int __glXGetSwapIntervalMESA(void)
{
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_CONTROL
GLXContext gc = __glXGetCurrentContext();
if ( (gc != NULL) && gc->isDirect ) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
- if ( (psc != NULL) && (psc->driScreen.private != NULL)
- && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) {
+ if ( (psc != NULL) && (psc->driScreen.private != NULL) ) {
__DRIdrawable * const pdraw =
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
- if ( pdraw != NULL ) {
- return pdraw->swap_interval;
+ if (psc->swapControl != NULL && pdraw != NULL) {
+ return psc->swapControl->getSwapInterval(pdraw);
}
}
}
}
#endif
+
+#ifdef __DRI_SWAP_CONTROL
+ if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
+ psc->swapControl = (__DRIswapControlExtension *) extensions[i];
+ __glXScrEnableExtension(&psc->driScreen,
+ "GLX_SGI_swap_control");
+ __glXScrEnableExtension(&psc->driScreen,
+ "GLX_MESA_swap_control");
+
+ }
+#endif
+
/* Ignore unknown extensions */
}
}
{ __DRI_COPY_SUB_BUFFER }, driCopySubBuffer
};
+static void driSetSwapInterval(__DRIdrawable *drawable, unsigned int interval)
+{
+ __DRIdrawablePrivate *dpriv = drawable->private;
+
+ dpriv->swap_interval = interval;
+}
+
+static unsigned int driGetSwapInterval(__DRIdrawable *drawable)
+{
+ __DRIdrawablePrivate *dpriv = drawable->private;
+
+ return dpriv->swap_interval;
+}
+
+const __DRIswapControlExtension driSwapControlExtension = {
+ { __DRI_SWAP_CONTROL },
+ driSetSwapInterval,
+ driGetSwapInterval
+};
+
+
/**
* This is called via __DRIscreenRec's createNewDrawable pointer.
*/
* default value when the drawable is first bound to a direct
* rendering context.
*/
- pdraw->swap_interval = (unsigned)-1;
+ pdp->swap_interval = (unsigned)-1;
pdp->swapBuffers = psp->DriverAPI.SwapBuffers;
{
__DRIscreenPrivate *psp;
- static const __DRIextension emptyExtensionList[] = { NULL };
+ static const __DRIextension *emptyExtensionList[] = { NULL };
dri_interface = interface;
api_ver = internal_api_version;
if ( (*dri_interface->getMSCRate)(dPriv->pdraw, &n, &d) ) {
- interval = (dPriv->pdraw->swap_interval != 0)
- ? dPriv->pdraw->swap_interval : 1;
+ interval = (dPriv->swap_interval != 0) ? dPriv->swap_interval : 1;
/* We want to calculate
* Extensions.
*/
extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
+extern const __DRIswapControlExtension driSwapControlExtension;
/**
* Used by DRI_VALIDATE_DRAWABLE_INFO
* Called via glXSwapBuffers().
*/
void (*swapBuffers)( __DRIdrawablePrivate *dPriv );
+
+ /**
+ * Controls swap interval as used by GLX_SGI_swap_control and
+ * GLX_MESA_swap_control.
+ */
+ unsigned int swap_interval;
};
/**
void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags,
GLuint *vbl_seq )
{
- if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
+ if ( priv->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 |
- VBLANK_FLAG_SYNC)) != 0 ? 1 : 0;
+ priv->swap_interval = (flags & (VBLANK_FLAG_THROTTLE |
+ VBLANK_FLAG_SYNC)) != 0 ? 1 : 0;
}
}
if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
/* this must have been initialized when the drawable was first bound
* to a direct rendering context. */
- assert ( priv->pdraw->swap_interval != (unsigned)-1 );
+ assert ( priv->swap_interval != (unsigned)-1 );
- return priv->pdraw->swap_interval;
+ return priv->swap_interval;
}
else if ( (flags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) != 0 ) {
return 1;
if (intel->ctx.DrawBuffer == &intel_fb->Base) {
if (intel->driDrawable != driDrawPriv) {
- if (driDrawPriv->pdraw->swap_interval == (unsigned)-1) {
+ if (driDrawPriv->swap_interval == (unsigned)-1) {
int i;
intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
static const __DRIextension *intelExtensions[] = {
&driCopySubBufferExtension.base,
+ &driSwapControlExtension.base,
NULL
};
sPriv->extensions = intelExtensions;
if (glx_enable_extension != NULL) {
- (*glx_enable_extension) (sPriv->psc, "GLX_SGI_swap_control");
(*glx_enable_extension) (sPriv->psc, "GLX_SGI_video_sync");
- (*glx_enable_extension) (sPriv->psc, "GLX_MESA_swap_control");
(*glx_enable_extension) (sPriv->psc, "GLX_MESA_swap_frame_usage");
(*glx_enable_extension) (sPriv->psc, "GLX_SGI_make_current_read");
}
static const __DRIextension *intelExtensions[] = {
&driCopySubBufferExtension.base,
+ &driSwapControlExtension.base,
NULL
};
sPriv->extensions = intelExtensions;
if (glx_enable_extension != NULL) {
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" );
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" );
(*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" );
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
}
ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv;
PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ int i;
if (sPriv->devPrivSize != sizeof(ATIDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(ATIDRIRec) does not match passed size from device driver\n");
mach64Screen->driScreen = sPriv;
+ i = 0;
if ( glx_enable_extension != NULL ) {
if ( mach64Screen->irq != 0 ) {
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" );
+ mach64Screen->extensions[i++] = &driSwapControlExtension.base;
+
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" );
}
(*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" );
}
+ mach64Screen->extensions[i++] = NULL;
+ sPriv->extensions = mach64Screen->extensions;
return mach64Screen;
}
__DRIscreenPrivate *driScreen;
driOptionCache optionCache;
+
+ const __DRIextension *extensions[2];
} mach64ScreenRec, *mach64ScreenPtr;
#endif /* __MACH64_SCREEN_H__ */
}
+static const __DRIextension *mgaExtensions[] = {
+ &driSwapControlExtension.base,
+ NULL
+};
+
static GLboolean
mgaInitDriver(__DRIscreenPrivate *sPriv)
{
}
}
+ sPriv->extensions = mgaExtensions;
+
if ( glx_enable_extension != NULL ) {
- (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" );
(*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_swap_control" );
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
}
R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ int i;
if (sPriv->devPrivSize != sizeof(R128DRIRec)) {
fprintf(stderr,"\nERROR! sizeof(R128DRIRec) does not match passed size from device driver\n");
r128Screen->driScreen = sPriv;
+ i = 0;
if ( glx_enable_extension != NULL ) {
if ( r128Screen->irq != 0 ) {
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" );
+ r128Screen->extensions[i++] = &driSwapControlExtension.base;
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" );
}
(*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" );
}
+ r128Screen->extensions[i++] = NULL;
+ sPriv->extensions = r128Screen->extensions;
return r128Screen;
}
/* Configuration cache with default values for all contexts */
driOptionCache optionCache;
+ const __DRIextension *extensions[2];
+
} r128ScreenRec, *r128ScreenPtr;
return modes;
}
-static const __DRIextension *radeonExtensions[] = {
- &driCopySubBufferExtension.base,
- NULL
-};
-
/* Create the device specific screen private data struct.
*/
static radeonScreenPtr
unsigned char *RADEONMMIO;
PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ int i;
if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
dri_priv->log2GARTTexGran;
}
- sPriv->extensions = radeonExtensions;
+ i = 0;
+ screen->extensions[i++] = &driCopySubBufferExtension.base;
if ( glx_enable_extension != NULL ) {
if ( screen->irq != 0 ) {
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" );
+ screen->extensions[i++] = &driSwapControlExtension.base;
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" );
}
(*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_frame_usage" );
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
}
+ screen->extensions[i++] = NULL;
+ sPriv->extensions = screen->extensions;
#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
if (IS_R200_CLASS(screen)) {
/* Configuration cache with default values for all contexts */
driOptionCache optionCache;
+
+ const __DRIextension *extensions[3];
} radeonScreenRec, *radeonScreenPtr;
#define IS_R100_CLASS(screen) \
VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
(PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ int i;
if (sPriv->devPrivSize != sizeof(VIADRIRec)) {
fprintf(stderr,"\nERROR! sizeof(VIADRIRec) does not match passed size from device driver\n");
viaScreen->sareaPrivOffset = gDRIPriv->sarea_priv_offset;
+ i = 0;
if ( glx_enable_extension != NULL ) {
if ( viaScreen->irqEnabled ) {
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_swap_control" );
+ viaScreen->extensions[i++] = &driSwapControlExtension.base;
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- (*glx_enable_extension)( sPriv->psc, "GLX_MESA_swap_control" );
}
(*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;
return GL_TRUE;
}
/* Configuration cache with default values for all contexts */
driOptionCache optionCache;
+
+ const __DRIextension *extensions[2];
} viaScreenPrivate;