[Mesa-dev] [PATCH 09/18] i965: Stop making a pointless region for DRI2 to just throw it away.

Kristian Høgsberg krh at bitplanet.net
Tue Apr 29 22:00:06 PDT 2014


On Tue, Apr 29, 2014 at 4:34 PM, Eric Anholt <eric at anholt.net> wrote:
> I noticed that we were doing this while changing the DRI3 path to not use
> regions, which involved changing the signature of
> intel_update_winsys_renderbuffer_miptree() this way.

Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

> ---
>  src/mesa/drivers/dri/i965/brw_context.c       | 32 +++++++++++++--------------
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 31 +++++++++++++++-----------
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.h |  4 +++-
>  3 files changed, 36 insertions(+), 31 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index e35cc7e..8c08edb 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -1237,10 +1237,9 @@ intel_query_dri2_buffers(struct brw_context *brw,
>   *    DRI2BufferDepthStencil are handled as special cases.
>   *
>   * \param buffer_name is a human readable name, such as "dri2 front buffer",
> - *        that is passed to intel_region_alloc_for_handle().
> + *        that is passed to drm_intel_bo_gem_create_from_name().
>   *
>   * \see intel_update_renderbuffers()
> - * \see intel_region_alloc_for_handle()
>   */
>  static void
>  intel_process_dri2_buffer(struct brw_context *brw,
> @@ -1249,8 +1248,8 @@ intel_process_dri2_buffer(struct brw_context *brw,
>                            struct intel_renderbuffer *rb,
>                            const char *buffer_name)
>  {
> -   struct intel_region *region = NULL;
>     struct gl_framebuffer *fb = drawable->driverPrivate;
> +   drm_intel_bo *bo;
>
>     if (!rb)
>        return;
> @@ -1287,24 +1286,21 @@ intel_process_dri2_buffer(struct brw_context *brw,
>     }
>
>     intel_miptree_release(&rb->mt);
> -   region = intel_region_alloc_for_handle(brw->intelScreen,
> -                                          buffer->cpp,
> -                                          drawable->w,
> -                                          drawable->h,
> -                                          buffer->pitch,
> -                                          buffer->name,
> -                                          buffer_name);
> -   if (!region) {
> +   bo = drm_intel_bo_gem_create_from_name(brw->bufmgr, buffer_name,
> +                                          buffer->name);
> +   if (!bo) {
>        fprintf(stderr,
> -              "Failed to make region for returned DRI2 buffer "
> -              "(%dx%d, named %d).\n"
> +              "Failed to open BO for returned DRI2 buffer "
> +              "(%dx%d, %s, named %d).\n"
>                "This is likely a bug in the X Server that will lead to a "
>                "crash soon.\n",
> -              drawable->w, drawable->h, buffer->name);
> +              drawable->w, drawable->h, buffer_name, buffer->name);
>        return;
>     }
>
> -   intel_update_winsys_renderbuffer_miptree(brw, rb, region);
> +   intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
> +                                            drawable->w, drawable->h,
> +                                            buffer->pitch);
>
>     if (brw_is_front_buffer_drawing(fb) &&
>         (buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||
> @@ -1315,7 +1311,7 @@ intel_process_dri2_buffer(struct brw_context *brw,
>
>     assert(rb->mt);
>
> -   intel_region_release(&region);
> +   drm_intel_bo_unreference(bo);
>  }
>
>  /**
> @@ -1361,7 +1357,9 @@ intel_update_image_buffer(struct brw_context *intel,
>     if (last_mt && last_mt->region->bo == region->bo)
>        return;
>
> -   intel_update_winsys_renderbuffer_miptree(intel, rb, region);
> +   intel_update_winsys_renderbuffer_miptree(intel, rb, region->bo,
> +                                            region->width, region->height,
> +                                            region->pitch);
>
>     if (brw_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 7a60671..d573033 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -690,16 +690,21 @@ intel_miptree_create_for_bo(struct brw_context *brw,
>  }
>
>  /**
> - * For a singlesample image buffer, this simply wraps the given region with a miptree.
> + * For a singlesample renderbuffer, this simply wraps the given BO with a
> + * miptree.
>   *
> - * For a multisample image buffer, this wraps the given region with
> - * a singlesample miptree, then creates a multisample miptree into which the
> - * singlesample miptree is embedded as a child.
> + * For a multisample renderbuffer, this wraps the window system's
> + * (singlesample) BO with a singlesample miptree attached to the
> + * intel_renderbuffer, then creates a multisample miptree attached to irb->mt
> + * that will contain the actual rendering (which is lazily resolved to
> + * irb->singlesample_mt).
>   */
>  void
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>                                           struct intel_renderbuffer *irb,
> -                                         struct intel_region *region)
> +                                         drm_intel_bo *bo,
> +                                         uint32_t width, uint32_t height,
> +                                         uint32_t pitch)
>  {
>     struct intel_mipmap_tree *singlesample_mt = NULL;
>     struct intel_mipmap_tree *multisample_mt = NULL;
> @@ -714,12 +719,12 @@ intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>            _mesa_get_format_base_format(format) == GL_RGBA);
>
>     singlesample_mt = intel_miptree_create_for_bo(intel,
> -                                                 region->bo,
> +                                                 bo,
>                                                   format,
>                                                   0,
> -                                                 region->width,
> -                                                 region->height,
> -                                                 region->pitch);
> +                                                 width,
> +                                                 height,
> +                                                 pitch);
>     if (!singlesample_mt)
>        goto fail;
>
> @@ -741,12 +746,12 @@ intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>        irb->singlesample_mt = singlesample_mt;
>
>        if (!irb->mt ||
> -          irb->mt->logical_width0 != region->width ||
> -          irb->mt->logical_height0 != region->height) {
> +          irb->mt->logical_width0 != width ||
> +          irb->mt->logical_height0 != height) {
>           multisample_mt = intel_miptree_create_for_renderbuffer(intel,
>                                                                  format,
> -                                                                region->width,
> -                                                                region->height,
> +                                                                width,
> +                                                                height,
>                                                                  num_samples);
>           if (!multisample_mt)
>              goto fail;
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> index d4f9575..d9b7d8b 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
> @@ -483,7 +483,9 @@ intel_miptree_create_for_bo(struct brw_context *brw,
>  void
>  intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
>                                           struct intel_renderbuffer *irb,
> -                                         struct intel_region *region);
> +                                         drm_intel_bo *bo,
> +                                         uint32_t width, uint32_t height,
> +                                         uint32_t pitch);
>
>  /**
>   * Create a miptree appropriate as the storage for a non-texture renderbuffer.
> --
> 1.9.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list