[Mesa-dev] [PATCH 1/3] mesa: Identify packed depth/stencil buffers using the Format field.

Brian Paul brianp at vmware.com
Thu Aug 26 07:02:25 PDT 2010


On 08/25/2010 07:14 AM, Nick Bowler wrote:
> Intel sometimes uses packed depth/stencil buffers even when only a depth
> buffer or only a stencil buffer was requested.  Common code currently
> uses the _BaseFormat field to determine whether a depth/stencil wrapper
> is necessary.  But unless the user explicitly requested a packed
> depth/stencil buffer, the _BaseFormat field does not encode this
> information, and the required wrappers are not created.
>
> The problem was introduced by commit 45e76d2665b38b ("mesa: remove a
> bunch of gl_renderbuffer fields"), which killed off the _ActualFormat
> field upon which the decision to create a wrapper used to be made.  This
> patch changes the logic to use the Format field instead, which is more
> like the old code.
>
> Fixes fdo bug 27590.
>
> Signed-off-by: Nick Bowler<nbowler at draconx.ca>
> ---
>   src/mesa/main/framebuffer.c |   18 ++++++++++++++++--
>   1 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
> index e0aac26..869401d 100644
> --- a/src/mesa/main/framebuffer.c
> +++ b/src/mesa/main/framebuffer.c
> @@ -588,6 +588,20 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
>      compute_depth_max(fb);
>   }
>
> +/**
> + * Determine if a renderbuffer is a packed depth/stencil buffer.
> + */
> +static int rb_is_depth_stencil(struct gl_renderbuffer *rb)
> +{
> +   if (rb->Format == MESA_FORMAT_Z24_S8
> +       || rb->Format == MESA_FORMAT_Z24_X8
> +       || rb->Format == MESA_FORMAT_S8_Z24
> +       || rb->Format == MESA_FORMAT_X8_Z24)
> +      return 1;
> +
> +   return 0;
> +}
> +

Let's rewrite this as a format helper function and put it in formats.c:

GLboolean
_mesa_is_format_packed_depth_stencil(gl_format format)


Then pass depthRb->Format to it.



>   /**
>    * Update the framebuffer's _DepthBuffer field using the renderbuffer
> @@ -611,7 +625,7 @@ _mesa_update_depth_buffer(GLcontext *ctx,
>
>      depthRb = fb->Attachment[attIndex].Renderbuffer;
>
> -   if (depthRb&&  depthRb->_BaseFormat == GL_DEPTH_STENCIL) {
> +   if (depthRb&&  rb_is_depth_stencil(depthRb)) {
>         /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
>         if (!fb->_DepthBuffer
>             || fb->_DepthBuffer->Wrapped != depthRb
> @@ -652,7 +666,7 @@ _mesa_update_stencil_buffer(GLcontext *ctx,
>
>      stencilRb = fb->Attachment[attIndex].Renderbuffer;
>
> -   if (stencilRb&&  stencilRb->_BaseFormat == GL_DEPTH_STENCIL) {
> +   if (stencilRb&&  rb_is_depth_stencil(stencilRb)) {
>         /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
>         if (!fb->_StencilBuffer
>             || fb->_StencilBuffer->Wrapped != stencilRb


-Brian


More information about the mesa-dev mailing list