#ifdef X_DRI2SwapInterval
-static void
+static int
dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
{
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
switch (vblank_mode) {
case DRI_CONF_VBLANK_NEVER:
- return;
+ return GLX_BAD_VALUE;
case DRI_CONF_VBLANK_ALWAYS_SYNC:
if (interval <= 0)
- return;
+ return GLX_BAD_VALUE;
break;
default:
break;
DRI2SwapInterval(priv->base.psc->dpy, priv->base.xDrawable, interval);
priv->swap_interval = interval;
+
+ return 0;
}
static unsigned int
return head.next;
}
-/* Bind DRI1 specific extensions */
-_X_HIDDEN void
-driBindExtensions(__GLXscreenConfigs *psc, const __DRIextension **extensions)
-{
- int i;
-
- for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_SWAP_CONTROL
- /* No DRI2 support for swap_control at the moment, since SwapBuffers
- * is done by the X server */
- if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
- psc->swapControl = (__DRIswapControlExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
- __glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
- }
-#endif
-
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
- psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "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 */
- }
-}
-
/* Bind extensions common to DRI1 and DRI2 */
_X_HIDDEN void
driBindCommonExtensions(__GLXscreenConfigs *psc,
extern void *driOpenDriver(const char *driverName);
-extern void driBindExtensions(__GLXscreenConfigs * psc,
- const __DRIextension **extensions);
extern void driBindCommonExtensions(__GLXscreenConfigs * psc,
const __DRIextension **extensions);
__GLXDRIscreen driScreen;
const __DRIlegacyExtension *legacy;
const __DRIcoreExtension *core;
+ const __DRIswapControlExtension *swapControl;
+ const __DRImediaStreamCounterExtension *msc;
+
void *driver;
int fd;
};
NULL,
};
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+
+static int
+driDrawableGetMSC(__GLXscreenConfigs *base, __GLXDRIdrawable *pdraw,
+ int64_t *ust, int64_t *msc, int64_t *sbc)
+{
+ struct dri_screen *psc = (struct dri_screen *) base;
+
+ if (pdraw && psc->sbc && psc->msc)
+ return ( (*psc->msc->getMSC)(psc->driScreen, msc) == 0 &&
+ (*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0 &&
+ __glXGetUST(ust) == 0 );
+}
+
+static int
+driWaitForMSC(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
+ int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
+{
+ struct dri_screen *psc = (struct dri_screen *) pdraw->psc;
+
+ if (pdraw != NULL && psc->msc != NULL) {
+ ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, 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.
+ */
+ return ret == 0 && __glXGetUST(ust) == 0;
+ }
+}
+
+static int
+driWaitForSBC(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
+ int64_t *msc, int64_t *sbc)
+{
+ if (pdraw != NULL && psc->sbc != NULL) {
+ ret =
+ (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc);
+
+ /* __glXGetUST returns zero on success and non-zero on failure.
+ * This function returns True on success and False on failure.
+ */
+ return ((ret == 0) && (__glXGetUST(ust) == 0));
+ }
+
+ return DRI2WaitSBC(pdraw->psc->dpy, pdraw->xDrawable, target_sbc, ust, msc,
+ sbc);
+}
+
+#endif
+
+static int
+driSetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ struct dri_screen *psc;
+
+ if (gc->driContext) {
+ psc = (struct dri_screen *) pdraw->psc;
+
+ if (psc->swapControl != NULL && pdraw != NULL) {
+ psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
+ return 0;
+ }
+ }
+
+ return GLX_BAD_CONTEXT;
+}
+
+static int
+driGetSwapInterval(__GLXDRIdrawable *pdraw)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ struct dri_screen *psc;
+
+ if (gc != NULL && gc->driContext) {
+ psc = (struct dri_screen *) pdraw->psc;
+
+ if (psc->swapControl != NULL && pdraw != NULL) {
+ return psc->swapControl->getSwapInterval(pdraw->driDrawable);
+ }
+ }
+
+ return 0;
+}
+
+/* Bind DRI1 specific extensions */
+static void
+driBindExtensions(struct dri_screen *psc, const __DRIextension **extensions)
+{
+ int i;
+
+ for (i = 0; extensions[i]; i++) {
+ /* No DRI2 support for swap_control at the moment, since SwapBuffers
+ * is done by the X server */
+ if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
+ psc->swapControl = (__DRIswapControlExtension *) extensions[i];
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control");
+ __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control");
+ }
+
+ if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
+ psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
+ __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync");
+ }
+
+ /* Ignore unknown extensions */
+ }
+}
+
static __GLXscreenConfigs *
driCreateScreen(int screen, __GLXdisplayPrivate *priv)
{
}
extensions = psc->core->getExtensions(psc->base.__driScreen);
- driBindExtensions(&psc->base, extensions);
+ driBindExtensions(psc, extensions);
driBindCommonExtensions(&psc->base, extensions);
psp = &psc->driScreen;
psp->waitX = NULL;
psp->waitGL = NULL;
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+ psp->getDrawableMSC = driDrawableGetMSC;
+ psp->waitForMSC = driWaitForMSC;
+ psp->waitForSBC = driWaitForSBC;
+#endif
+
+ psp->setSwapInterval = driSetSwapInterval;
+ psp->getSwapInterval = driGetSwapInterval;
+
psc->base.direct_context_vtable = &dri_context_vtable;
return &psc->base;
}
extensions = psc->core->getExtensions(psc->base.__driScreen);
- driBindExtensions(&psc->base, extensions);
driBindCommonExtensions(&psc->base, extensions);
psc->base.configs =
int64_t *msc, int64_t *sbc);
int (*waitForSBC)(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc);
- void (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
+ int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval);
int (*getSwapInterval)(__GLXDRIdrawable *pdraw);
};
const __DRIcopySubBufferExtension *driCopySubBuffer;
#endif
-#ifdef __DRI_SWAP_CONTROL
- const __DRIswapControlExtension *swapControl;
-#endif
-
#ifdef __DRI_FRAME_TRACKING
const __DRIframeTrackingExtension *frameTracking;
#endif
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- const __DRImediaStreamCounterExtension *msc;
-#endif
-
#endif
/**
return GLX_BAD_VALUE;
}
-#ifdef __DRI_SWAP_CONTROL
- if (gc->driContext) {
- __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
- gc->screen );
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
- gc->currentDrawable,
- NULL);
- if (psc->swapControl != NULL && pdraw != NULL) {
- psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
- return 0;
- }
- else if (pdraw == NULL) {
- return GLX_BAD_CONTEXT;
- }
- }
-#endif
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
#ifdef GLX_DIRECT_RENDERING
static int
__glXSwapIntervalMESA(unsigned int interval)
{
+#ifdef GLX_DIRECT_RENDERING
GLXContext gc = __glXGetCurrentContext();
-#ifdef __DRI_SWAP_CONTROL
- if (gc != NULL && gc->driContext) {
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
- gc->screen);
-
- if ((psc != NULL) && (psc->driScreen != NULL)) {
- __GLXDRIdrawable *pdraw =
- GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
- if (psc->swapControl != NULL && pdraw != NULL) {
- psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
- return 0;
- }
- }
- }
-#endif
-
-#ifdef GLX_DIRECT_RENDERING
if (gc != NULL && gc->driContext) {
__GLXscreenConfigs *psc;
if (psc->driScreen && psc->driScreen->setSwapInterval) {
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
gc->currentDrawable, NULL);
- psc->driScreen->setSwapInterval(pdraw, interval);
- return 0;
+ return psc->driScreen->setSwapInterval(pdraw, interval);
}
}
#endif
static int
__glXGetSwapIntervalMESA(void)
{
-#ifdef __DRI_SWAP_CONTROL
+#ifdef GLX_DIRECT_RENDERING
GLXContext gc = __glXGetCurrentContext();
- if (gc != NULL && gc->driContext) {
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(gc->currentDpy,
- gc->screen);
-
- if ((psc != NULL) && (psc->driScreen != NULL)) {
- __GLXDRIdrawable *pdraw =
- GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
- if (psc->swapControl != NULL && pdraw != NULL) {
- return psc->swapControl->getSwapInterval(pdraw->driDrawable);
- }
- }
- }
-#endif
-
-#ifdef GLX_DIRECT_RENDERING
if (gc != NULL && gc->driContext) {
__GLXscreenConfigs *psc;
* FIXME: there should be a GLX encoding for this call. I can find no
* FIXME: documentation for the GLX encoding.
*/
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if ( psc->msc && psc->driScreen ) {
- ret = (*psc->msc->getDrawableMSC)(psc->__driScreen,
- pdraw->driDrawable, &msc);
- *count = (unsigned) msc;
-
- return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
- }
-#endif
-
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->getDrawableMSC) {
ret = psc->driScreen->getDrawableMSC(psc, pdraw, &ust, &msc, &sbc);
pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
#endif
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if (psc->msc != NULL && psc->driScreen ) {
- ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0,
- divisor, remainder, &msc, &sbc);
- *count = (unsigned) msc;
- return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
- }
-#endif
-
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->waitForMSC) {
ret = psc->driScreen->waitForMSC(pdraw, 0, divisor, remainder, &ust, &msc,
#ifdef GLX_DIRECT_RENDERING
pdraw = GetGLXDRIDrawable(dpy, drawable, &i);
-#endif
psc = priv->screenConfigs[i];
-
-#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER)
- if (pdraw && psc->sbc && psc->msc)
- return ( (pdraw && psc->sbc && psc->msc)
- && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0)
- && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0)
- && (__glXGetUST(ust) == 0) );
-#endif
-
-#ifdef GLX_DIRECT_RENDERING
if (pdraw && psc && psc->driScreen && psc->driScreen->getDrawableMSC) {
ret = psc->driScreen->getDrawableMSC(psc, pdraw, ust, msc, sbc);
return ret;
if (target_msc == 0 && divisor == 0 && remainder == 0)
remainder = 1;
-#ifdef __DRI_SWAP_BUFFER_COUNTER
- if (psc->counters != NULL)
- return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc,
- divisor, remainder);
-#endif
-
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen && psc->driScreen->swapBuffers)
return (*psc->driScreen->swapBuffers)(pdraw, target_msc, divisor,
if (divisor > 0 && remainder >= divisor)
return False;
-#ifdef __DRI_MEDIA_STREAM_COUNTER
- if (pdraw != NULL && psc->msc != NULL) {
- ret = (*psc->msc->waitForMSC) (pdraw->driDrawable, 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.
- */
- return ((ret == 0) && (__glXGetUST(ust) == 0));
- }
-#endif
-
#ifdef GLX_DIRECT_RENDERING
if (pdraw && psc->driScreen && psc->driScreen->waitForMSC) {
ret = psc->driScreen->waitForMSC(pdraw, target_msc, divisor, remainder,
*/
if (target_sbc < 0)
return False;
-#ifdef __DRI_SWAP_BUFFER_COUNTER
- if (pdraw != NULL && psc->sbc != NULL) {
- ret =
- (*psc->sbc->waitForSBC) (pdraw->driDrawable, target_sbc, msc, sbc);
-
- /* __glXGetUST returns zero on success and non-zero on failure.
- * This function returns True on success and False on failure.
- */
- return ((ret == 0) && (__glXGetUST(ust) == 0));
- }
-#endif
#ifdef GLX_DIRECT_RENDERING
if (pdraw && psc->driScreen && psc->driScreen->waitForSBC) {