[PATCH 09/11] etnaviv: fill in modifier in etna_resource_get_handle

Wladimir J. van der Laan laanwj at gmail.com
Wed Jun 28 17:39:29 UTC 2017


On Fri, Jun 23, 2017 at 05:50:26PM +0200, Lucas Stach wrote:
> This allows the state trackers to know the tiling layout of the
> resource and pass this through the various userspace protocols.

> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>

Comment inline.

Reviewed-by: Wladimir J. van der Laan <laanwj at gmail.com>

> ---
>  src/gallium/drivers/etnaviv/etnaviv_resource.c | 30 +++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> index 66d96aacbbe7..df5a5700bc19 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
> @@ -464,6 +464,24 @@ fail:
>     return NULL;
>  }
>  
> +static uint64_t layout_to_modifier(unsigned int layout)
> +{
> +   switch (layout) {
> +   case ETNA_LAYOUT_TILED:
> +      return DRM_FORMAT_MOD_VIVANTE_TILED;
> +   case ETNA_LAYOUT_SUPER_TILED:
> +      return DRM_FORMAT_MOD_VIVANTE_SUPER_TILED;
> +   case ETNA_LAYOUT_MULTI_TILED:
> +      return DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED;
> +   case ETNA_LAYOUT_MULTI_SUPERTILED:
> +      return DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED;
> +   case ETNA_LAYOUT_LINEAR:
> +      return DRM_FORMAT_MOD_LINEAR;
> +   default:
> +      return DRM_FORMAT_MOD_INVALID;
> +   }
> +}
> +

It would make sense to put this function after modifier_to_layout
as introduced in 07/11: in the rare case when a tiling layout is added,
both need to be updated, after all. 

>  static boolean
>  etna_resource_get_handle(struct pipe_screen *pscreen,
>                           struct pipe_context *pctx,
> @@ -472,10 +490,20 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
>  {
>     struct etna_resource *rsc = etna_resource(prsc);
>     handle->stride = rsc->levels[0].stride;
> +   handle->modifier = layout_to_modifier(rsc->layout);
>  
>     if (handle->type == DRM_API_HANDLE_TYPE_KMS &&
> -       renderonly_get_handle(rsc->scanout, handle))
> +       renderonly_get_handle(rsc->scanout, handle)) {
> +      /*
> +       * If we export the renderonly handle and the scanout BO is attached as
> +       * an external resource we need to fill in the modifier from the external
> +       * resource.
> +       */
> +      if (rsc->external)
> +         handle->modifier = layout_to_modifier(etna_resource(rsc->external)->layout);
> +
>        return TRUE;
> +   }
>  
>     if (handle->type == DRM_API_HANDLE_TYPE_SHARED) {
>        return etna_bo_get_name(rsc->bo, &handle->handle) == 0;
> -- 
> 2.11.0
> 
> _______________________________________________
> etnaviv mailing list
> etnaviv at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv


More information about the etnaviv mailing list