[PATCH xserver 11/13] glx: Move glx_enable_bits up to the GLX screen base class

Adam Jackson ajax at redhat.com
Wed Mar 23 22:46:53 UTC 2016


Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 glx/glxdri2.c            | 25 ++++++++++++-------------
 glx/glxdriswrast.c       | 19 ++++++++++---------
 glx/glxscreens.h         |  3 +++
 hw/xquartz/GL/indirect.c | 13 +++++--------
 hw/xwin/glx/indirect.c   | 15 ++++++---------
 5 files changed, 36 insertions(+), 39 deletions(-)

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index ad97eb5..fa93da1 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -75,8 +75,6 @@ struct __GLXDRIscreen {
     const __DRIswapControlExtension *swapControl;
     const __DRItexBufferExtension *texBuffer;
     const __DRIconfig **driConfigs;
-
-    unsigned char glx_enable_bits[__GLX_EXT_BYTES];
 };
 
 struct __GLXDRIcontext {
@@ -847,18 +845,19 @@ glxDRILeaveVT(ScrnInfoPtr scrn)
  * @param screen The screen where glx_enable_bits are to be set.
  */
 static void
-initializeExtensions(__GLXDRIscreen * screen)
+initializeExtensions(__GLXscreen * screen)
 {
-    ScreenPtr pScreen = screen->base.pScreen;
+    ScreenPtr pScreen = screen->pScreen;
+    __GLXDRIscreen *dri = (__GLXDRIscreen *)screen;
     const __DRIextension **extensions;
     int i;
 
-    extensions = screen->core->getExtensions(screen->driScreen);
+    extensions = dri->core->getExtensions(dri->driScreen);
 
     __glXEnableExtension(screen->glx_enable_bits, "GLX_MESA_copy_sub_buffer");
     LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
 
-    if (screen->dri2->base.version >= 3) {
+    if (dri->dri2->base.version >= 3) {
         __glXEnableExtension(screen->glx_enable_bits,
                              "GLX_ARB_create_context");
         __glXEnableExtension(screen->glx_enable_bits,
@@ -901,7 +900,7 @@ initializeExtensions(__GLXDRIscreen * screen)
 
     for (i = 0; extensions[i]; i++) {
         if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
-            screen->texBuffer = (const __DRItexBufferExtension *) extensions[i];
+            dri->texBuffer = (const __DRItexBufferExtension *) extensions[i];
             __glXEnableExtension(screen->glx_enable_bits,
                                  "GLX_EXT_texture_from_pixmap");
             LogMessage(X_INFO,
@@ -910,11 +909,11 @@ initializeExtensions(__GLXDRIscreen * screen)
 
         if (strcmp(extensions[i]->name, __DRI2_FLUSH) == 0 &&
             extensions[i]->version >= 3) {
-            screen->flush = (__DRI2flushExtension *) extensions[i];
+            dri->flush = (__DRI2flushExtension *) extensions[i];
         }
 
         if (strcmp(extensions[i]->name, __DRI2_ROBUSTNESS) == 0 &&
-            screen->dri2->base.version >= 3) {
+            dri->dri2->base.version >= 3) {
             __glXEnableExtension(screen->glx_enable_bits,
                                  "GLX_ARB_create_context_robustness");
             LogMessage(X_INFO,
@@ -960,7 +959,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     screen->base.swapInterval = __glXDRIdrawableSwapInterval;
     screen->base.pScreen = pScreen;
 
-    __glXInitExtensionEnableBits(screen->glx_enable_bits);
+    __glXInitExtensionEnableBits(screen->base.glx_enable_bits);
 
     screen->driver =
         glxProbeDriver(driverName, (void **) &screen->core, __DRI_CORE, 1,
@@ -980,7 +979,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
         goto handle_error;
     }
 
-    initializeExtensions(screen);
+    initializeExtensions(&screen->base);
 
     screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs,
                                                GLX_WINDOW_BIT |
@@ -993,10 +992,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
      * This allows us to allocate some memory to hold the extension string,
      * but it requires that we call __glXGetExtensionString a second time.
      */
-    buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
+    buffer_size = __glXGetExtensionString(screen->base.glx_enable_bits, NULL);
     if (buffer_size > 0) {
         screen->base.GLXextensions = xnfalloc(buffer_size);
-        (void) __glXGetExtensionString(screen->glx_enable_bits,
+        (void) __glXGetExtensionString(screen->base.glx_enable_bits,
                                        screen->base.GLXextensions);
     }
 
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index 65abdff..27c98ed 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -391,15 +391,16 @@ static const __DRIextension *loader_extensions[] = {
 };
 
 static void
-initializeExtensions(__GLXDRIscreen * screen)
+initializeExtensions(__GLXscreen * screen)
 {
     const __DRIextension **extensions;
+    __GLXDRIscreen *dri = (__GLXDRIscreen *)screen;
     int i;
 
     __glXEnableExtension(screen->glx_enable_bits, "GLX_MESA_copy_sub_buffer");
     LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
 
-    if (screen->swrast->base.version >= 3) {
+    if (dri->swrast->base.version >= 3) {
         __glXEnableExtension(screen->glx_enable_bits,
                              "GLX_ARB_create_context");
         __glXEnableExtension(screen->glx_enable_bits,
@@ -415,16 +416,16 @@ initializeExtensions(__GLXDRIscreen * screen)
     __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_fbconfig_float");
     __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_fbconfig_packed_float");
 
-    extensions = screen->core->getExtensions(screen->driScreen);
+    extensions = dri->core->getExtensions(dri->driScreen);
 
     for (i = 0; extensions[i]; i++) {
         if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
-            screen->copySubBuffer =
+            dri->copySubBuffer =
                 (const __DRIcopySubBufferExtension *) extensions[i];
         }
 
         if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
-            screen->texBuffer = (const __DRItexBufferExtension *) extensions[i];
+            dri->texBuffer = (const __DRItexBufferExtension *) extensions[i];
             __glXEnableExtension(screen->glx_enable_bits,
                                  "GLX_EXT_texture_from_pixmap\n");
         }
@@ -459,7 +460,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     screen->base.swapInterval = NULL;
     screen->base.pScreen = pScreen;
 
-    __glXInitExtensionEnableBits(screen->glx_enable_bits);
+    __glXInitExtensionEnableBits(screen->base.glx_enable_bits);
 
     screen->driver = glxProbeDriver(driverName,
                                     (void **) &screen->core,
@@ -480,7 +481,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
         goto handle_error;
     }
 
-    initializeExtensions(screen);
+    initializeExtensions(&screen->base);
 
     screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs,
                                                GLX_WINDOW_BIT |
@@ -493,10 +494,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
      * This allows us to allocate some memory to hold the extension string,
      * but it requires that we call __glXGetExtensionString a second time.
      */
-    buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
+    buffer_size = __glXGetExtensionString(screen->base.glx_enable_bits, NULL);
     if (buffer_size > 0) {
         screen->base.GLXextensions = xnfalloc(buffer_size);
-        (void) __glXGetExtensionString(screen->glx_enable_bits,
+        (void) __glXGetExtensionString(screen->base.glx_enable_bits,
                                        screen->base.GLXextensions);
     }
 
diff --git a/glx/glxscreens.h b/glx/glxscreens.h
index 0fe85e6..c63fb56 100644
--- a/glx/glxscreens.h
+++ b/glx/glxscreens.h
@@ -35,6 +35,8 @@
  * Silicon Graphics, Inc.
  */
 
+#include "extension_string.h"
+
 typedef struct __GLXconfig __GLXconfig;
 struct __GLXconfig {
     __GLXconfig *next;
@@ -141,6 +143,7 @@ struct __GLXscreen {
 
     char *GLextensions;
     char *GLXextensions;
+    unsigned char glx_enable_bits[__GLX_EXT_BYTES];
 
     Bool (*CloseScreen) (ScreenPtr pScreen);
 };
diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index f857325..9eaeb94 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -112,9 +112,6 @@ typedef struct __GLXAquaDrawable __GLXAquaDrawable;
  */
 struct __GLXAquaScreen {
     __GLXscreen base;
-
-    /* Supported GLX extensions */
-    unsigned char glx_enable_bits[__GLX_EXT_BYTES];
 };
 
 struct __GLXAquaContext {
@@ -542,19 +539,19 @@ __glXAquaScreenProbe(ScreenPtr pScreen)
     screen->base.fbconfigs = __glXAquaCreateVisualConfigs(
         &screen->base.numFBConfigs, pScreen->myNum);
 
-    __glXInitExtensionEnableBits(screen->glx_enable_bits);
+    __glXInitExtensionEnableBits(screen->base.glx_enable_bits);
     __glXScreenInit(&screen->base, pScreen);
 
-    //__glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_create_context");
-    //__glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_create_context_profile");
+    //__glXEnableExtension(screen->base.glx_enable_bits, "GLX_ARB_create_context");
+    //__glXEnableExtension(screen->base.glx_enable_bits, "GLX_ARB_create_context_profile");
 
     // Generate the GLX extensions string (overrides that set by __glXScreenInit())
     {
         unsigned int buffer_size =
-            __glXGetExtensionString(screen->glx_enable_bits, NULL);
+            __glXGetExtensionString(screen->base.glx_enable_bits, NULL);
         if (buffer_size > 0) {
             screen->base.GLXextensions = xnfalloc(buffer_size);
-            __glXGetExtensionString(screen->glx_enable_bits,
+            __glXGetExtensionString(screen->base.glx_enable_bits,
                                     screen->base.GLXextensions);
         }
     }
diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 76ed51b..5e491c5 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -136,9 +136,6 @@ struct __GLXWinDrawable {
 struct __GLXWinScreen {
     __GLXscreen base;
 
-    /* Supported GLX extensions */
-    unsigned char glx_enable_bits[__GLX_EXT_BYTES];
-
     Bool has_WGL_ARB_multisample;
     Bool has_WGL_ARB_pixel_format;
     Bool has_WGL_ARB_pbuffer;
@@ -632,19 +629,19 @@ glxWinScreenProbe(ScreenPtr pScreen)
         // Based on the WGL extensions available, enable various GLX extensions
         // XXX: make this table-driven ?
         //
-        __glXInitExtensionEnableBits(screen->glx_enable_bits);
+        __glXInitExtensionEnableBits(screen->base.glx_enable_bits);
 
         if (strstr(wgl_extensions, "WGL_ARB_make_current_read"))
             screen->has_WGL_ARB_make_current_read = TRUE;
 
         if (strstr(gl_extensions, "GL_WIN_swap_hint")) {
-            __glXEnableExtension(screen->glx_enable_bits,
+            __glXEnableExtension(screen->base.glx_enable_bits,
                                  "GLX_MESA_copy_sub_buffer");
             LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
         }
 
         if (strstr(wgl_extensions, "WGL_EXT_swap_control")) {
-            __glXEnableExtension(screen->glx_enable_bits,
+            __glXEnableExtension(screen->base.glx_enable_bits,
                                  "GLX_SGI_swap_control");
             LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control\n");
         }
@@ -652,7 +649,7 @@ glxWinScreenProbe(ScreenPtr pScreen)
 /*       // Hmm?  screen->texOffset */
 /*       if (strstr(wgl_extensions, "WGL_ARB_render_texture")) */
 /*         { */
-/*           __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_texture_from_pixmap"); */
+/*           __glXEnableExtension(screen->base.glx_enable_bits, "GLX_EXT_texture_from_pixmap"); */
 /*           LogMessage(X_INFO, "AIGLX: GLX_EXT_texture_from_pixmap backed by buffer objects\n"); */
 /*           screen->has_WGL_ARB_render_texture = TRUE; */
 /*         } */
@@ -707,10 +704,10 @@ glxWinScreenProbe(ScreenPtr pScreen)
         // Generate the GLX extensions string (overrides that set by __glXScreenInit())
         {
             unsigned int buffer_size =
-                __glXGetExtensionString(screen->glx_enable_bits, NULL);
+                __glXGetExtensionString(screen->base.glx_enable_bits, NULL);
             if (buffer_size > 0) {
                 screen->base.GLXextensions = xnfalloc(buffer_size);
-                __glXGetExtensionString(screen->glx_enable_bits,
+                __glXGetExtensionString(screen->base.glx_enable_bits,
                                         screen->base.GLXextensions);
             }
         }
-- 
2.5.0



More information about the xorg-devel mailing list