On 21 July 2012 17:36, Chad Versace <span dir="ltr"><<a href="mailto:chad.versace@linux.intel.com" target="_blank">chad.versace@linux.intel.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
DRI2 configs were constructed in intelInitScreen2. That function already<br>
does too much, so move verbatim the code for creating configs to a new<br>
function, intel_screen_make_configs.<br>
<br>
CC: Eric Anholt <<a href="mailto:eric@anholt.net">eric@anholt.net</a>><br>
CC: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
Signed-off-by: Chad Versace <<a href="mailto:chad.versace@linux.intel.com">chad.versace@linux.intel.com</a>><br>
---<br>
 src/mesa/drivers/dri/intel/intel_screen.c | 189 ++++++++++++++++--------------<br>
 1 file changed, 98 insertions(+), 91 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c<br>
index 958ff9f..9bb42dd 100644<br>
--- a/src/mesa/drivers/dri/intel/intel_screen.c<br>
+++ b/src/mesa/drivers/dri/intel/intel_screen.c<br>
@@ -848,6 +848,103 @@ intel_detect_swizzling(struct intel_screen *screen)<br>
       return true;<br>
 }<br>
<br>
+static __DRIconfig**<br>
+intel_screen_make_configs(__DRIscreen *dri_screen)<br>
+{<br>
+   static const GLenum back_buffer_modes[] = {<br>
+       GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML<br>
+   };<br>
+<br>
+   GLenum fb_format[3];<br>
+   GLenum fb_type[3];<br>
+   uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1];<br>
+   int color;<br>
+   __DRIconfig **configs = NULL;<br>
+<br>
+   msaa_samples_array[0] = 0;<br>
+<br>
+   fb_format[0] = GL_RGB;<br>
+   fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;<br>
+<br>
+   fb_format[1] = GL_BGR;<br>
+   fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;<br>
+<br>
+   fb_format[2] = GL_BGRA;<br>
+   fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;<br>
+<br>
+   depth_bits[0] = 0;<br>
+   stencil_bits[0] = 0;<br>
+<br>
+   /* Generate a rich set of useful configs that do not include an<br>
+    * accumulation buffer.<br>
+    */<br>
+   for (color = 0; color < ARRAY_SIZE(fb_format); color++) {<br>
+      __DRIconfig **new_configs;<br>
+      int depth_factor;<br>
+<br>
+      /* Starting with DRI2 protocol version 1.1 we can request a depth/stencil<br>
+       * buffer that has a different number of bits per pixel than the color<br>
+       * buffer.  This isn't yet supported here.<br>
+       */<br>
+      if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) {<br>
+         depth_bits[1] = 16;<br>
+         stencil_bits[1] = 0;<br>
+      } else {<br>
+         depth_bits[1] = 24;<br>
+         stencil_bits[1] = 8;<br>
+      }<br>
+<br>
+      depth_factor = 2;<br>
+<br>
+      new_configs = driCreateConfigs(fb_format[color], fb_type[color],<br>
+                                     depth_bits,<br>
+                                     stencil_bits,<br>
+                                     depth_factor,<br>
+                                     back_buffer_modes,<br>
+                                     ARRAY_SIZE(back_buffer_modes),<br>
+                                     msaa_samples_array,<br>
+                                     ARRAY_SIZE(msaa_samples_array),<br>
+                                     false);<br>
+      if (configs == NULL)<br>
+         configs = new_configs;<br>
+      else<br>
+         configs = driConcatConfigs(configs, new_configs);<br>
+   }<br>
+<br>
+   /* Generate the minimum possible set of configs that include an<br>
+    * accumulation buffer.<br>
+    */<br>
+   for (color = 0; color < ARRAY_SIZE(fb_format); color++) {<br>
+      __DRIconfig **new_configs;<br>
+<br>
+      if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) {<br>
+         depth_bits[0] = 16;<br>
+         stencil_bits[0] = 0;<br>
+      } else {<br>
+         depth_bits[0] = 24;<br>
+         stencil_bits[0] = 8;<br>
+      }<br>
+<br>
+      new_configs = driCreateConfigs(fb_format[color], fb_type[color],<br>
+                                     depth_bits, stencil_bits, 1,<br>
+                                     back_buffer_modes + 1, 1,<br>
+                                     msaa_samples_array, 1,<br>
+                                     true);<br>
+      if (configs == NULL)<br>
+         configs = new_configs;<br>
+      else<br>
+         configs = driConcatConfigs(configs, new_configs);<br>
+   }<br>
+<br>
+   if (configs == NULL) {<br>
+      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,<br>
+              __LINE__);<br>
+      return NULL;<br>
+   }<br>
+<br>
+   return configs;<br>
+}<br>
+<br>
 /**<br>
  * This is the driver specific part of the createNewScreen entry point.<br>
  * Called when using DRI2.<br>
@@ -858,17 +955,8 @@ static const<br>
 __DRIconfig **intelInitScreen2(__DRIscreen *psp)<br>
 {<br>
    struct intel_screen *intelScreen;<br>
-   GLenum fb_format[3];<br>
-   GLenum fb_type[3];<br>
    unsigned int api_mask;<br>
<br>
-   static const GLenum back_buffer_modes[] = {<br>
-       GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML<br>
-   };<br>
-   uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1];<br>
-   int color;<br>
-   __DRIconfig **configs = NULL;<br>
-<br>
    if (psp->dri2.loader->base.version <= 2 ||<br>
        psp->dri2.loader->getBuffersWithFormat == NULL) {<br>
       fprintf(stderr,<br>
@@ -941,88 +1029,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)<br>
<br>
    psp->extensions = intelScreenExtensions;<br>
<br>
-   msaa_samples_array[0] = 0;<br>
-<br>
-   fb_format[0] = GL_RGB;<br>
-   fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;<br>
-<br>
-   fb_format[1] = GL_BGR;<br>
-   fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;<br>
-<br>
-   fb_format[2] = GL_BGRA;<br>
-   fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;<br>
-<br>
-   depth_bits[0] = 0;<br>
-   stencil_bits[0] = 0;<br>
-<br>
-   /* Generate a rich set of useful configs that do not include an<br>
-    * accumulation buffer.<br>
-    */<br>
-   for (color = 0; color < ARRAY_SIZE(fb_format); color++) {<br>
-      __DRIconfig **new_configs;<br>
-      int depth_factor;<br>
-<br>
-      /* Starting with DRI2 protocol version 1.1 we can request a depth/stencil<br>
-       * buffer that has a diffferent number of bits per pixel than the color<br></blockquote><div><br>Man, I'm gonna miss that typo... :)<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

-       * buffer.  This isn't yet supported here.<br>
-       */<br>
-      if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) {<br>
-        depth_bits[1] = 16;<br>
-        stencil_bits[1] = 0;<br>
-      } else {<br>
-        depth_bits[1] = 24;<br>
-        stencil_bits[1] = 8;<br>
-      }<br>
-<br>
-      depth_factor = 2;<br>
-<br>
-      new_configs = driCreateConfigs(fb_format[color], fb_type[color],<br>
-                                    depth_bits,<br>
-                                    stencil_bits,<br>
-                                    depth_factor,<br>
-                                    back_buffer_modes,<br>
-                                    ARRAY_SIZE(back_buffer_modes),<br>
-                                    msaa_samples_array,<br>
-                                    ARRAY_SIZE(msaa_samples_array),<br>
-                                    false);<br>
-      if (configs == NULL)<br>
-        configs = new_configs;<br>
-      else<br>
-        configs = driConcatConfigs(configs, new_configs);<br>
-   }<br>
-<br>
-   /* Generate the minimum possible set of configs that include an<br>
-    * accumulation buffer.<br>
-    */<br>
-   for (color = 0; color < ARRAY_SIZE(fb_format); color++) {<br>
-      __DRIconfig **new_configs;<br>
-<br>
-      if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) {<br>
-        depth_bits[0] = 16;<br>
-        stencil_bits[0] = 0;<br>
-      } else {<br>
-        depth_bits[0] = 24;<br>
-        stencil_bits[0] = 8;<br>
-      }<br>
-<br>
-      new_configs = driCreateConfigs(fb_format[color], fb_type[color],<br>
-                                    depth_bits, stencil_bits, 1,<br>
-                                    back_buffer_modes + 1, 1,<br>
-                                    msaa_samples_array, 1,<br>
-                                    true);<br>
-      if (configs == NULL)<br>
-        configs = new_configs;<br>
-      else<br>
-        configs = driConcatConfigs(configs, new_configs);<br>
-   }<br>
-<br>
-   if (configs == NULL) {<br>
-      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,<br>
-              __LINE__);<br>
-      return NULL;<br>
-   }<br>
-<br>
-   return (const __DRIconfig **)configs;<br>
+   return (const __DRIconfig**) intel_screen_make_configs(psp);<br>
 }<br>
<br>
 struct intel_buffer {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.2<br>
<br>
</font></span></blockquote></div><br>This patch is<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>