intel/blorp: Take a destination swizzle in blorp_blit
[mesa.git] / src / mesa / drivers / dri / common / utils.c
index 43d90d905997c0edb2adca3da3799a992a75b16b..c37d446a1e4ab6bda14e4cc54bbb593b96bae858 100644 (file)
 #include "utils.h"
 #include "dri_util.h"
 
-
-uint64_t
-driParseDebugString( const char * debug, 
-                    const struct dri_debug_control * control  )
-{
-   uint64_t flag = 0;
-
-   if ( debug != NULL ) {
-      while( control->string != NULL ) {
-        if ( !strcmp( debug, "all" ) ||
-             strstr( debug, control->string ) != NULL ) {
-           flag |= control->flag;
-        }
-
-        control++;
-      }
-   }
-
-   return flag;
-}
-
-
-
 /**
  * Create the \c GL_RENDERER string for DRI drivers.
  * 
@@ -166,8 +143,10 @@ driGetRendererString( char * buffer, const char * hardware_name,
  * \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.
  * 
  * \returns
  * Pointer to any array of pointers to the \c __DRIconfig structures created
@@ -181,7 +160,7 @@ 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)
 {
    static const uint32_t masks_table[][4] = {
       /* MESA_FORMAT_B5G6R5_UNORM */
@@ -194,6 +173,10 @@ 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 },
    };
 
    const uint32_t * masks;
@@ -220,6 +203,12 @@ driCreateConfigs(mesa_format format,
    case MESA_FORMAT_B8G8R8A8_SRGB:
       masks = masks_table[2];
       break;
+   case MESA_FORMAT_R8G8B8A8_UNORM:
+      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;
@@ -249,6 +238,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++;