Mesa (master): st/dri: Always try to set up R5G6B5 configs.

Michel Dänzer daenzer at kemper.freedesktop.org
Fri Mar 12 18:21:21 UTC 2010


Module: Mesa
Branch: master
Commit: 51a51899d0e7eab93468f51296c196b2f3978332
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=51a51899d0e7eab93468f51296c196b2f3978332

Author: Michel Dänzer <daenzer at vmware.com>
Date:   Fri Mar 12 18:24:34 2010 +0100

st/dri: Always try to set up R5G6B5 configs.

Allows compiz to work in depth 16.

The DRI2 getBuffersWithFormat hook is only required for 16/32 bit depth
buffers, for colour buffers the only requirement is that the format matches
the drawable depth, which we can't check here.

(cherry picked from commit c50477c255a34444720fb944c54373462ef39fb9)

---

 src/gallium/state_trackers/dri/dri_screen.c |   97 ++++++++++++++-------------
 1 files changed, 50 insertions(+), 47 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index 60bc560..7ccad8f 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -90,6 +90,9 @@ dri_fill_in_modes(struct dri_screen *screen,
 		  unsigned pixel_bits)
 {
    __DRIconfig **configs = NULL;
+   __DRIconfig **configs_r5g6b5 = NULL;
+   __DRIconfig **configs_a8r8g8b8 = NULL;
+   __DRIconfig **configs_x8r8g8b8 = NULL;
    unsigned num_modes;
    uint8_t depth_bits_array[5];
    uint8_t stencil_bits_array[5];
@@ -127,25 +130,23 @@ dri_fill_in_modes(struct dri_screen *screen,
    pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
 					       PIPE_TEXTURE_2D,
 					       PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
-
-   /* we support buffers with different depths only if we can tell the driver
-    * the actual depth of each of them. */
-   if (screen->sPriv->dri2.loader
-       && (screen->sPriv->dri2.loader->base.version > 2)
-       && (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
+   pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
+					     PIPE_TEXTURE_2D,
+					     PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+
+   /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
+   if (screen->sPriv->dri2.loader &&
+       (screen->sPriv->dri2.loader->base.version > 2) &&
+       (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
       pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
                                              PIPE_TEXTURE_2D,
                                              PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
       pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
                                              PIPE_TEXTURE_2D,
                                              PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
-      pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
-                                                PIPE_TEXTURE_2D,
-                                                PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
    } else {
       pf_z16 = FALSE;
       pf_z32 = FALSE;
-      pf_r5g6b5 = FALSE;
    }
 
    if (pf_z16) {
@@ -175,46 +176,48 @@ dri_fill_in_modes(struct dri_screen *screen,
    num_modes =
       depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
 
-   if (pixel_bits == 16 && pf_r5g6b5) {
-      configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
-				 depth_bits_array, stencil_bits_array,
-				 depth_buffer_factor, back_buffer_modes,
-				 back_buffer_factor,
-				 msaa_samples_array, msaa_samples_factor,
-				 GL_TRUE);
+   if (pf_r5g6b5)
+      configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
+                                        depth_bits_array, stencil_bits_array,
+                                        depth_buffer_factor, back_buffer_modes,
+                                        back_buffer_factor,
+                                        msaa_samples_array, msaa_samples_factor,
+                                        GL_TRUE);
+
+   if (pf_a8r8g8b8)
+      configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+                                          depth_bits_array,
+                                          stencil_bits_array,
+                                          depth_buffer_factor,
+                                          back_buffer_modes,
+                                          back_buffer_factor,
+                                          msaa_samples_array,
+                                          msaa_samples_factor,
+                                          GL_TRUE);
+
+   if (pf_x8r8g8b8)
+      configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
+                                          depth_bits_array,
+                                          stencil_bits_array,
+                                          depth_buffer_factor,
+                                          back_buffer_modes,
+                                          back_buffer_factor,
+                                          msaa_samples_array,
+                                          msaa_samples_factor,
+                                          GL_TRUE);
+
+   if (pixel_bits == 16) {
+      configs = configs_r5g6b5;
+      if (configs_a8r8g8b8)
+         configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8;
+      if (configs_x8r8g8b8)
+	 configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
    } else {
-      __DRIconfig **configs_a8r8g8b8 = NULL;
-      __DRIconfig **configs_x8r8g8b8 = NULL;
-
-      if (pf_a8r8g8b8)
-	 configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
-					     depth_bits_array,
-					     stencil_bits_array,
-					     depth_buffer_factor,
-					     back_buffer_modes,
-					     back_buffer_factor,
-					     msaa_samples_array,
-                                             msaa_samples_factor,
-					     GL_TRUE);
-      if (pf_x8r8g8b8)
-	 configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
-					     depth_bits_array,
-					     stencil_bits_array,
-					     depth_buffer_factor,
-					     back_buffer_modes,
-					     back_buffer_factor,
-					     msaa_samples_array,
-                                             msaa_samples_factor,
-					     GL_TRUE);
-
-      if (configs_a8r8g8b8 && configs_x8r8g8b8)
-	 configs = driConcatConfigs(configs_x8r8g8b8, configs_a8r8g8b8);
-      else if (configs_a8r8g8b8)
-	 configs = configs_a8r8g8b8;
-      else if (configs_x8r8g8b8)
-	 configs = configs_x8r8g8b8;
-      else
-	 configs = NULL;
+      configs = configs_a8r8g8b8;
+      if (configs_x8r8g8b8)
+	 configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
+      if (configs_r5g6b5)
+         configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5;
    }
 
    if (configs == NULL) {




More information about the mesa-commit mailing list