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

Jordan Justen jordan.l.justen at intel.com
Thu Nov 21 14:17:42 PST 2013


On Wed, 2013-11-20 at 14:29 -0800, Paul Berry 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.
> 
> This patch replaces the gl_framebuffer::Layered boolean with a
> gl_framebuffer::NumLayers integer, which is 0 if the framebuffer is
> not layered, and equal to the number of layers otherwise.
> 
> v2: Remove gl_framebuffer::Layered and make gl_framebuffer::NumLayers
> always have a defined value.  Fix factor of 6 error in the number of
> layers in a cube map array.
> 
> Cc: "10.0" <mesa-stable at lists.freedesktop.org>
> 
> Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  src/mesa/drivers/dri/i965/brw_wm_surface_state.c |  2 +-
>  src/mesa/drivers/dri/i965/gen6_clip_state.c      |  2 +-
>  src/mesa/drivers/dri/i965/gen7_misc_state.c      |  2 +-
>  src/mesa/main/fbobject.c                         | 13 +++++++++++--
>  src/mesa/main/mtypes.h                           |  8 +++++++-
>  5 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index 662c975..fd6954b 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -701,7 +701,7 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw)
>        for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
>  	 if (intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i])) {
>  	    brw->vtbl.update_renderbuffer_surface(brw, ctx->DrawBuffer->_ColorDrawBuffers[i],
> -                                                  ctx->DrawBuffer->Layered, i);
> +                                                  ctx->DrawBuffer->NumLayers > 0, i);
>  	 } else {
>  	    brw->vtbl.update_null_renderbuffer_surface(brw, i);
>  	 }
> diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c
> index 03d0f90..37a39b8 100644
> --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c
> @@ -121,7 +121,7 @@ upload_clip_state(struct brw_context *brw)
>  	     dw2);
>     OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
>               U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
> -             (fb->Layered ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX));
> +             (fb->NumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX));
>     ADVANCE_BATCH();
>  }
>  
> diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c b/src/mesa/drivers/dri/i965/gen7_misc_state.c
> index 3f3833e..4251949 100644
> --- a/src/mesa/drivers/dri/i965/gen7_misc_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c
> @@ -81,7 +81,7 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
>        break;
>     }
>  
> -   if (fb->Layered || !irb) {
> +   if (fb->NumLayers > 0 || !irb) {
>        min_array_element = 0;
>     } else if (irb->mt->num_samples > 1) {
>        /* Convert physical layer to logical layer. */
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 9dd7161..e8cf274 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,14 @@ _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) {
> +         if (att_tex_target == GL_TEXTURE_CUBE_MAP)
> +            att_layer_count = 6;
> +         else
> +            att_layer_count = att->Renderbuffer->Depth;
> +      } else {
> +         att_layer_count = 0;
> +      }

This seems like a separate change. I'll leave it up to you
whether you bother moving it out or not.

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>




More information about the mesa-stable mailing list