Mesa (gallium-st-api): st/glx: Return a better format in choose_depth_stencil_format.

Chia-I Wu olv at kemper.freedesktop.org
Fri Mar 12 03:21:52 UTC 2010


Module: Mesa
Branch: gallium-st-api
Commit: 3475e88442c16fb2b50b903fe246b3ebe49da226
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3475e88442c16fb2b50b903fe246b3ebe49da226

Author: Chia-I Wu <olv at lunarg.com>
Date:   Fri Mar 12 11:20:27 2010 +0800

st/glx: Return a better format in choose_depth_stencil_format.

Return a better format instead of an exact format in
choose_depth_stencil_format.  Also, prefer formats with stencil bits.

---

 src/gallium/state_trackers/glx/xlib/xm_api.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 6a0f314..3ea4d77 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -274,7 +274,8 @@ choose_pixel_format(XMesaVisual v)
 }
 
 /**
- * Choose a depth/stencil format for the given depth and stencil sizes.
+ * Choose a depth/stencil format that is "better" than the given depth and
+ * stencil sizes.
  */
 static enum pipe_format
 choose_depth_stencil_format(int depth, int stencil)
@@ -289,21 +290,16 @@ choose_depth_stencil_format(int depth, int stencil)
    assert(screen);
 
    count = 0;
-   switch (depth) {
-   case 16:
-      if (!stencil)
-         formats[count++] = PIPE_FORMAT_Z16_UNORM;
-      break;
-   case 24:
+   if (depth <= 24 && stencil <= 8) {
       formats[count++] = PIPE_FORMAT_S8Z24_UNORM;
       formats[count++] = PIPE_FORMAT_Z24S8_UNORM;
-      break;
-   case 32:
-      if (!stencil)
+   }
+
+   if (!stencil) {
+      if (depth <= 16)
+         formats[count++] = PIPE_FORMAT_Z16_UNORM;
+      if (depth <= 32)
          formats[count++] = PIPE_FORMAT_Z32_UNORM;
-      break;
-   default:
-      break;
    }
 
    fmt = PIPE_FORMAT_NONE;




More information about the mesa-commit mailing list