Mesa (master): st/glx: better format selection in xmesa_choose_z_stencil_format()
Brian Paul
brianp at kemper.freedesktop.org
Tue Mar 23 08:14:32 PDT 2010
Module: Mesa
Branch: master
Commit: 4ceeb1307a018f426784620d3376f9f1ea07e53b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ceeb1307a018f426784620d3376f9f1ea07e53b
Author: Brian Paul <brianp at vmware.com>
Date: Tue Mar 23 08:58:09 2010 -0600
st/glx: better format selection in xmesa_choose_z_stencil_format()
This is a back-port of commit ef2664da6c4db1b52ef351641e3ee949b87f9c7b
from master.
---
src/gallium/state_trackers/glx/xlib/xm_api.c | 41 +++++++++++++++-----------
1 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 217bdef..e8524a2 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -324,7 +324,7 @@ choose_pixel_format(XMesaVisual v)
* at least matches the given depthBits and stencilBits.
*/
static void
-xmesa_choose_z_stencil_format(int depthBits, int stencilBits,
+xmesa_choose_z_stencil_format(int depth, int stencil,
enum pipe_format *depthFormat,
enum pipe_format *stencilFormat)
{
@@ -332,20 +332,28 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits,
const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE |
PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO);
- static enum pipe_format formats[] = {
- PIPE_FORMAT_S8Z24_UNORM,
- PIPE_FORMAT_Z24S8_UNORM,
- PIPE_FORMAT_Z16_UNORM,
- PIPE_FORMAT_Z32_UNORM
- };
- int i;
+ enum pipe_format formats[8];
+ int count, i;
- assert(screen);
+ count = 0;
- *depthFormat = *stencilFormat = PIPE_FORMAT_NONE;
+ 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 (depth <= 32 && stencil == 0) {
+ formats[count++] = PIPE_FORMAT_Z32_UNORM;
+ }
- /* search for supported format */
- for (i = 0; i < Elements(formats); i++) {
+ *depthFormat = PIPE_FORMAT_NONE;
+ for (i = 0; i < count; i++) {
if (screen->is_format_supported(screen, formats[i],
target, tex_usage, geom_flags)) {
*depthFormat = formats[i];
@@ -353,13 +361,12 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits,
}
}
- if (stencilBits) {
+ if (stencil) {
*stencilFormat = *depthFormat;
}
-
- /* XXX we should check that he chosen format has at least as many bits
- * as what was requested.
- */
+ else {
+ *stencilFormat = PIPE_FORMAT_NONE;
+ }
}
More information about the mesa-commit
mailing list