[Mesa-dev] [PATCH 12/30] i965/miptree: Allocate mt earlier in update winsys
Pohjolainen, Topi
topi.pohjolainen at gmail.com
Mon Jun 26 18:36:34 UTC 2017
On Fri, Jun 16, 2017 at 03:41:34PM -0700, Jason Ekstrand wrote:
> From: Ben Widawsky <ben at bwidawsk.net>
>
> Allows us to continue utilizing common miptree creation using __DRIimage
> without creating a new DRIimage (for the intel_process_dri2_buffer()
> case).
Just looking this patch locally I don't really understand this commit
message. I'll keep on reading if the answer is later in the series..
>
> This is a bit ugly, but I think it's the best one can do.
>
> v2: This patch let's us remove the temporary no_aux variable since mt
> allocation should work correctly now.
> Unref the BO is miptree creation fails (Jason)
> v3: Rebase (Daniel)
>
> Cc: Jason Ekstrand <jason at jlekstrand.net>
> 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 | 37 ++++++++++++++++++++++++---
> src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 16 ++----------
> src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 2 +-
> 3 files changed, 37 insertions(+), 18 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index e963e13..f57045f 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1611,10 +1611,26 @@ 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) {
> + brw_bo_unreference(bo);
> + return;
> + }
> +
> + if (!intel_update_winsys_renderbuffer_miptree(brw, rb, mt,
> drawable->w, drawable->h,
> buffer->pitch)) {
> brw_bo_unreference(bo);
> + intel_miptree_release(&mt);
> return;
> }
>
> @@ -1672,10 +1688,25 @@ 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_bo(intel,
> + buffer->bo,
> + intel_rb_format(rb),
> + 0,
> + buffer->width,
> + buffer->height,
> + 1,
> + 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 893f13e..08c13fc 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -960,11 +960,10 @@ intel_miptree_create_for_dri_image(struct brw_context *brw,
> bool
> intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
> struct intel_renderbuffer *irb,
> - struct brw_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;
> @@ -976,17 +975,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 (num_samples == 0) {
> intel_miptree_release(&irb->mt);
> @@ -1016,7 +1005,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 04aab2d..7b702a3 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> @@ -704,7 +704,7 @@ intel_miptree_create_for_dri_image(struct brw_context *brw,
> bool
> intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
> struct intel_renderbuffer *irb,
> - struct brw_bo *bo,
> + struct intel_mipmap_tree *singlesample_mt,
> uint32_t width, uint32_t height,
> uint32_t pitch);
>
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list