glx: Move DRI2 extensions to DRI2 screen private
authorKristian Høgsberg <krh@bitplanet.net>
Mon, 19 Jul 2010 19:35:48 +0000 (15:35 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 20 Jul 2010 02:45:50 +0000 (22:45 -0400)
src/glx/dri2_glx.c
src/glx/dri_common.c
src/glx/dri_common.h
src/glx/glxclient.h

index b35663d5ede1a0adc90d380221284f31473bad1d..e00dffeab1b9afee28dc855a0d3ae8f7e2bac4cb 100644 (file)
@@ -81,6 +81,11 @@ struct dri2_screen {
    __GLXDRIscreen driScreen;
    const __DRIdri2Extension *dri2;
    const __DRIcoreExtension *core;
+
+   const __DRI2flushExtension *f;
+   const __DRI2configQueryExtension *config;
+   const __DRItexBufferExtension *texBuffer;
+
    void *driver;
    int fd;
 };
@@ -211,9 +216,9 @@ dri2CreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
    pdraw->swap_interval = 1; /* default may be overridden below */
    pdraw->have_back = 0;
 
-   if (psc->base.config)
-      psc->base.config->configQueryi(psc->base.__driScreen,
-                                    "vblank_mode", &vblank_mode);
+   if (psc->config)
+      psc->config->configQueryi(psc->base.__driScreen,
+                               "vblank_mode", &vblank_mode);
 
    switch (vblank_mode) {
    case DRI_CONF_VBLANK_NEVER:
@@ -298,6 +303,7 @@ static void
 dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height)
 {
    struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
+   struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
    XRectangle xrect;
    XserverRegion region;
 
@@ -311,21 +317,21 @@ dri2CopySubBuffer(__GLXDRIdrawable *pdraw, int x, int y, int width, int height)
    xrect.height = height;
 
 #ifdef __DRI2_FLUSH
-   if (pdraw->psc->f)
-      (*pdraw->psc->f->flush) (pdraw->driDrawable);
+   if (psc->f)
+      (*psc->f->flush) (pdraw->driDrawable);
 #endif
 
-   region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
-   DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region,
+   region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
+   DRI2CopyRegion(psc->base.dpy, pdraw->xDrawable, region,
                   DRI2BufferFrontLeft, DRI2BufferBackLeft);
-   XFixesDestroyRegion(pdraw->psc->dpy, region);
+   XFixesDestroyRegion(psc->base.dpy, region);
 
    /* Refresh the fake front (if present) after we just damaged the real
     * front.
     */
-   DRI2CopyRegion(pdraw->psc->dpy, pdraw->xDrawable, region,
+   DRI2CopyRegion(psc->base.dpy, pdraw->xDrawable, region,
                  DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
-   XFixesDestroyRegion(pdraw->psc->dpy, region);
+   XFixesDestroyRegion(psc->base.dpy, region);
 }
 
 static void
@@ -333,7 +339,7 @@ dri2_copy_drawable(struct dri2_drawable *priv, int dest, int src)
 {
    XRectangle xrect;
    XserverRegion region;
-   __GLXscreenConfigs *const psc = priv->base.psc;
+   struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
 
    xrect.x = 0;
    xrect.y = 0;
@@ -345,9 +351,9 @@ dri2_copy_drawable(struct dri2_drawable *priv, int dest, int src)
       (*psc->f->flush) (priv->base.driDrawable);
 #endif
 
-   region = XFixesCreateRegion(psc->dpy, &xrect, 1);
-   DRI2CopyRegion(psc->dpy, priv->base.xDrawable, region, dest, src);
-   XFixesDestroyRegion(psc->dpy, region);
+   region = XFixesCreateRegion(psc->base.dpy, &xrect, 1);
+   DRI2CopyRegion(psc->base.dpy, priv->base.xDrawable, region, dest, src);
+   XFixesDestroyRegion(psc->base.dpy, region);
 
 }
 
@@ -438,13 +444,14 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
 {
     struct dri2_drawable *priv = (struct dri2_drawable *) pdraw;
     __GLXdisplayPrivate *dpyPriv = __glXInitialize(priv->base.psc->dpy);
+    struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
     struct dri2_display *pdp =
        (struct dri2_display *)dpyPriv->dri2Display;
     int64_t ret;
 
 #ifdef __DRI2_FLUSH
-    if (pdraw->psc->f)
-       (*pdraw->psc->f->flush)(pdraw->driDrawable);
+    if (psc->f)
+       (*psc->f->flush)(pdraw->driDrawable);
 #endif
 
     /* Old servers don't send invalidate events */
@@ -458,7 +465,7 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
     }
 
 #ifdef X_DRI2SwapBuffers
-    DRI2SwapBuffers(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor,
+    DRI2SwapBuffers(psc->base.dpy, pdraw->xDrawable, target_msc, divisor,
                    remainder, &ret);
 #endif
 
@@ -518,12 +525,13 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable,
 static void
 dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
 {
-   __GLXscreenConfigs *psc = pdraw->psc;
    struct dri2_drawable *priv =  (struct dri2_drawable *) pdraw;
    GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
+   struct dri2_screen *psc = (struct dri2_screen *) priv->base.psc;
 
    if (psc->config)
-      psc->config->configQueryi(psc->__driScreen, "vblank_mode", &vblank_mode);
+      psc->config->configQueryi(psc->base.__driScreen,
+                               "vblank_mode", &vblank_mode);
 
    switch (vblank_mode) {
    case DRI_CONF_VBLANK_NEVER:
@@ -536,7 +544,7 @@ dri2SetSwapInterval(__GLXDRIdrawable *pdraw, int interval)
       break;
    }
 
-   DRI2SwapInterval(priv->base.psc->dpy, pdraw->xDrawable, interval);
+   DRI2SwapInterval(priv->base.psc->dpy, priv->base.xDrawable, interval);
    priv->swap_interval = interval;
 }
 
@@ -575,10 +583,11 @@ dri2InvalidateBuffers(Display *dpy, XID drawable)
 {
    __GLXDRIdrawable *pdraw =
       dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
+   struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
 
 #if __DRI2_FLUSH_VERSION >= 3
-   if (pdraw && pdraw->psc->f)
-       pdraw->psc->f->invalidate(pdraw->driDrawable);
+   if (pdraw && psc->f)
+       psc->f->invalidate(pdraw->driDrawable);
 #endif
 }
 
@@ -592,25 +601,26 @@ dri2_bind_tex_image(Display * dpy,
     __GLXdisplayPrivate *dpyPriv = __glXInitialize(dpy);
     struct dri2_display *pdp =
        (struct dri2_display *) dpyPriv->dri2Display;
+   struct dri2_screen *psc = (struct dri2_screen *) pdraw->psc;
 
    if (pdraw != NULL) {
 
 #if __DRI2_FLUSH_VERSION >= 3
-      if (!pdp->invalidateAvailable && pdraw->psc->f)
-        pdraw->psc->f->invalidate(pdraw->driDrawable);
+      if (!pdp->invalidateAvailable && psc->f)
+        psc->f->invalidate(pdraw->driDrawable);
 #endif
 
-      if (pdraw->psc->texBuffer->base.version >= 2 &&
-         pdraw->psc->texBuffer->setTexBuffer2 != NULL) {
-        (*pdraw->psc->texBuffer->setTexBuffer2) (gc->__driContext,
-                                                 pdraw->textureTarget,
-                                                 pdraw->textureFormat,
-                                                 pdraw->driDrawable);
+      if (psc->texBuffer->base.version >= 2 &&
+         psc->texBuffer->setTexBuffer2 != NULL) {
+        (*psc->texBuffer->setTexBuffer2) (gc->__driContext,
+                                          pdraw->textureTarget,
+                                          pdraw->textureFormat,
+                                          pdraw->driDrawable);
       }
       else {
-        (*pdraw->psc->texBuffer->setTexBuffer) (gc->__driContext,
-                                                pdraw->textureTarget,
-                                                pdraw->driDrawable);
+        (*psc->texBuffer->setTexBuffer) (gc->__driContext,
+                                         pdraw->textureTarget,
+                                         pdraw->driDrawable);
       }
    }
 }
@@ -625,6 +635,35 @@ static const struct glx_context_vtable dri2_context_vtable = {
    dri2_release_tex_image,
 };
 
+static void
+dri2BindExtensions(struct dri2_screen *psc, const __DRIextension **extensions)
+{
+   int i;
+
+   __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync");
+   __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control");
+   __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control");
+
+   /* FIXME: if DRI2 version supports it... */
+   __glXEnableDirectExtension(&psc->base, "INTEL_swap_event");
+
+   for (i = 0; extensions[i]; i++) {
+      if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
+        psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
+        __glXEnableDirectExtension(&psc->base, "GLX_EXT_texture_from_pixmap");
+      }
+
+      if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) {
+        psc->f = (__DRI2flushExtension *) extensions[i];
+        /* internal driver extension, no GL extension exposed */
+      }
+
+      if ((strcmp(extensions[i]->name, __DRI2_CONFIG_QUERY) == 0))
+        psc->config = (__DRI2configQueryExtension *) extensions[i];
+   }
+}
+
+
 static __GLXscreenConfigs *
 dri2CreateScreen(int screen, __GLXdisplayPrivate * priv)
 {
@@ -709,7 +748,7 @@ dri2CreateScreen(int screen, __GLXdisplayPrivate * priv)
 
    extensions = psc->core->getExtensions(psc->base.__driScreen);
    driBindCommonExtensions(&psc->base, extensions);
-   dri2BindExtensions(&psc->base, extensions);
+   dri2BindExtensions(psc, extensions);
 
    psc->base.configs =
       driConvertConfigs(psc->core, psc->base.configs, driver_configs);
index 70ff8f1c0333faef3129fe050fa4d353a5fe765b..78636cd3101eb03dd7a395edb35a5b03584c2d7b 100644 (file)
@@ -370,42 +370,6 @@ driBindExtensions(__GLXscreenConfigs *psc, const __DRIextension **extensions)
    }
 }
 
-/* Bind DRI2 specific extensions */
-_X_HIDDEN void
-dri2BindExtensions(__GLXscreenConfigs *psc,
-                  const __DRIextension **extensions)
-{
-   int i;
-
-   for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_TEX_BUFFER
-      if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0)) {
-        psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
-        __glXEnableDirectExtension(psc, "GLX_EXT_texture_from_pixmap");
-      }
-#endif
-
-      __glXEnableDirectExtension(psc, "GLX_SGI_video_sync");
-      __glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
-      __glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
-
-      /* FIXME: if DRI2 version supports it... */
-      __glXEnableDirectExtension(psc, "INTEL_swap_event");
-
-#ifdef __DRI2_FLUSH
-      if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0)) {
-        psc->f = (__DRI2flushExtension *) extensions[i];
-        /* 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
-   }
-}
-
 /* Bind extensions common to DRI1 and DRI2 */
 _X_HIDDEN void
 driBindCommonExtensions(__GLXscreenConfigs *psc,
index 7cd9ac2dac0faf490f2559eafce1bed21581900b..9c07a0f6d40d30c58f0c654a99ec81f7dce706b9 100644 (file)
@@ -58,8 +58,6 @@ extern void *driOpenDriver(const char *driverName);
 
 extern void driBindExtensions(__GLXscreenConfigs * psc,
                              const __DRIextension **extensions);
-extern void dri2BindExtensions(__GLXscreenConfigs * psc,
-                              const __DRIextension **extensions);
 extern void driBindCommonExtensions(__GLXscreenConfigs * psc,
                                    const __DRIextension **extensions);
 
index 090d7ee6074a62fc6722e7604f4aec7909e7891b..22c98437135716e74349d3cfca8ac064119702a4 100644 (file)
@@ -553,18 +553,6 @@ struct __GLXscreenConfigsRec
    const __DRImediaStreamCounterExtension *msc;
 #endif
 
-#ifdef __DRI_TEX_BUFFER
-   const __DRItexBufferExtension *texBuffer;
-#endif
-
-#ifdef __DRI2_FLUSH
-   const __DRI2flushExtension *f;
-#endif
-
-#ifdef __DRI2_CONFIG_QUERY
-   const __DRI2configQueryExtension *config;
-#endif
-
 #endif
 
     /**