From 59b4146a5dbeb108b53fc9c4132095e264ba04be Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 10 Feb 2010 19:00:35 -0500 Subject: st/dri, st/xorg: fix buffers that have attachements of different depth we actually need to specify the formats for different attachements, otherwise if the color buffer is 24bpp and the app asks for 16bpp depth buffer than we end up fetching the depth from the drawable which is 24bpp and end up creating the wrong depth buffer. use the new getBuffersWithFormat extension to pass the depth correctly. --- src/gallium/state_trackers/xorg/xorg_dri2.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/gallium/state_trackers/xorg/xorg_dri2.c') diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 7457fe1c6d..5b67392435 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -103,14 +103,26 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form pipe_texture_reference(&tex, exa_priv->depth_stencil_tex); else { struct pipe_texture template; + unsigned depthBits = (format != 0) ? format : pDraw->depth; memset(&template, 0, sizeof(template)); template.target = PIPE_TEXTURE_2D; - if (buffer->attachment == DRI2BufferDepth) - template.format = ms->ds_depth_bits_last ? - PIPE_FORMAT_X8Z24_UNORM : PIPE_FORMAT_Z24X8_UNORM; - else - template.format = ms->ds_depth_bits_last ? - PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM; + if (buffer->attachment == DRI2BufferDepth) { + switch(depthBits) { + case 16: + template.format = PIPE_FORMAT_Z16_UNORM; + break; + case 32: + template.format = PIPE_FORMAT_Z32_UNORM; + break; + default: + template.format = ms->ds_depth_bits_last ? + PIPE_FORMAT_X8Z24_UNORM : PIPE_FORMAT_Z24X8_UNORM; + break; + } + } else { + template.format = ms->ds_depth_bits_last ? + PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM; + } template.width0 = pDraw->width; template.height0 = pDraw->height; template.depth0 = 1; -- cgit v1.2.3