dri: Introduce SWAP_METHOD tokens
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 9 Aug 2017 09:25:10 +0000 (11:25 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 10 Aug 2017 07:15:33 +0000 (09:15 +0200)
We shouldn't be using GLX tokens in the dri subsystem, so define dri
SWAP_METHOD tokens and translate when necessary. Unfortunately the X server
uses the dri swap method value untranslated as the GLX fbconfig swapMethod,
so we can't enumerate these tokens arbitrarily, but rather need to make them
have the same values as the corresponding GLX tokens.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
include/GL/internal/dri_interface.h
src/gallium/state_trackers/dri/dri_screen.c
src/glx/dri_common.c
src/mesa/drivers/dri/common/utils.c
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/intel_screen.c
src/mesa/drivers/dri/nouveau/nouveau_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/swrast/swrast.c

index 5e8fce79f9143bddf7531a3a61834f93c589f592..2cbd738439eb995e4abc97849ee3b3ead650994f 100644 (file)
@@ -724,6 +724,18 @@ struct __DRIuseInvalidateExtensionRec {
 #define __DRI_ATTRIB_TEXTURE_2D_BIT            0x02
 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT     0x04
 
+/* __DRI_ATTRIB_SWAP_METHOD */
+/* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define
+ * the same tokens as GLX. This is because old and current X servers will
+ * transmit the driconf value grabbed from the AIGLX driver untranslated as
+ * the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers
+ * to signal to the dri core that the driconfig is single-buffer.
+ */
+#define __DRI_ATTRIB_SWAP_NONE                  0x0000
+#define __DRI_ATTRIB_SWAP_EXCHANGE              0x8061
+#define __DRI_ATTRIB_SWAP_COPY                  0x8062
+#define __DRI_ATTRIB_SWAP_UNDEFINED             0x8063
+
 /**
  * This extension defines the core DRI functionality.
  *
index 406e97dc2429a10879a495a8fc6f472b4983d0df..1d9f441223e1538595d444e7011b1c834b721ab4 100644 (file)
@@ -156,7 +156,8 @@ dri_fill_in_modes(struct dri_screen *screen)
    boolean mixed_color_depth;
 
    static const GLenum back_buffer_modes[] = {
-      GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+      __DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED,
+      __DRI_ATTRIB_SWAP_COPY
    };
 
    if (driQueryOptionb(&screen->dev->option_cache, "always_have_depth_buffer")) {
index 0f8f7134b4ad0b03c90ba3084c78bb51f4df9a3d..e2bbd48d3a59da79780093bf6cf43b459ca32697 100644 (file)
@@ -317,6 +317,19 @@ driConfigEqual(const __DRIcoreExtension *core,
             return GL_FALSE;
          break;
 
+      case __DRI_ATTRIB_SWAP_METHOD:
+         if (value == __DRI_ATTRIB_SWAP_EXCHANGE)
+            glxValue = GLX_SWAP_EXCHANGE_OML;
+         else if (value == __DRI_ATTRIB_SWAP_COPY)
+            glxValue = GLX_SWAP_COPY_OML;
+         else
+            glxValue = GLX_SWAP_UNDEFINED_OML;
+
+         if (!scalarEqual(config, attrib, glxValue))
+            return GL_FALSE;
+
+         break;
+
       default:
          if (!scalarEqual(config, attrib, value))
             return GL_FALSE;
index 7ae4cb8cd20f204339d18591eefc5a06cc7376f6..e944754a424d2241e80aebbd92d5c9414e19eb25 100644 (file)
@@ -284,9 +284,9 @@ driCreateConfigs(mesa_format format,
                    modes->transparentIndex = GLX_DONT_CARE;
                    modes->rgbMode = GL_TRUE;
 
-                   if ( db_modes[i] == GLX_NONE ) {
+                   if (db_modes[i] == __DRI_ATTRIB_SWAP_NONE) {
                        modes->doubleBufferMode = GL_FALSE;
-                       modes->swapMethod = GLX_SWAP_UNDEFINED_OML;
+                       modes->swapMethod = __DRI_ATTRIB_SWAP_UNDEFINED;
                    }
                    else {
                        modes->doubleBufferMode = GL_TRUE;
index 367a7347fb9384640d4193b241adb1bb6eb2ae87..6e32ac22cb77ed43cf2cba576c1de8e59a8dff04 100644 (file)
@@ -1060,7 +1060,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
 
    /* GLX_SWAP_COPY_OML is not supported due to page flipping. */
    static const GLenum back_buffer_modes[] = {
-       GLX_SWAP_UNDEFINED_OML, GLX_NONE,
+      __DRI_ATTRIB_SWAP_UNDEFINED, __DRI_ATTRIB_SWAP_NONE
    };
 
    static const uint8_t singlesample_samples[1] = {0};
index ec07cf0acc72a0908162541fd448f2f257e5731e..452f0d186cd669d7d87aa0b7f78c551bea044418 100644 (file)
@@ -1774,7 +1774,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
 
    /* GLX_SWAP_COPY_OML is not supported due to page flipping. */
    static const GLenum back_buffer_modes[] = {
-       GLX_SWAP_UNDEFINED_OML, GLX_NONE,
+      __DRI_ATTRIB_SWAP_UNDEFINED, __DRI_ATTRIB_SWAP_NONE
    };
 
    static const uint8_t singlesample_samples[1] = {0};
index 65caec27eb3e4a88ae77d387b4cad9f4acc25910..95b3469daae821e303270d3cc2c812ec0bb578b0 100644 (file)
@@ -65,7 +65,7 @@ nouveau_get_configs(uint32_t chipset)
        };
 
        const GLenum back_buffer_modes[] = {
-               GLX_NONE, GLX_SWAP_UNDEFINED_OML
+               __DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED
        };
 
        for (i = 0; i < ARRAY_SIZE(formats); i++) {
index a2061e51be57adace5868d8316e4f8d63f905426..750a65492285d8bfed8cb40af9cffcf8ad0b31b2 100644 (file)
@@ -770,11 +770,9 @@ __DRIconfig **radeonInitScreen2(__DRIscreen *psp)
       MESA_FORMAT_B8G8R8X8_UNORM,
       MESA_FORMAT_B8G8R8A8_UNORM
    };
-   /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
-    * support pageflipping at all.
-    */
+
    static const GLenum back_buffer_modes[] = {
-     GLX_NONE, GLX_SWAP_UNDEFINED_OML, /*, GLX_SWAP_COPY_OML*/
+      __DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED
    };
    uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1];
    int color;
index 7de90d31f1357165947bc1bef295e5bcb640d2dd..45d8279d3649595d70d2820d4675b6f23589b089 100644 (file)
@@ -227,7 +227,7 @@ swrastFillInModes(__DRIscreen *psp,
      * support pageflipping at all.
      */
     static const GLenum back_buffer_modes[] = {
-       GLX_NONE, GLX_SWAP_UNDEFINED_OML
+       __DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED
     };
 
     uint8_t depth_bits_array[4];