summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glx/dri2_glx.c8
-rw-r--r--src/glx/dri_common.c34
-rw-r--r--src/glx/dri_common.h2
-rw-r--r--src/glx/dri_glx.c124
-rw-r--r--src/glx/drisw_glx.c1
-rw-r--r--src/glx/glxclient.h10
-rw-r--r--src/glx/glxcmds.c113
7 files changed, 132 insertions, 160 deletions
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index e00dffeab1b..7d0a8603e05 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -522,7 +522,7 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
#ifdef X_DRI2SwapInterval
-static void
+static int
dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
{
struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
@@ -535,10 +535,10 @@ dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
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;
@@ -546,6 +546,8 @@ dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
DRI2SwapInterval(priv->base.psc->dpy, priv->base.xDrawable, interval);
priv->swap_interval = interval;
+
+ return 0;
}
static unsigned int
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 78636cd3101..907b05f6391 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -336,40 +336,6 @@ driConvertConfigs(const __DRIcoreExtension * core,
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,
diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h
index 9c07a0f6d40..7ed7767c92b 100644
--- a/src/glx/dri_common.h
+++ b/src/glx/dri_common.h
@@ -56,8 +56,6 @@ extern void ErrorMessageF(const char *f, ...);
extern void *driOpenDriver(const char *driverName);
-extern void driBindExtensions(__GLXscreenConfigs * psc,
- const __DRIextension **extensions);
extern void driBindCommonExtensions(__GLXscreenConfigs * psc,
const __DRIextension **extensions);
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index e14bc62e63b..42d5994b2e2 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -66,6 +66,9 @@ struct dri_screen
__GLXDRIscreen driScreen;
const __DRIlegacyExtension *legacy;
const __DRIcoreExtension *core;
+ const __DRIswapControlExtension *swapControl;
+ const __DRImediaStreamCounterExtension *msc;
+
void *driver;
int fd;
};
@@ -657,6 +660,116 @@ static const struct glx_context_vtable dri_context_vtable = {
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)
{
@@ -716,7 +829,7 @@ 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;
@@ -731,6 +844,15 @@ driCreateScreen(int screen, __GLXdisplayPrivate *priv)
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;
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 4ed13a3ac76..d403b235372 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -448,7 +448,6 @@ driCreateScreen(int screen, __GLXdisplayPrivate *priv)
}
extensions = psc->core->getExtensions(psc->base.__driScreen);
- driBindExtensions(&psc->base, extensions);
driBindCommonExtensions(&psc->base, extensions);
psc->base.configs =
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 22c98437135..b865e24b36e 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -151,7 +151,7 @@ struct __GLXDRIscreenRec {
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);
};
@@ -541,18 +541,10 @@ struct __GLXscreenConfigsRec
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
/**
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 5d022557bbf..4a7360c1497 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -2038,22 +2038,6 @@ __glXSwapIntervalSGI(int interval)
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
@@ -2097,25 +2081,9 @@ __glXSwapIntervalSGI(int interval)
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;
@@ -2123,8 +2091,7 @@ __glXSwapIntervalMESA(unsigned int interval)
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
@@ -2136,25 +2103,10 @@ __glXSwapIntervalMESA(unsigned int interval)
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;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
@@ -2302,16 +2254,6 @@ __glXGetVideoSyncSGI(unsigned int *count)
* 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);
@@ -2350,15 +2292,6 @@ __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
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,
@@ -2543,18 +2476,7 @@ __glXGetSyncValuesOML(Display * dpy, GLXDrawable drawable,
#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;
@@ -2703,12 +2625,6 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
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,
@@ -2741,18 +2657,6 @@ __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
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,
@@ -2782,17 +2686,6 @@ __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
*/
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) {