[Mesa-dev] [PATCH v3 1/4] r600g/radeonsi: send endian info to format translation functions

Marek Olšák maraeo at gmail.com
Fri Apr 22 19:03:38 UTC 2016


On Thu, Apr 21, 2016 at 4:39 PM, Oded Gabbay <oded.gabbay at gmail.com> wrote:
> Because r600 GPUs can't do swap in their DB unit, we need to disable
> endianess swapping for textures that are handled by DB.
>
> There are four format translation functions in r600g driver:
>
> - r600_translate_texformat
> - r600_colorformat_endian_swap
> - r600_translate_colorformat
> - r600_translate_colorswap
>
> This patch adds a new parameters to those functions, called
> "do_endian_swap". When running in a big-endian machine, the calling
> functions will check whether the texture/color is handled by DB -
> "rtex->is_depth && !rtex->is_flushing_texture" - and if so, they will
> send FALSE through this parameter. Otherwise, they will send TRUE.
>
> The translation functions, in specific cases, will look at this parameter
> and configure the swapping accordingly.
>
> Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
> ---
>  src/gallium/drivers/r600/evergreen_state.c    | 42 ++++++++++++++++++---------
>  src/gallium/drivers/r600/r600_pipe.h          |  8 +++--
>  src/gallium/drivers/r600/r600_state.c         | 27 +++++++++++------
>  src/gallium/drivers/r600/r600_state_common.c  |  8 +++--
>  src/gallium/drivers/radeon/r600_pipe_common.h |  2 +-
>  src/gallium/drivers/radeon/r600_texture.c     |  4 +--
>  src/gallium/drivers/radeonsi/si_state.c       |  4 +--
>  7 files changed, 62 insertions(+), 33 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
> index 2ad9e3e..8ff40aa 100644
> --- a/src/gallium/drivers/r600/evergreen_state.c
> +++ b/src/gallium/drivers/r600/evergreen_state.c
> @@ -213,13 +213,14 @@ static uint32_t r600_translate_dbformat(enum pipe_format format)
>
>  static bool r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
>  {
> -       return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0U;
> +       return r600_translate_texformat(screen, format, NULL, NULL, NULL,
> +                                   FALSE) != ~0U;
>  }
>
>  static bool r600_is_colorbuffer_format_supported(enum chip_class chip, enum pipe_format format)
>  {
> -       return r600_translate_colorformat(chip, format) != ~0U &&
> -               r600_translate_colorswap(format) != ~0U;
> +       return r600_translate_colorformat(chip, format, FALSE) != ~0U &&
> +               r600_translate_colorswap(format, FALSE) != ~0U;
>  }
>
>  static bool r600_is_zs_format_supported(enum pipe_format format)
> @@ -677,6 +678,7 @@ evergreen_create_sampler_view_custom(struct pipe_context *ctx,
>         unsigned base_level, first_level, last_level;
>         unsigned dim, last_layer;
>         uint64_t va;
> +       bool do_endian_swap = FALSE;
>
>         if (!view)
>                 return NULL;
> @@ -722,16 +724,19 @@ evergreen_create_sampler_view_custom(struct pipe_context *ctx,
>                 }
>         }
>
> +       if (R600_BIG_ENDIAN)
> +               do_endian_swap = !(tmp->is_depth && !tmp->is_flushing_texture);
> +
>         format = r600_translate_texformat(ctx->screen, pipe_format,
>                                           swizzle,
> -                                         &word4, &yuv_format);
> +                                         &word4, &yuv_format, do_endian_swap);
>         assert(format != ~0);
>         if (format == ~0) {
>                 FREE(view);
>                 return NULL;
>         }
>
> -       endian = r600_colorformat_endian_swap(format);
> +       endian = r600_colorformat_endian_swap(format, do_endian_swap);
>
>         base_level = 0;
>         first_level = state->u.tex.first_level;
> @@ -942,15 +947,22 @@ void evergreen_init_color_surface_rat(struct r600_context *rctx,
>                                         struct r600_surface *surf)
>  {
>         struct pipe_resource *pipe_buffer = surf->base.texture;
> -       unsigned format = r600_translate_colorformat(rctx->b.chip_class,
> -                                                    surf->base.format);
> -       unsigned endian = r600_colorformat_endian_swap(format);
> -       unsigned swap = r600_translate_colorswap(surf->base.format);
> +       struct r600_texture *rtex = (struct r600_texture*)surf->base.texture;
>         unsigned block_size =
>                 align(util_format_get_blocksize(pipe_buffer->format), 4);
>         unsigned pitch_alignment =
>                 MAX2(64, rctx->screen->b.info.pipe_interleave_bytes / block_size);
>         unsigned pitch = align(pipe_buffer->width0, pitch_alignment);
> +       unsigned format, endian, swap;
> +       bool do_endian_swap = FALSE;
> +
> +       if (R600_BIG_ENDIAN)
> +               do_endian_swap = !(rtex->is_depth && !rtex->is_flushing_texture);
> +
> +       format = r600_translate_colorformat(rctx->b.chip_class, surf->base.format,
> +                                                     do_endian_swap);
> +       endian = r600_colorformat_endian_swap(format, do_endian_swap);
> +       swap = r600_translate_colorswap(surf->base.format, do_endian_swap);
>
>         surf->cb_color_base = r600_resource(pipe_buffer)->gpu_address >> 8;
>

You can drop all changes to evergreen_init_color_surface_rat and just
set true or false statically. The function is only used by compute and
can't get DB surfaces.

Marek


More information about the mesa-dev mailing list