[Mesa-stable] [Mesa-dev] [PATCH 1/5] mesa: Track number of layers in layered framebuffers.

Marek Olšák maraeo at gmail.com
Wed Nov 20 03:18:03 PST 2013


On Wed, Nov 20, 2013 at 5:47 AM, Paul Berry <stereotype441 at gmail.com> wrote:
> In order to properly clear layered framebuffers, we need to know how
> many layers they have.  The easiest way to do this is to record it in
> the gl_framebuffer struct when we check framebuffer completeness, just
> like we do for the Layered boolean.
>
> Cc: "10.0" <mesa-stable at lists.freedesktop.org>
> ---
>  src/mesa/main/fbobject.c | 21 ++++++++++++++++++++-
>  src/mesa/main/mtypes.h   |  6 ++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 9dd7161..3b84f6a 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -905,6 +905,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
>        struct gl_renderbuffer_attachment *att;
>        GLenum f;
>        gl_format attFormat;
> +      GLenum att_tex_target = GL_NONE;
>
>        /*
>         * XXX for ARB_fbo, only check color buffers that are named by
> @@ -945,6 +946,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
>         */
>        if (att->Type == GL_TEXTURE) {
>           const struct gl_texture_image *texImg = att->Renderbuffer->TexImage;
> +         att_tex_target = att->Texture->Target;
>           minWidth = MIN2(minWidth, texImg->Width);
>           maxWidth = MAX2(maxWidth, texImg->Width);
>           minHeight = MIN2(minHeight, texImg->Height);
> @@ -1057,7 +1059,21 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
>        }
>
>        /* Check that layered rendering is consistent. */
> -      att_layer_count = att->Layered ? att->Renderbuffer->Depth : 0;
> +      if (att->Layered) {
> +         switch (att_tex_target) {
> +         case GL_TEXTURE_CUBE_MAP:
> +            att_layer_count = 6;
> +            break;
> +         case GL_TEXTURE_CUBE_MAP_ARRAY:
> +            att_layer_count = att->Renderbuffer->Depth * 6;
> +            break;
> +         default:
> +            att_layer_count = att->Renderbuffer->Depth;
> +            break;
> +         }
> +      } else {
> +         att_layer_count = 0;
> +      }
>        if (!layer_count_valid) {
>           layer_count = att_layer_count;
>           layer_count_valid = true;
> @@ -1074,6 +1090,9 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
>     }
>
>     fb->Layered = layer_count > 0;
> +   if (layer_count > 0) {
> +      fb->NumLayers = layer_count;
> +   }
>
>     if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
>        /* Check that all DrawBuffers are present */
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 8801d6f..699e6e6 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2996,6 +2996,12 @@ struct gl_framebuffer
>
>     GLboolean Layered;
>
> +   /**
> +    * If Layered is true, the number of layers in the framebuffer.  For cube
> +    * maps and cube map arrays, this includes the factor of 6.
> +    */
> +   GLuint NumLayers;
> +

I think the cube map array size is already premultiplied by 6.

Marek


More information about the mesa-stable mailing list