anv,i965: Stop warning about incomplete gen11 support
[mesa.git] / src / mesa / drivers / dri / common / utils.c
index ae8fcabc14e47491013770e2d56a0ac25606a557..5a66bcf8e054bee9ead54e43e6a382c8c253b73e 100644 (file)
 #include "utils.h"
 #include "dri_util.h"
 
+/* WARNING: HACK: Local defines to avoid pulling glx.h.
+ *
+ * Any parts of this file that use the following defines are either partial or
+ * entirely broken wrt EGL.
+ *
+ * For example any getConfigAttrib() or indexConfigAttrib() query from EGL for
+ * SLOW or NON_CONFORMANT_CONFIG will not work as expected since the EGL tokens
+ * are different from the GLX ones.
+ */
+#define GLX_NONE                                                0x8000
+#define GLX_SLOW_CONFIG                                         0x8001
+#define GLX_NON_CONFORMANT_CONFIG                               0x800D
+#define GLX_DONT_CARE                                           0xFFFFFFFF
+
 /**
  * Create the \c GL_RENDERER string for DRI drivers.
  * 
@@ -134,18 +148,24 @@ driGetRendererString( char * buffer, const char * hardware_name,
  * \param num_depth_stencil_bits  Number of entries in both \c depth_bits and
  *                      \c stencil_bits.
  * \param db_modes      Array of buffer swap modes.  If an element has a
- *                      value of \c GLX_NONE, then it represents a
- *                      single-buffered mode.  Other valid values are
- *                      \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and
- *                      \c GLX_SWAP_UNDEFINED_OML.  See the
- *                      GLX_OML_swap_method extension spec for more details.
+ *                      value of \c __DRI_ATTRIB_SWAP_NONE, then it
+ *                      represents a single-buffered mode.  Other valid
+ *                      values are \c __DRI_ATTRIB_SWAP_EXCHANGE,
+ *                      \c __DRI_ATTRIB_SWAP_COPY, and \c __DRI_ATTRIB_SWAP_UNDEFINED.
+ *                      They represent the respective GLX values as in
+ *                      the GLX_OML_swap_method extension spec.
  * \param num_db_modes  Number of entries in \c db_modes.
  * \param msaa_samples  Array of msaa sample count. 0 represents a visual
  *                      without a multisample buffer.
  * \param num_msaa_modes Number of entries in \c msaa_samples.
- * \param visType       GLX visual type.  Usually either \c GLX_TRUE_COLOR or
- *                      \c GLX_DIRECT_COLOR.
- * 
+ * \param enable_accum  Add an accum buffer to the configs
+ * \param color_depth_match Whether the color depth must match the zs depth
+ *                          This forces 32-bit color to have 24-bit depth, and
+ *                          16-bit color to have 16-bit depth.
+ * \param mutable_render_buffer Enable __DRI_ATTRIB_MUTABLE_RENDER_BUFFER,
+ *                              which translates to
+ *                              EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
+ *
  * \returns
  * Pointer to any array of pointers to the \c __DRIconfig structures created
  * for the specified formats.  If there is an error, \c NULL is returned.
@@ -158,7 +178,8 @@ driCreateConfigs(mesa_format format,
                 unsigned num_depth_stencil_bits,
                 const GLenum * db_modes, unsigned num_db_modes,
                 const uint8_t * msaa_samples, unsigned num_msaa_modes,
-                GLboolean enable_accum)
+                GLboolean enable_accum, GLboolean color_depth_match,
+                GLboolean mutable_render_buffer)
 {
    static const uint32_t masks_table[][4] = {
       /* MESA_FORMAT_B5G6R5_UNORM */
@@ -171,6 +192,14 @@ driCreateConfigs(mesa_format format,
       { 0x3FF00000, 0x000FFC00, 0x000003FF, 0x00000000 },
       /* MESA_FORMAT_B10G10R10A2_UNORM */
       { 0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000 },
+      /* MESA_FORMAT_R8G8B8A8_UNORM */
+      { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 },
+      /* MESA_FORMAT_R8G8B8X8_UNORM */
+      { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 },
+      /* MESA_FORMAT_R10G10B10X2_UNORM */
+      { 0x000003FF, 0x000FFC00, 0x3FF00000, 0x00000000 },
+      /* MESA_FORMAT_R10G10B10A2_UNORM */
+      { 0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000 },
    };
 
    const uint32_t * masks;
@@ -197,12 +226,25 @@ driCreateConfigs(mesa_format format,
    case MESA_FORMAT_B8G8R8A8_SRGB:
       masks = masks_table[2];
       break;
+   case MESA_FORMAT_R8G8B8A8_UNORM:
+   case MESA_FORMAT_R8G8B8A8_SRGB:
+      masks = masks_table[5];
+      break;
+   case MESA_FORMAT_R8G8B8X8_UNORM:
+      masks = masks_table[6];
+      break;
    case MESA_FORMAT_B10G10R10X2_UNORM:
       masks = masks_table[3];
       break;
    case MESA_FORMAT_B10G10R10A2_UNORM:
       masks = masks_table[4];
       break;
+   case MESA_FORMAT_R10G10B10X2_UNORM:
+      masks = masks_table[7];
+      break;
+   case MESA_FORMAT_R10G10B10A2_UNORM:
+      masks = masks_table[8];
+      break;
    default:
       fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n",
               __func__, __LINE__,
@@ -226,6 +268,19 @@ driCreateConfigs(mesa_format format,
        for ( i = 0 ; i < num_db_modes ; i++ ) {
            for ( h = 0 ; h < num_msaa_modes; h++ ) {
                for ( j = 0 ; j < num_accum_bits ; j++ ) {
+                   if (color_depth_match &&
+                       (depth_bits[k] || stencil_bits[k])) {
+                       /* Depth can really only be 0, 16, 24, or 32. A 32-bit
+                        * color format still matches 24-bit depth, as there
+                        * is an implicit 8-bit stencil. So really we just
+                        * need to make sure that color/depth are both 16 or
+                        * both non-16.
+                        */
+                       if ((depth_bits[k] + stencil_bits[k] == 16) !=
+                           (red_bits + green_bits + blue_bits + alpha_bits == 16))
+                           continue;
+                   }
+
                    *c = malloc (sizeof **c);
                    modes = &(*c)->modes;
                    c++;
@@ -259,8 +314,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 = __DRI_ATTRIB_SWAP_UNDEFINED;
                    }
                    else {
                        modes->doubleBufferMode = GL_TRUE;
@@ -288,6 +344,7 @@ driCreateConfigs(mesa_format format,
 
                    modes->yInverted = GL_TRUE;
                    modes->sRGBCapable = is_srgb;
+                   modes->mutableRenderBuffer = mutable_render_buffer;
                }
            }
        }
@@ -372,13 +429,13 @@ static const struct { unsigned int attrib, offset; } attribMap[] = {
     __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS,     bindToTextureTargets),
     __ATTRIB(__DRI_ATTRIB_YINVERTED,                   yInverted),
     __ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE,    sRGBCapable),
+    __ATTRIB(__DRI_ATTRIB_MUTABLE_RENDER_BUFFER,       mutableRenderBuffer),
 
     /* The struct field doesn't matter here, these are handled by the
      * switch in driGetConfigAttribIndex.  We need them in the array
      * so the iterator includes them though.*/
     __ATTRIB(__DRI_ATTRIB_RENDER_TYPE,                 level),
     __ATTRIB(__DRI_ATTRIB_CONFIG_CAVEAT,               level),
-    __ATTRIB(__DRI_ATTRIB_SWAP_METHOD,                 level)
 };
 
 
@@ -403,10 +460,6 @@ driGetConfigAttribIndex(const __DRIconfig *config,
        else
            *value = 0;
        break;
-    case __DRI_ATTRIB_SWAP_METHOD:
-        /* XXX no return value??? */
-       break;
-
     default:
         /* any other int-sized field */
        *value = *(unsigned int *)