typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
typedef struct __DRIallocateExtensionRec __DRIallocateExtension;
typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
+typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
/*@}*/
float * lastMissedUsage, float * usage);
};
+
+/**
+ * Used by drivers that implement the GLX_SGI_video_sync extension.
+ */
+#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
+struct __DRImediaStreamCounterExtensionRec {
+ __DRIextension base;
+
+ /**
+ * Get the number of vertical refreshes since some point in time before
+ * this function was first called (i.e., system start up).
+ */
+ int (*getMSC)(__DRIscreen *screen, int64_t *msc);
+
+ /**
+ * Wait for the MSC to equal target_msc, or, if that has already passed,
+ * the next time (MSC % divisor) is equal to remainder. If divisor is
+ * zero, the function will return as soon as MSC is greater than or equal
+ * to target_msc.
+ */
+ int (*waitForMSC)(__DRIdrawable *drawable,
+ int64_t target_msc, int64_t divisor, int64_t remainder,
+ int64_t * msc, int64_t * sbc);
+};
+
+
/**
* \name Functions provided by the driver loader.
*/
*/
void *private;
- /**
- * Get the number of vertical refreshes since some point in time before
- * this function was first called (i.e., system start up).
- *
- * \since Internal API version 20030317.
- */
- int (*getMSC)(__DRIscreen *screen, int64_t *msc);
-
/**
* Method to create the private DRI context data and initialize the
* context dependent methods.
* screen used to create this drawable. Never dereferenced in libGL.
*/
void *private;
-
- /**
- * Get the number of completed swap buffers for this drawable.
- *
- * \since Internal API version 20030317.
- */
- int (*getSBC)(__DRIdrawable *drawable, int64_t *sbc);
-
- /**
- * Wait for the SBC to be greater than or equal target_sbc.
- *
- * \since Internal API version 20030317.
- */
- int (*waitForSBC)(__DRIdrawable *drawable,
- int64_t target_sbc,
- int64_t * msc, int64_t * sbc);
-
- /**
- * Wait for the MSC to equal target_msc, or, if that has already passed,
- * the next time (MSC % divisor) is equal to remainder. If divisor is
- * zero, the function will return as soon as MSC is greater than or equal
- * to target_msc.
- *
- * \since Internal API version 20030317.
- */
- int (*waitForMSC)(__DRIdrawable *drawable,
- int64_t target_msc, int64_t divisor, int64_t remainder,
- int64_t * msc, int64_t * sbc);
-
- /**
- * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once
- * rendering is complete, waits until MSC is equal to target_msc, or
- * if that has already passed, waits until (MSC % divisor) is equal
- * to remainder. If divisor is zero, the swap will happen as soon as
- * MSC is greater than or equal to target_msc.
- *
- * \since Internal API version 20030317.
- */
- int64_t (*swapBuffersMSC)(__DRIdrawable *drawable,
- int64_t target_msc,
- int64_t divisor, int64_t remainder);
};
#endif
__DRIframeTrackingExtension *frameTracking;
#endif
+#ifdef __DRI_MEDIA_STREAM_COUNTER
+ __DRImediaStreamCounterExtension *msc;
+#endif
+
#endif
/**
* FIXME: there should be a GLX encoding for this call. I can find no
* FIXME: documentation for the GLX encoding.
*/
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_MEDIA_STREAM_COUNTER
GLXContext gc = __glXGetCurrentContext();
if ( (gc != NULL) && gc->isDirect ) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
- if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit )
- && psc->driScreen.private && psc->driScreen.getMSC) {
+ if (psc->msc != NULL && psc->driScreen.private != NULL) {
int ret;
int64_t temp;
- ret = psc->driScreen.getMSC(&psc->driScreen, &temp);
+ ret = psc->msc->getMSC(&psc->driScreen, &temp);
*count = (unsigned) temp;
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
}
static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
{
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_MEDIA_STREAM_COUNTER
GLXContext gc = __glXGetCurrentContext();
if ( divisor <= 0 || remainder < 0 )
if ( (gc != NULL) && gc->isDirect ) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
- if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit )
- && psc->driScreen.private ) {
+ if (psc->msc != NULL && psc->driScreen.private ) {
__DRIdrawable * const pdraw =
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
- if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) ) {
+ if (pdraw != NULL) {
int ret;
int64_t msc;
int64_t sbc;
- ret = (*pdraw->waitForMSC)(pdraw, 0,
- divisor, remainder, &msc, &sbc);
+ ret = (*psc->msc->waitForMSC)(pdraw, 0,
+ divisor, remainder, &msc, &sbc);
*count = (unsigned) msc;
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
}
static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
int64_t *ust, int64_t *msc, int64_t *sbc)
{
-#ifdef GLX_DIRECT_RENDERING
+#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER)
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
if ( priv != NULL ) {
__GLXscreenConfigs * const psc = &priv->screenConfigs[i];
assert( (pdraw == NULL) || (i != -1) );
- return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC)
- && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )
- && ((*psc->driScreen.getMSC)(&psc->driScreen, msc) == 0)
- && ((*pdraw->getSBC)(pdraw, sbc ) == 0)
- && (__glXGetUST( ust ) == 0) );
+ return ( (pdraw && psc->sbc && psc->msc)
+ && ((*psc->msc->getMSC)(&psc->driScreen, msc) == 0)
+ && ((*psc->sbc->getSBC)(pdraw, sbc) == 0)
+ && (__glXGetUST(ust) == 0) );
}
#else
(void) dpy;
int64_t target_msc, int64_t divisor,
int64_t remainder)
{
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_BUFFER_COUNTER
int screen;
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
if ( divisor > 0 && remainder >= divisor )
return -1;
- if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL)
- && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {
- return (*pdraw->swapBuffersMSC)(pdraw, target_msc, divisor, remainder);
- }
+ if (pdraw != NULL && psc->counters != NULL)
+ return (*psc->sbc->swapBuffersMSC)(pdraw, target_msc,
+ divisor, remainder);
+
#else
(void) dpy;
(void) drawable;
int64_t remainder, int64_t *ust,
int64_t *msc, int64_t *sbc)
{
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_MEDIA_STREAM_COUNTER
int screen;
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
if ( divisor > 0 && remainder >= divisor )
return False;
- if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL)
- && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {
- ret = (*pdraw->waitForMSC)(pdraw, target_msc,
- divisor, remainder, msc, sbc);
+ if (pdraw != NULL && psc->msc != NULL) {
+ ret = (*psc->msc->waitForMSC)(pdraw, target_msc,
+ divisor, remainder, msc, sbc);
/* __glXGetUST returns zero on success and non-zero on failure.
* This function returns True on success and False on failure.
int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc )
{
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_BUFFER_COUNTER
int screen;
__DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
if ( target_sbc < 0 )
return False;
- if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL)
- && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) {
- ret = (*pdraw->waitForSBC)(pdraw, target_sbc, msc, sbc);
+ if (pdraw != NULL && psc->sbc != NULL) {
+ ret = (*psc->sbc->waitForSBC)(pdraw, target_sbc, msc, sbc);
/* __glXGetUST returns zero on success and non-zero on failure.
* This function returns True on success and False on failure.
if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) {
psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i];
__glXScrEnableExtension(&psc->driScreen,
- "GLX_MESA_swap_frame_usage");
+ "GLX_MESA_swap_frame_usage");
}
#endif
+#ifdef __DRI_MEDIA_STREAM_COUNTER
+ if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
+ psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
+ __glXScrEnableExtension(&psc->driScreen,
+ "GLX_SGI_video_sync");
+ }
+#endif
+
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+ /* No driver supports this at this time and the extension is
+ * not defined in dri_interface.h. Will enable
+ * GLX_OML_sync_control if implemented. */
+#endif
/* Ignore unknown extensions */
}
}
return sPriv->DriverAPI.GetMSC( sPriv, msc );
}
-/**
- * Called directly from a number of higher-level GLX functions.
- */
-static int driGetSBC(__DRIdrawable *drawable, int64_t *sbc)
-{
- __DRIdrawablePrivate *dPriv = drawable->private;
- __DRIswapInfo sInfo;
- int status;
-
-
- status = dPriv->driScreenPriv->DriverAPI.GetSwapInfo( dPriv, & sInfo );
- *sbc = sInfo.swap_count;
-
- return status;
-}
-
-static int driWaitForSBC(__DRIdrawable *drawable, int64_t target_sbc,
- int64_t * msc, int64_t * sbc)
-{
- __DRIdrawablePrivate *dPriv = drawable->private;
-
- return dPriv->driScreenPriv->DriverAPI.WaitForSBC( dPriv, target_sbc,
- msc, sbc );
-}
-
static int driWaitForMSC(__DRIdrawable *drawable, int64_t target_msc,
int64_t divisor, int64_t remainder,
int64_t * msc, int64_t * sbc)
return status;
}
-static int64_t driSwapBuffersMSC(__DRIdrawable *drawable, int64_t target_msc,
- int64_t divisor, int64_t remainder)
-{
- __DRIdrawablePrivate *dPriv = drawable->private;
-
- return dPriv->driScreenPriv->DriverAPI.SwapBuffersMSC( dPriv, target_msc,
- divisor,
- remainder );
-}
+const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = {
+ { __DRI_MEDIA_STREAM_COUNTER },
+ driGetMSC,
+ driWaitForMSC,
+};
static void driCopySubBuffer(__DRIdrawable *drawable,
int x, int y, int w, int h)
pdraw->destroyDrawable = driDestroyDrawable;
pdraw->swapBuffers = driSwapBuffers; /* called by glXSwapBuffers() */
- pdraw->getSBC = driGetSBC;
- pdraw->waitForSBC = driWaitForSBC;
- pdraw->waitForMSC = driWaitForMSC;
- pdraw->swapBuffersMSC = driSwapBuffersMSC;
-
/* This special default value is replaced with the configured
* default value when the drawable is first bound to a direct
* rendering context.
psc->destroyScreen = driDestroyScreen;
psc->getExtensions = driGetExtensions;
psc->createNewDrawable = driCreateNewDrawable;
- psc->getMSC = driGetMSC;
psc->createNewContext = driCreateNewContext;
if (internal_api_version >= 20070121)
extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
extern const __DRIswapControlExtension driSwapControlExtension;
extern const __DRIframeTrackingExtension driFrameTrackingExtension;
+extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;
/**
* Used by DRI_VALIDATE_DRAWABLE_INFO
&driSwapControlExtension.base,
&intelAllocateExtension.base,
&driFrameTrackingExtension.base,
+ &driMediaStreamCounterExtension.base,
NULL
};
sPriv->extensions = intelExtensions;
if (glx_enable_extension != NULL) {
- (*glx_enable_extension) (sPriv->psc, "GLX_SGI_video_sync");
(*glx_enable_extension) (sPriv->psc, "GLX_SGI_make_current_read");
}
&driCopySubBufferExtension.base,
&driSwapControlExtension.base,
&driFrameTrackingExtension.base,
+ &driMediaStreamCounterExtension.base,
NULL
};
sPriv->extensions = intelExtensions;
- if (glx_enable_extension != NULL) {
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
+ if (glx_enable_extension != NULL)
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
- }
return GL_TRUE;
}
{
mach64ScreenPtr mach64Screen;
ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv;
- PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
- (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
int i;
if (sPriv->devPrivSize != sizeof(ATIDRIRec)) {
i = 0;
mach64Screen->extensions[i++] = &driFrameTrackingExtension.base;
- if ( glx_enable_extension != NULL ) {
- if ( mach64Screen->irq != 0 ) {
- mach64Screen->extensions[i++] = &driSwapControlExtension.base;
-
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- }
+ if ( mach64Screen->irq != 0 ) {
+ mach64Screen->extensions[i++] = &driSwapControlExtension.base;
+ mach64Screen->extensions[i++] = &driMediaStreamCounterExtension.base;
}
mach64Screen->extensions[i++] = NULL;
sPriv->extensions = mach64Screen->extensions;
driOptionCache optionCache;
- const __DRIextension *extensions[3];
+ const __DRIextension *extensions[4];
} mach64ScreenRec, *mach64ScreenPtr;
#endif /* __MACH64_SCREEN_H__ */
static const __DRIextension *mgaExtensions[] = {
&driSwapControlExtension.base,
&driFrameTrackingExtension.base,
+ &driMediaStreamCounterExtension.base,
NULL
};
sPriv->extensions = mgaExtensions;
- if ( glx_enable_extension != NULL ) {
+ if ( glx_enable_extension != NULL )
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- }
if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
serverInfo->chipset != MGA_CARD_TYPE_G400) {
{
r128ScreenPtr r128Screen;
R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
- PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
- (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
int i;
if (sPriv->devPrivSize != sizeof(R128DRIRec)) {
i = 0;
r128Screen->extensions[i++] = &driFrameTrackingExtension.base;
- if ( glx_enable_extension != NULL ) {
- if ( r128Screen->irq != 0 ) {
- r128Screen->extensions[i++] = &driSwapControlExtension.base;
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- }
+ if ( r128Screen->irq != 0 ) {
+ r128Screen->extensions[i++] = &driSwapControlExtension.base;
+ r128Screen->extensions[i++] = &driMediaStreamCounterExtension.base;
}
r128Screen->extensions[i++] = NULL;
sPriv->extensions = r128Screen->extensions;
/* Configuration cache with default values for all contexts */
driOptionCache optionCache;
- const __DRIextension *extensions[3];
+ const __DRIextension *extensions[4];
} r128ScreenRec, *r128ScreenPtr;
i = 0;
screen->extensions[i++] = &driCopySubBufferExtension.base;
screen->extensions[i++] = &driFrameTrackingExtension.base;
-
- if ( glx_enable_extension != NULL ) {
- if ( screen->irq != 0 ) {
- screen->extensions[i++] = &driSwapControlExtension.base;
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- }
-
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
+ if ( screen->irq != 0 ) {
+ screen->extensions[i++] = &driSwapControlExtension.base;
+ screen->extensions[i++] = &driMediaStreamCounterExtension.base;
}
+ if ( glx_enable_extension != NULL )
+ (*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
#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[5];
+ const __DRIextension *extensions[6];
} radeonScreenRec, *radeonScreenPtr;
#define IS_R100_CLASS(screen) \
i = 0;
viaScreen->extensions[i++] = &driFrameTrackingExtension.base;
- if ( glx_enable_extension != NULL ) {
- if ( viaScreen->irqEnabled ) {
- viaScreen->extensions[i++] = &driSwapControlExtension.base;
- (*glx_enable_extension)( sPriv->psc, "GLX_SGI_video_sync" );
- }
+ if ( viaScreen->irqEnabled ) {
+ viaScreen->extensions[i++] = &driSwapControlExtension.base;
+ viaScreen->extensions[i++] = &driMediaStreamCounterExtension.base;
+ }
+ if ( glx_enable_extension != NULL )
(*glx_enable_extension)( sPriv->psc, "GLX_SGI_make_current_read" );
- }
+
viaScreen->extensions[i++] = NULL;
sPriv->extensions = viaScreen->extensions;
/* Configuration cache with default values for all contexts */
driOptionCache optionCache;
- const __DRIextension *extensions[3];
+ const __DRIextension *extensions[4];
} viaScreenPrivate;