diff options
author | Brian Paul <[email protected]> | 2010-03-23 08:58:09 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-03-23 08:58:12 -0600 |
commit | 4ceeb1307a018f426784620d3376f9f1ea07e53b (patch) | |
tree | d9a8e2c2593ac39c1c297735bc55291387cc2fca /src/gallium/state_trackers | |
parent | 2ded27b2f0a7b01f5db77ea9a2a25df5baa876b3 (diff) |
st/glx: better format selection in xmesa_choose_z_stencil_format()
This is a back-port of commit ef2664da6c4db1b52ef351641e3ee949b87f9c7b
from master.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | 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 217bdeff75e..e8524a21c21 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; + } } |