[Mesa-dev] [PATCH] r300g: set endian controls on big endian
Aaron Watry
awatry at gmail.com
Mon Apr 25 15:40:39 UTC 2016
On Sun, Apr 24, 2016 at 6:27 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/gallium/drivers/r300/r300_reg.h | 20 +++++++----------
> src/gallium/drivers/r300/r300_texture.c | 38
> ++++++++++++++++++++++++++++++---
> 2 files changed, 43 insertions(+), 15 deletions(-)
>
> diff --git a/src/gallium/drivers/r300/r300_reg.h
> b/src/gallium/drivers/r300/r300_reg.h
> index 9c373c5..9c93b84 100644
> --- a/src/gallium/drivers/r300/r300_reg.h
> +++ b/src/gallium/drivers/r300/r300_reg.h
> @@ -1700,10 +1700,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
> #define R300_TX_OFFSET_6 0x4558
> #define R300_TX_OFFSET_7 0x455C
>
> -# define R300_TXO_ENDIAN_NO_SWAP (0 << 0)
> -# define R300_TXO_ENDIAN_BYTE_SWAP (1 << 0)
> -# define R300_TXO_ENDIAN_WORD_SWAP (2 << 0)
> -# define R300_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
> +# define R300_TXO_ENDIAN(x) ((x) << 0)
> # define R300_TXO_MACRO_TILE_LINEAR (0 << 2)
> # define R300_TXO_MACRO_TILE_TILED (1 << 2)
> # define R300_TXO_MACRO_TILE(x) ((x) << 2)
> @@ -2418,10 +2415,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
> # define R300_COLOR_MICROTILE_ENABLE (1 << 17)
> # define R300_COLOR_MICROTILE_ENABLE_SQUARE (2 << 17) /* Only
> available in 16-bit */
> # define R300_COLOR_MICROTILE(x) ((x) << 17)
> -# define R300_COLOR_ENDIAN_NO_SWAP (0 << 19)
> -# define R300_COLOR_ENDIAN_WORD_SWAP (1 << 19)
> -# define R300_COLOR_ENDIAN_DWORD_SWAP (2 << 19)
> -# define R300_COLOR_ENDIAN_HALF_DWORD_SWAP (3 << 19)
> +# define R300_COLOR_ENDIAN(x) ((x) << 19)
> # define R500_COLOR_FORMAT_ARGB10101010 (0 << 21)
> # define R500_COLOR_FORMAT_UV1010 (1 << 21)
> # define R500_COLOR_FORMAT_CI8 (2 << 21) /* 2D only */
> @@ -2693,10 +2687,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
> # define R300_DEPTHMICROTILE_TILED (1 << 17)
> # define R300_DEPTHMICROTILE_TILED_SQUARE (2 << 17)
> # define R300_DEPTHMICROTILE(x) ((x) << 17)
> -# define R300_DEPTHENDIAN_NO_SWAP (0 << 18)
> -# define R300_DEPTHENDIAN_WORD_SWAP (1 << 18)
> -# define R300_DEPTHENDIAN_DWORD_SWAP (2 << 18)
> -# define R300_DEPTHENDIAN_HALF_DWORD_SWAP (3 << 18)
> +# define R300_DEPTHENDIAN(x) ((x) << 19)
>
Was this an intentional switch to << 19, or just a copy/paste type-o from
the R300_COLOR_ENDIAN hunk above?
Not qualified to review this patch, but that looked odd as I was scanning
it.
--Aaron
> +
> +#define R300_SURF_NO_SWAP 0
> +#define R300_SURF_WORD_SWAP 1
> +#define R300_SURF_DWORD_SWAP 2
> +#define R300_SURF_HALF_DWORD_SWAP 3
>
> /* Z Buffer Clear Value */
> #define R300_ZB_DEPTHCLEARVALUE 0x4f28
> diff --git a/src/gallium/drivers/r300/r300_texture.c
> b/src/gallium/drivers/r300/r300_texture.c
> index da51661..825d811 100644
> --- a/src/gallium/drivers/r300/r300_texture.c
> +++ b/src/gallium/drivers/r300/r300_texture.c
> @@ -837,6 +837,35 @@ boolean r300_is_sampler_format_supported(enum
> pipe_format format)
> return r300_translate_texformat(format, 0, TRUE, FALSE) != ~0;
> }
>
> +static unsigned r300_get_endian_swap(enum pipe_format format)
> +{
> + const struct util_format_description *desc;
> + unsigned swap_size;
> +
> + if (PIPE_ENDIAN_NATIVE != PIPE_ENDIAN_BIG)
> + return R300_SURF_NO_SWAP;
> +
> + desc = util_format_description(format);
> + if (!desc)
> + return R300_SURF_NO_SWAP;
> +
> + /* Compressed formats should be in the little endian format. */
> + if (desc->block.width != 1 || desc->block.height != 1)
> + return R300_SURF_NO_SWAP;
> +
> + swap_size = desc->is_array ? desc->channel[0].size : desc->block.bits;
> +
> + switch (swap_size) {
> + default: /* shouldn't happen? */
> + case 8:
> + return R300_SURF_NO_SWAP;
> + case 16:
> + return R300_SURF_WORD_SWAP;
> + case 32:
> + return R300_SURF_DWORD_SWAP;
> + }
> +}
> +
> void r300_texture_setup_format_state(struct r300_screen *screen,
> struct r300_resource *tex,
> enum pipe_format format,
> @@ -918,7 +947,8 @@ void r300_texture_setup_format_state(struct
> r300_screen *screen,
> }
>
> out->tile_config = R300_TXO_MACRO_TILE(desc->macrotile[level]) |
> - R300_TXO_MICRO_TILE(desc->microtile);
> + R300_TXO_MICRO_TILE(desc->microtile) |
> +
> R300_TXO_ENDIAN(r300_get_endian_swap(tex->b.b.format));
> }
>
> static void r300_texture_setup_fb_state(struct r300_surface *surf)
> @@ -933,7 +963,8 @@ static void r300_texture_setup_fb_state(struct
> r300_surface *surf)
> surf->pitch =
> stride |
> R300_DEPTHMACROTILE(tex->tex.macrotile[level]) |
> - R300_DEPTHMICROTILE(tex->tex.microtile);
> + R300_DEPTHMICROTILE(tex->tex.microtile) |
> + R300_DEPTHENDIAN(r300_get_endian_swap(tex->b.b.format));
> surf->format = r300_translate_zsformat(surf->base.format);
> surf->pitch_zmask = tex->tex.zmask_stride_in_pixels[level];
> surf->pitch_hiz = tex->tex.hiz_stride_in_pixels[level];
> @@ -944,7 +975,8 @@ static void r300_texture_setup_fb_state(struct
> r300_surface *surf)
> stride |
> r300_translate_colorformat(format) |
> R300_COLOR_TILE(tex->tex.macrotile[level]) |
> - R300_COLOR_MICROTILE(tex->tex.microtile);
> + R300_COLOR_MICROTILE(tex->tex.microtile) |
> + R300_COLOR_ENDIAN(r300_get_endian_swap(tex->b.b.format));
> surf->format = r300_translate_out_fmt(format);
> surf->colormask_swizzle =
> r300_translate_colormask_swizzle(format);
> --
> 2.5.0
>
> _______________________________________________
> 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/20160425/64bb6f16/attachment-0001.html>
More information about the mesa-dev
mailing list