[Mesa-dev] [RFC v2 15/15] swrast: add a new macro, FETCH_COMPRESSED

Anuj Phogat anuj.phogat at gmail.com
Mon Jun 1 14:20:12 PDT 2015


On Mon, Jun 1, 2015 at 10:13 AM, Nanley Chery <nanleychery at gmail.com> wrote:
> From: Nanley Chery <nanley.g.chery at intel.com>
>
> This patch creates a new macro, FETCH_COMPRESSED - similar in nature
> to the other FETCH_* macros. This reduces repetition in the code that
> deals with compressed textures.
>
> Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
> ---
>  src/mesa/swrast/s_texfetch.c | 239 ++++++++-----------------------------------
>  1 file changed, 41 insertions(+), 198 deletions(-)
>
> diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
> index 14e5293..92a4a37 100644
> --- a/src/mesa/swrast/s_texfetch.c
> +++ b/src/mesa/swrast/s_texfetch.c
> @@ -116,6 +116,14 @@ static void fetch_null_texelf( const struct swrast_texture_image *texImage,
>        NULL                      \
>     }
>
> +#define FETCH_COMPRESSED(NAME)  \
> +   {                            \
> +      MESA_FORMAT_ ## NAME,     \
> +      fetch_compressed,         \
> +      fetch_compressed,         \
> +      fetch_compressed          \
> +   }
> +
>  /**
>   * Table to map MESA_FORMAT_ to texel fetch/store funcs.
>   */
> @@ -344,214 +352,49 @@ texfetch_funcs[] =
>     FETCH_NULL(RGBX_SINT32),
>
>     /* DXT compressed formats */
> -   {
> -      MESA_FORMAT_RGB_DXT1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_RGBA_DXT1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_RGBA_DXT3,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_RGBA_DXT5,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> +   FETCH_COMPRESSED(RGB_DXT1),
> +   FETCH_COMPRESSED(RGBA_DXT1),
> +   FETCH_COMPRESSED(RGBA_DXT3),
> +   FETCH_COMPRESSED(RGBA_DXT5),
>
>     /* DXT sRGB compressed formats */
> -   {
> -      MESA_FORMAT_SRGB_DXT1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_SRGBA_DXT1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_SRGBA_DXT3,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_SRGBA_DXT5,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> +   FETCH_COMPRESSED(SRGB_DXT1),
> +   FETCH_COMPRESSED(SRGBA_DXT1),
> +   FETCH_COMPRESSED(SRGBA_DXT3),
> +   FETCH_COMPRESSED(SRGBA_DXT5),
>
>     /* FXT1 compressed formats */
> -   {
> -      MESA_FORMAT_RGB_FXT1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_RGBA_FXT1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> +   FETCH_COMPRESSED(RGB_FXT1),
> +   FETCH_COMPRESSED(RGBA_FXT1),
>
>     /* RGTC compressed formats */
> -   {
> -      MESA_FORMAT_R_RGTC1_UNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_R_RGTC1_SNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_RG_RGTC2_UNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_RG_RGTC2_SNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> +   FETCH_COMPRESSED(R_RGTC1_UNORM),
> +   FETCH_COMPRESSED(R_RGTC1_SNORM),
> +   FETCH_COMPRESSED(RG_RGTC2_UNORM),
> +   FETCH_COMPRESSED(RG_RGTC2_SNORM),
>
>     /* LATC1/2 compressed formats */
> -   {
> -      MESA_FORMAT_L_LATC1_UNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_L_LATC1_SNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_LA_LATC2_UNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_LA_LATC2_SNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> +   FETCH_COMPRESSED(L_LATC1_UNORM),
> +   FETCH_COMPRESSED(L_LATC1_SNORM),
> +   FETCH_COMPRESSED(LA_LATC2_UNORM),
> +   FETCH_COMPRESSED(LA_LATC2_SNORM),
>
>     /* ETC1/2 compressed formats */
> -   {
> -      MESA_FORMAT_ETC1_RGB8,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_RGB8,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_SRGB8,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_RGBA8_EAC,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_R11_EAC,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_RG11_EAC,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_SIGNED_R11_EAC,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_BPTC_RGBA_UNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> -   {
> -      MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT,
> -      fetch_compressed,
> -      fetch_compressed,
> -      fetch_compressed
> -   },
> +   FETCH_COMPRESSED(ETC1_RGB8),
> +   FETCH_COMPRESSED(ETC2_RGB8),
> +   FETCH_COMPRESSED(ETC2_SRGB8),
> +   FETCH_COMPRESSED(ETC2_RGBA8_EAC),
> +   FETCH_COMPRESSED(ETC2_SRGB8_ALPHA8_EAC),
> +   FETCH_COMPRESSED(ETC2_R11_EAC),
> +   FETCH_COMPRESSED(ETC2_RG11_EAC),
> +   FETCH_COMPRESSED(ETC2_SIGNED_R11_EAC),
> +   FETCH_COMPRESSED(ETC2_SIGNED_RG11_EAC),
> +   FETCH_COMPRESSED(ETC2_RGB8_PUNCHTHROUGH_ALPHA1),
> +   FETCH_COMPRESSED(ETC2_SRGB8_PUNCHTHROUGH_ALPHA1),
> +   FETCH_COMPRESSED(BPTC_RGBA_UNORM),
> +   FETCH_COMPRESSED(BPTC_SRGB_ALPHA_UNORM),
> +   FETCH_COMPRESSED(BPTC_RGB_SIGNED_FLOAT),
> +   FETCH_COMPRESSED(BPTC_RGB_UNSIGNED_FLOAT),
>
>     /* ASTC compressed formats */
>     FETCH_NULL(ASTC_4x4_RGBA),
> --
> 2.4.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list