Mesa (master): st/glx: fix depth/stencil format selection code
Brian Paul
brianp at kemper.freedesktop.org
Mon Mar 22 22:02:06 UTC 2010
Module: Mesa
Branch: master
Commit: ef2664da6c4db1b52ef351641e3ee949b87f9c7b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef2664da6c4db1b52ef351641e3ee949b87f9c7b
Author: Brian Paul <brianp at vmware.com>
Date: Mon Mar 22 15:55:43 2010 -0600
st/glx: fix depth/stencil format selection code
This fixes a pretty big performance regression caused by commit
3475e88442c16fb2b50b903fe246b3ebe49da226.
When the user does not request a stencil buffer it's important that we
don't use a depth/stencil format (or at least make it our last choice).
If the user calls glClear(GL_DEPTH_BUFFER_BIT) when we have a combined
depth/stencil buffer, that causes us to hit the clear_with_quad() path
which can be much, much slower than calling pipe_context::clear().
Also, try to use a shallower depth format before a deeper one.
---
src/gallium/state_trackers/glx/xlib/xm_api.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 62a2bfc..8dd5420 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -309,8 +309,9 @@ choose_pixel_format(XMesaVisual v)
return 0;
}
+
/**
- * Choose a depth/stencil format that is "better" than the given depth and
+ * Choose a depth/stencil format that satisfies the given depth and
* stencil sizes.
*/
static enum pipe_format
@@ -324,16 +325,20 @@ choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil)
int count, i;
count = 0;
+
+ if (depth <= 16 && stencil == 0) {
+ formats[count++] = PIPE_FORMAT_Z16_UNORM;
+ }
+ if (depth <= 24 && stencil == 0) {
+ formats[count++] = PIPE_FORMAT_X8Z24_UNORM;
+ formats[count++] = PIPE_FORMAT_Z24X8_UNORM;
+ }
if (depth <= 24 && stencil <= 8) {
formats[count++] = PIPE_FORMAT_S8Z24_UNORM;
formats[count++] = PIPE_FORMAT_Z24S8_UNORM;
}
-
- if (!stencil) {
- if (depth <= 16)
- formats[count++] = PIPE_FORMAT_Z16_UNORM;
- if (depth <= 32)
- formats[count++] = PIPE_FORMAT_Z32_UNORM;
+ if (depth <= 32 && stencil == 0) {
+ formats[count++] = PIPE_FORMAT_Z32_UNORM;
}
fmt = PIPE_FORMAT_NONE;
More information about the mesa-commit
mailing list