[Mesa-dev] [PATCH 6/6] st/mesa: skip any extra handling of YUV textures if driver supports them

Marek Olšák maraeo at gmail.com
Tue Apr 16 15:03:32 UTC 2019


On Fri, Apr 12, 2019 at 1:33 PM Lucas Stach <l.stach at pengutronix.de> wrote:

> If the driver provides native support for YUV textures we can skip
> adding additional samplers and re-writing the shaders.
>
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> ---
>  src/mesa/state_tracker/st_atom_sampler.c |  6 ++++++
>  src/mesa/state_tracker/st_atom_texture.c |  6 ++++++
>  src/mesa/state_tracker/st_program.h      |  6 ++++++
>  src/mesa/state_tracker/st_sampler_view.c | 21 +++++++++++++--------
>  4 files changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom_sampler.c
> b/src/mesa/state_tracker/st_atom_sampler.c
> index 27e4da315817..9def70c9432a 100644
> --- a/src/mesa/state_tracker/st_atom_sampler.c
> +++ b/src/mesa/state_tracker/st_atom_sampler.c
> @@ -303,10 +303,16 @@ update_shader_samplers(struct st_context *st,
>        struct st_texture_object *stObj =
>              st_get_texture_object(st->ctx, prog, unit);
>        struct pipe_sampler_state *sampler = samplers + unit;
> +      struct pipe_screen *pscreen = st->pipe->screen;
>
>        if (!stObj)
>           continue;
>
> +      if (pscreen->is_format_supported(pscreen, st_get_view_format(stObj),
> +                                       PIPE_TEXTURE_2D, 0, 0,
> +                                       PIPE_BIND_SAMPLER_VIEW))
> +         continue;
>

Can you call is_format_supported at texture initialization?
is_format_supported can be expensive.


> +
>        switch (st_get_view_format(stObj)) {
>        case PIPE_FORMAT_NV12:
>           /* we need one additional sampler: */
> diff --git a/src/mesa/state_tracker/st_atom_texture.c
> b/src/mesa/state_tracker/st_atom_texture.c
> index ce7755f0c588..df84a472e722 100644
> --- a/src/mesa/state_tracker/st_atom_texture.c
> +++ b/src/mesa/state_tracker/st_atom_texture.c
> @@ -174,11 +174,17 @@ update_textures(struct st_context *st,
>        GLuint extra = 0;
>        struct st_texture_object *stObj =
>              st_get_texture_object(st->ctx, prog, unit);
> +      struct pipe_screen *pscreen = st->pipe->screen;
>        struct pipe_sampler_view tmpl;
>
>        if (!stObj)
>           continue;
>
> +      if (pscreen->is_format_supported(pscreen, st_get_view_format(stObj),
> +                                       sampler_views[unit]->target, 0, 0,
> +                                       PIPE_BIND_SAMPLER_VIEW))
>

Same here.

+         continue;
> +
>        /* use original view as template: */
>        tmpl = *sampler_views[unit];
>
> diff --git a/src/mesa/state_tracker/st_program.h
> b/src/mesa/state_tracker/st_program.h
> index f67ea5eb2087..bc5f3e3d9642 100644
> --- a/src/mesa/state_tracker/st_program.h
> +++ b/src/mesa/state_tracker/st_program.h
> @@ -67,6 +67,12 @@ st_get_external_sampler_key(struct st_context *st,
> struct gl_program *prog)
>        unsigned unit = u_bit_scan(&mask);
>        struct st_texture_object *stObj =
>              st_get_texture_object(st->ctx, prog, unit);
> +      struct pipe_screen *pscreen = st->pipe->screen;
> +
> +      if (pscreen->is_format_supported(pscreen, st_get_view_format(stObj),
> +                                       PIPE_TEXTURE_2D, 0, 0,
> +                                       PIPE_BIND_SAMPLER_VIEW))
>

Same here.

+         continue;
>
>        switch (st_get_view_format(stObj)) {
>        case PIPE_FORMAT_NV12:
> diff --git a/src/mesa/state_tracker/st_sampler_view.c
> b/src/mesa/state_tracker/st_sampler_view.c
> index eb97f2bb6b7d..30dfa20af6b5 100644
> --- a/src/mesa/state_tracker/st_sampler_view.c
> +++ b/src/mesa/state_tracker/st_sampler_view.c
> @@ -471,6 +471,7 @@ get_sampler_view_format(struct st_context *st,
>                          const struct st_texture_object *stObj,
>                          bool srgb_skip_decode)
>  {
> +   struct pipe_screen *pscreen = st->pipe->screen;
>     enum pipe_format format;
>
>     GLenum baseFormat = _mesa_base_tex_image(&stObj->base)->_BaseFormat;
> @@ -489,15 +490,19 @@ get_sampler_view_format(struct st_context *st,
>     if (srgb_skip_decode)
>        format = util_format_linear(format);
>
> -   /* Use R8_UNORM for video formats */
> -   switch (format) {
> -   case PIPE_FORMAT_NV12:
> -   case PIPE_FORMAT_IYUV:
> -      format = PIPE_FORMAT_R8_UNORM;
> -      break;
> -   default:
> -      break;
> +   if (!pscreen->is_format_supported(pscreen, format, PIPE_TEXTURE_2D, 0,
> 0,
> +                                     PIPE_BIND_SAMPLER_VIEW)) {
>

Same here.

Marek

+      /* Use R8_UNORM for video formats */
> +      switch (format) {
> +      case PIPE_FORMAT_NV12:
> +      case PIPE_FORMAT_IYUV:
> +         format = PIPE_FORMAT_R8_UNORM;
> +         break;
> +      default:
> +         break;
> +      }
>     }
> +
>     return format;
>  }
>
> --
> 2.20.1
>
> _______________________________________________
> 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/20190416/ccfc75bc/attachment-0001.html>


More information about the mesa-dev mailing list