[Mesa-dev] [PATCH 25/34] i965/miptree: Allocate mt earlier in update winsys

Jason Ekstrand jason at jlekstrand.net
Tue Jan 31 21:13:20 UTC 2017


On Mon, Jan 23, 2017 at 10:21 PM, Ben Widawsky <ben at bwidawsk.net> wrote:

> Allows us to continue utilizing common miptree creation using __DRIimage
> without creating a new DRIimage (for the intel_process_dri2_buffer()
> case).
>
> This is a bit ugly, but I think it's the best one can do.
>
> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
> Acked-by: Daniel Stone <daniels at collabora.com>
> ---
>  src/mesa/drivers/dri/i965/brw_context.c       | 31
> +++++++++++++++++++++++----
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 17 ++-------------
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.h |  2 +-
>  3 files changed, 30 insertions(+), 20 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c
> b/src/mesa/drivers/dri/i965/brw_context.c
> index d2b3140ea1..ca879004c9 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1646,10 +1646,24 @@ intel_process_dri2_buffer(struct brw_context *brw,
>        return;
>     }
>
> -   if (!intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
> +   struct intel_mipmap_tree *mt = intel_miptree_create_for_bo(brw,
> +                                                              bo,
> +
> intel_rb_format(rb),
> +                                                              0,
> +                                                              drawable->w,
> +                                                              drawable->h,
> +                                                              1,
> +
> buffer->pitch,
> +
> MIPTREE_LAYOUT_FOR_SCANOUT);
> +   if (!mt)
>

Unref the BO here


> +      return;
> +
> +   if (!intel_update_winsys_renderbuffer_miptree(brw, rb, mt,
>                                                   drawable->w, drawable->h,
> -                                                 buffer->pitch))
> +                                                 buffer->pitch)) {
> +      intel_miptree_release(&mt);
>        return;
> +   }
>
>     if (_mesa_is_front_buffer_drawing(fb) &&
>         (buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||
> @@ -1705,10 +1719,19 @@ intel_update_image_buffer(struct brw_context
> *intel,
>     if (last_mt && last_mt->bo == buffer->bo)
>        return;
>
> -   if (!intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
> +   struct intel_mipmap_tree *mt = intel_miptree_create_for_image(intel,
> +                                                                 buffer,
> intel_rb_format(rb), 0,
> +
>  buffer->width, buffer->height,
> +
>  buffer->pitch, MIPTREE_LAYOUT_FOR_SCANOUT);
> +   if (!mt)
> +      return;
> +
> +   if (!intel_update_winsys_renderbuffer_miptree(intel, rb, mt,
>                                                   buffer->width,
> buffer->height,
> -                                                 buffer->pitch))
> +                                                 buffer->pitch)) {
> +      intel_miptree_release(&mt);
>        return;
> +   }
>
>     if (_mesa_is_front_buffer_drawing(fb) &&
>         buffer_type == __DRI_IMAGE_BUFFER_FRONT &&
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 7d08bb6920..095d001eae 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -918,11 +918,10 @@ intel_miptree_create_for_image(struct brw_context
> *intel,
>  bool
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>                                           struct intel_renderbuffer *irb,
> -                                         drm_intel_bo *bo,
> +                                         struct intel_mipmap_tree
> *singlesample_mt,
>                                           uint32_t width, uint32_t height,
>                                           uint32_t pitch)
>  {
> -   struct intel_mipmap_tree *singlesample_mt = NULL;
>     struct intel_mipmap_tree *multisample_mt = NULL;
>     struct gl_renderbuffer *rb = &irb->Base.Base;
>     mesa_format format = rb->Format;
> @@ -933,18 +932,7 @@ intel_update_winsys_renderbuffer_miptree(struct
> brw_context *intel,
>      */
>     assert(_mesa_get_format_base_format(format) == GL_RGB ||
>            _mesa_get_format_base_format(format) == GL_RGBA);
> -
> -   singlesample_mt = intel_miptree_create_for_bo(intel,
> -                                                 bo,
> -                                                 format,
> -                                                 0,
> -                                                 width,
> -                                                 height,
> -                                                 1,
> -                                                 pitch,
> -
>  MIPTREE_LAYOUT_FOR_SCANOUT);
> -   if (!singlesample_mt)
> -      goto fail;
> +   assert(singlesample_mt);
>
>     /* If this miptree is capable of supporting fast color clears, set
>      * mcs_state appropriately to ensure that fast clears will occur.
> @@ -984,7 +972,6 @@ intel_update_winsys_renderbuffer_miptree(struct
> brw_context *intel,
>     return true;
>
>  fail:
> -   intel_miptree_release(&irb->singlesample_mt);
>     intel_miptree_release(&irb->mt);
>     return false;
>  }
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> index 9b4c85e509..1f1166a12b 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> @@ -733,7 +733,7 @@ intel_miptree_create_for_image(struct brw_context
> *intel,
>  bool
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>                                           struct intel_renderbuffer *irb,
> -                                         drm_intel_bo *bo,
> +                                         struct intel_mipmap_tree
> *singlesample_mt,
>                                           uint32_t width, uint32_t height,
>                                           uint32_t pitch);
>
> --
> 2.11.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170131/6575482e/attachment-0001.html>


More information about the mesa-dev mailing list