[Mesa-dev] [PATCH 16/16] intel: Advertise multisample DRI2 configs on gen >= 6

Chad Versace chad.versace at linux.intel.com
Thu Aug 2 18:39:59 PDT 2012


This turns on window system MSAA.

This patch changes the id of many GLX visuals and configs, but that
couldn't be prevented. I attempted to preserve the id's of extant configs
by appending the multisample configs to the end of the extant ones. But
somewhere, perhaps in the X server, the configs are reordered with
multisample configs interspersed among the singlesample ones.

Test results:
  Tested with xonotic and `glxgears -samples 1` on Ivybridge.

  No piglit regressions on Ivybridge.

  On Sandybridge, passes 68/70 of oglconform's
  winsys multisample tests.  The two failing tests are:
      multisample(advanced.pixelmap.depth)
      multisample(advanced.pixelmap.depthCopyPixels)
  These tests hang the gpu (on kernel 3.4.6) due to
  a glDrawPixels/glReadPixels pair on an MSAA depth buffer.  I don't expect
  realworld apps to do that, so I'm not too concerned about the hang.

  On Ivybridge, passes 69/70. The failing case is
  multisample(advanced.line.changeWidth).

v2:
  - Place MSAA configs after singlesample configs to work around X server
    bug.
  - Document why supported swap methods differ between singlesample
    and multisample configs.

CC: Ian Romanick <idr at freedesktop.org>
CC: Eric Anholt <eric at anholt.net>
CC: Paul Berry <stereotype441 at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/mesa/drivers/dri/intel/intel_screen.c | 58 ++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 9cc5480..f93e668 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -828,8 +828,9 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
        GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
    };
 
-   static const msaa_samples_array[1] = {0};
+   static const msaa_samples_array[3] = {0, 4, 8};
 
+   struct intel_screen *screen = dri_screen->driverPrivate;
    GLenum fb_format[3];
    GLenum fb_type[3];
    uint8_t depth_bits[4], stencil_bits[4];
@@ -844,9 +845,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
    fb_format[2] = GL_BGRA;
    fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;
 
-   /* Generate a rich set of useful configs that do not include an
-    * accumulation buffer.
-    */
+   /* Generate singlesample configs without accumulation buffer. */
    for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
       __DRIconfig **new_configs;
       const int num_depth_stencil_bits = 2;
@@ -899,6 +898,57 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
       configs = driConcatConfigs(configs, new_configs);
    }
 
+   /* Generate multisample configs.
+    *
+    * This loop breaks early, and hence is a no-op, on gen < 6.
+    *
+    * Multisample configs must follow the singlesample configs in order to
+    * work around an X server bug present in 1.12. The X server chooses to
+    * associate the first listed RGBA888-Z24S8 config, regardless of its
+    * sample count, with the 32-bit depth visual used for compositing.
+    *
+    * Only doublebuffer configs with GLX_SWAP_UNDEFINED_OML behavior are
+    * supported.  Singlebuffer configs are not supported because that would
+    * require that rendering be eventually written to the singlesample buffer
+    * even if DRI2Flush is never called; yet we downsample to the singlesample
+    * buffer only on DRI2Flush.  GLX_SWAP_COPY_OML is not supported because we
+    * have no tests for its interaction with MSAA.
+    */
+   for (int i = 0; i < ARRAY_SIZE(fb_format); i++) {
+      if (screen->gen < 6)
+         break;
+
+      __DRIconfig **new_configs;
+      const int num_depth_stencil_bits = 2;
+      int num_msaa_modes;
+
+      depth_bits[0] = 0;
+      stencil_bits[0] = 0;
+
+      if (fb_type[i] == GL_UNSIGNED_SHORT_5_6_5) {
+         depth_bits[1] = 16;
+         stencil_bits[1] = 0;
+      } else {
+         depth_bits[1] = 24;
+         stencil_bits[1] = 8;
+      }
+
+      if (screen->gen >= 7)
+         num_msaa_modes = 2;
+      else if (screen->gen == 6)
+         num_msaa_modes = 1;
+
+      new_configs = driCreateConfigs(fb_format[i], fb_type[i],
+                                     depth_bits,
+                                     stencil_bits,
+                                     num_depth_stencil_bits,
+                                     back_buffer_modes + 1, 1,
+                                     msaa_samples_array + 1,
+                                     num_msaa_modes,
+                                     false);
+      configs = driConcatConfigs(configs, new_configs);
+   }
+
    if (configs == NULL) {
       fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
               __LINE__);
-- 
1.7.11.4



More information about the mesa-dev mailing list