[Mesa-dev] [PATCH 123/140] radeonsi/gfx9: set/validate GFX9 BO metadata

Mike Lothian mike at fireburn.co.uk
Thu Mar 30 13:58:33 UTC 2017


This patch gives me a warning

/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/gallium/drivers/radeon/r600_texture.c:
In function ‘r600_texture_from_handle’:
/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/gallium/drivers/radeon/r600_texture.c:1441:28:
warning: unused variable ‘gfx9’ [-Wunused-variable]
   struct gfx9_surf_layout *gfx9 = &surface.u.gfx9;
                            ^~~~


On Mon, 20 Mar 2017 at 22:54 Marek Olšák <maraeo at gmail.com> wrote:

> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  src/gallium/drivers/radeon/r600_texture.c  | 20 +++++++++++++++++++-
>  src/gallium/drivers/radeon/radeon_winsys.h |  5 +++++
>  2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_texture.c
> b/src/gallium/drivers/radeon/r600_texture.c
> index 2e66dd0..df260b6 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -291,6 +291,7 @@ static void r600_texture_init_metadata(struct
> r600_common_screen *rscreen,
>         memset(metadata, 0, sizeof(*metadata));
>
>         if (rscreen->chip_class >= GFX9) {
> +               metadata->u.gfx9.swizzle_mode =
> surface->u.gfx9.surf.swizzle_mode;
>         } else {
>                 metadata->u.legacy.microtile =
> surface->u.legacy.level[0].mode >= RADEON_SURF_MODE_1D ?
>                                            RADEON_LAYOUT_TILED :
> RADEON_LAYOUT_LINEAR;
> @@ -1345,6 +1346,7 @@ static struct pipe_resource
> *r600_texture_from_handle(struct pipe_screen *screen
>         int r;
>         struct radeon_bo_metadata metadata = {};
>         struct r600_texture *rtex;
> +       bool is_scanout;
>
>         /* Support only 2D textures without mipmaps */
>         if ((templ->target != PIPE_TEXTURE_2D && templ->target !=
> PIPE_TEXTURE_RECT) ||
> @@ -1358,6 +1360,13 @@ static struct pipe_resource
> *r600_texture_from_handle(struct pipe_screen *screen
>         rscreen->ws->buffer_get_metadata(buf, &metadata);
>
>         if (rscreen->chip_class >= GFX9) {
> +               if (metadata.u.gfx9.swizzle_mode > 0)
> +                       array_mode = RADEON_SURF_MODE_2D;
> +               else
> +                       array_mode = RADEON_SURF_MODE_LINEAR_ALIGNED;
> +
> +               is_scanout = metadata.u.gfx9.swizzle_mode == 0 ||
> +                            metadata.u.gfx9.swizzle_mode % 4 == 2;
>         } else {
>                 surface.u.legacy.pipe_config =
> metadata.u.legacy.pipe_config;
>                 surface.u.legacy.bankw = metadata.u.legacy.bankw;
> @@ -1372,10 +1381,12 @@ static struct pipe_resource
> *r600_texture_from_handle(struct pipe_screen *screen
>                         array_mode = RADEON_SURF_MODE_1D;
>                 else
>                         array_mode = RADEON_SURF_MODE_LINEAR_ALIGNED;
> +
> +               is_scanout = metadata.u.legacy.scanout;
>         }
>
>         r = r600_init_surface(rscreen, &surface, templ, array_mode, stride,
> -                             offset, true, metadata.u.legacy.scanout,
> false, false);
> +                             offset, true, is_scanout, false, false);
>         if (r) {
>                 return NULL;
>         }
> @@ -1390,6 +1401,13 @@ static struct pipe_resource
> *r600_texture_from_handle(struct pipe_screen *screen
>         if (rscreen->apply_opaque_metadata)
>                 rscreen->apply_opaque_metadata(rscreen, rtex, &metadata);
>
> +       /* Validate that addrlib arrived at the same surface parameters. */
> +       if (rscreen->chip_class >= GFX9) {
> +               struct gfx9_surf_layout *gfx9 = &surface.u.gfx9;
> +
> +               assert(metadata.u.gfx9.swizzle_mode ==
> gfx9->surf.swizzle_mode);
> +       }
> +
>         return &rtex->resource.b.b;
>  }
>
> diff --git a/src/gallium/drivers/radeon/radeon_winsys.h
> b/src/gallium/drivers/radeon/radeon_winsys.h
> index b3c7608..7839170 100644
> --- a/src/gallium/drivers/radeon/radeon_winsys.h
> +++ b/src/gallium/drivers/radeon/radeon_winsys.h
> @@ -250,6 +250,11 @@ struct radeon_bo_metadata {
>              unsigned                stride;
>              bool                    scanout;
>          } legacy;
> +
> +        struct {
> +            /* surface flags */
> +            unsigned swizzle_mode:5;
> +        } gfx9;
>      } u;
>
>      /* Additional metadata associated with the buffer, in bytes.
> --
> 2.7.4
>
> _______________________________________________
> 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/20170330/5c165414/attachment-0001.html>


More information about the mesa-dev mailing list