[Mesa-dev] [PATCH] radeonsi: fix texture gather on stencil textures

Marek Olšák maraeo at gmail.com
Thu Jan 19 12:29:13 UTC 2017


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Wed, Jan 18, 2017 at 9:32 AM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> At least on VI, texture gather doesn't work with a 24_8 data format, so
> use 8_8_8_8 and a modified swizzle instead.
>
> A bit of background: When creating a GL_STENCIL_INDEX8 texture, we select
> the X24S8 pipe format because we don't support stencil-only render targets
> properly. With mip-mapping this can lead to a setup where the tiling is
> incompatible with stencil texturing, and a flushed stencil texture is
> used. For the flushed stencil, a literal X24S8 is used because there were
> issues with an 8bpp DB->CB copy.
>
> Longer term, it would be good if we could get away from these workarounds,
> i.e. properly support an S8 format for stencil-only rendering and flushed
> stencil. Since stencil texturing is somewhat rare, it's not a high
> priority.
>
> Fixes GL45-CTS.texture_cube_map_array.sampling.
> ---
>  src/gallium/drivers/radeonsi/si_state.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
> index 865a75d..c1a6652 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -1363,11 +1363,17 @@ static uint32_t si_translate_texformat(struct pipe_screen *screen,
>                 case PIPE_FORMAT_Z16_UNORM:
>                         return V_008F14_IMG_DATA_FORMAT_16;
>                 case PIPE_FORMAT_X24S8_UINT:
> +               case PIPE_FORMAT_S8X24_UINT:
> +                       /*
> +                        * Implemented as an 8_8_8_8 data format to fix texture
> +                        * gathers in stencil sampling. This affects at least
> +                        * GL45-CTS.texture_cube_map_array.sampling on VI.
> +                        */
> +                       return V_008F14_IMG_DATA_FORMAT_8_8_8_8;
>                 case PIPE_FORMAT_Z24X8_UNORM:
>                 case PIPE_FORMAT_Z24_UNORM_S8_UINT:
>                         return V_008F14_IMG_DATA_FORMAT_8_24;
>                 case PIPE_FORMAT_X8Z24_UNORM:
> -               case PIPE_FORMAT_S8X24_UINT:
>                 case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>                         return V_008F14_IMG_DATA_FORMAT_24_8;
>                 case PIPE_FORMAT_S8_UINT:
> @@ -2794,14 +2800,22 @@ si_make_texture_descriptor(struct si_screen *screen,
>         if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
>                 const unsigned char swizzle_xxxx[4] = {0, 0, 0, 0};
>                 const unsigned char swizzle_yyyy[4] = {1, 1, 1, 1};
> +               const unsigned char swizzle_wwww[4] = {3, 3, 3, 3};
>
>                 switch (pipe_format) {
>                 case PIPE_FORMAT_S8_UINT_Z24_UNORM:
> -               case PIPE_FORMAT_X24S8_UINT:
>                 case PIPE_FORMAT_X32_S8X24_UINT:
>                 case PIPE_FORMAT_X8Z24_UNORM:
>                         util_format_compose_swizzles(swizzle_yyyy, state_swizzle, swizzle);
>                         break;
> +               case PIPE_FORMAT_X24S8_UINT:
> +                       /*
> +                        * X24S8 is implemented as an 8_8_8_8 data format, to
> +                        * fix texture gathers. This affects at least
> +                        * GL45-CTS.texture_cube_map_array.sampling on VI.
> +                        */
> +                       util_format_compose_swizzles(swizzle_wwww, state_swizzle, swizzle);
> +                       break;
>                 default:
>                         util_format_compose_swizzles(swizzle_xxxx, state_swizzle, swizzle);
>                 }
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list