[Mesa-dev] [PATCH 03/11] renderonly/etnaviv: stop importing resource from renderonly

Philipp Zabel p.zabel at pengutronix.de
Mon Jun 26 10:37:08 UTC 2017


On Fri, 2017-06-23 at 17:50 +0200, Lucas Stach wrote:
> The current way of importing the resource from renderonly after allocation
> is opaque and is taking away control from the driver, which it needs in
> order to implement more advanced scenarios, than the simple linear
> scanout with matching stride alignments.
> 
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> ---
>  src/gallium/auxiliary/renderonly/renderonly.c    | 52 +++++++-----------------
>  src/gallium/auxiliary/renderonly/renderonly.h    | 20 ++++-----
>  src/gallium/drivers/etnaviv/etnaviv_clear_blit.c |  8 ++--
>  src/gallium/drivers/etnaviv/etnaviv_resource.c   | 23 +++++++----
>  src/gallium/drivers/etnaviv/etnaviv_resource.h   |  5 +++
>  5 files changed, 49 insertions(+), 59 deletions(-)
> 
[...]
> diff --git a/src/gallium/auxiliary/renderonly/renderonly.h b/src/gallium/auxiliary/renderonly/renderonly.h
> index 70641c45878a..6a89c29e2ef6 100644
> --- a/src/gallium/auxiliary/renderonly/renderonly.h
> +++ b/src/gallium/auxiliary/renderonly/renderonly.h
> @@ -34,8 +34,6 @@
>  struct renderonly_scanout {
>     uint32_t handle;
>     uint32_t stride;
> -
> -   struct pipe_resource *prime;
>  };
>  
>  struct renderonly {
> @@ -59,7 +57,8 @@ struct renderonly {
>      *   to be done in flush_resource(..) like a resolve to linear.
>      */
>     struct renderonly_scanout *(*create_for_resource)(struct pipe_resource *rsc,
> -                                                     struct renderonly *ro);
> +                                                     struct renderonly *ro,
> +                                                     struct winsys_handle *out_handle);
>     int kms_fd;
>     int gpu_fd;
>  };
> @@ -68,14 +67,13 @@ struct renderonly *
>  renderonly_dup(const struct renderonly *ro);
>  
>  static inline struct renderonly_scanout *
> -renderonly_scanout_for_resource(struct pipe_resource *rsc, struct renderonly *ro)
> +renderonly_scanout_for_resource(struct pipe_resource *rsc,
> +                                struct renderonly *ro,
> +                                struct winsys_handle *out_handle)
>  {
> -   return ro->create_for_resource(rsc, ro);
> +   return ro->create_for_resource(rsc, ro, out_handle);
>  }

This changes the signature for renderonly_scanout_for_resource, which is
also called at:

src/gallium/drivers/vc4/vc4_resource.c:601:                        renderonly_scanout_for_resource(prsc, screen->ro);

since commit 7029ec05e2c7 ("gallium: Add renderonly-based support for
pl111+vc4.").

> -struct renderonly_scanout *
> -renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro);
> -
>  void
>  renderonly_scanout_destroy(struct renderonly_scanout *scanout,
>  			   struct renderonly *ro);
[...]
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 97e0a15597fa..c6e7e98837b6 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -214,8 +214,20 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
>     rsc->bo = bo;
>     rsc->ts_bo = 0; /* TS is only created when first bound to surface */
>  
> -   if (templat->bind & PIPE_BIND_SCANOUT)
> -      rsc->scanout = renderonly_scanout_for_resource(&rsc->base, screen->ro);
> +   if (templat->bind & PIPE_BIND_SCANOUT) {
> +      struct winsys_handle handle;
> +      rsc->scanout = renderonly_scanout_for_resource(&rsc->base, screen->ro,
> +                                                     &handle);
> +      if (!rsc->scanout)
> +         goto free_rsc;
> +
> +      rsc->external = pscreen->resource_from_handle(pscreen, &rsc->base,
> +                                                    &handle,
> +                                                    PIPE_HANDLE_USAGE_WRITE);
> +      close(handle.handle);

Is the handle guaranteed to be DRM_API_HANDLE_TYPE_FD at this point?

> +      if (!rsc->external)
> +         goto free_rsc;
> +   }
>  
>     if (DBG_ENABLED(ETNA_DBG_ZERO)) {
>        void *map = etna_bo_map(bo);
> @@ -310,6 +322,7 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc)
>     list_delinit(&rsc->list);
>  
>     pipe_resource_reference(&rsc->texture, NULL);
> +   pipe_resource_reference(&rsc->external, NULL);
>  
>     FREE(rsc);
>  }
> @@ -375,16 +388,12 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
>        /* Render targets are linear in Xorg but must be tiled
>        * here. It would be nice if dri_drawable_get_format()
>        * set scanout for these buffers too. */
> -      struct etna_resource *tiled;
>  
>        ptiled = etna_resource_create(pscreen, tmpl);
>        if (!ptiled)
>           goto fail;
>  
> -      tiled = etna_resource(ptiled);
> -      tiled->scanout = renderonly_scanout_for_prime(prsc, screen->ro);
> -      if (!tiled->scanout)
> -         goto fail;
> +      etna_resource(ptiled)->external = prsc;
>  
>        return ptiled;
>     }
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> index 3507e5ccecbc..5f563c06adcf 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h
> @@ -75,6 +75,11 @@ struct etna_resource {
>  
>     /* When we are rendering to a texture, we need a differently tiled resource */
>     struct pipe_resource *texture;
> +   /*
> +    * If imported resources have an render/sampler incompatible tiling, we keep
> +    * them as an external resource, which is blitted as needed.
> +    */
> +   struct pipe_resource *external;
>  
>     enum etna_resource_status status;

regards
Philipp



More information about the mesa-dev mailing list