[Mesa-dev] [V2 PATCH 1/2] mesa: inline r200 radeon texture format macros to facility search and replace
Marek Olšák
maraeo at gmail.com
Sat Dec 21 07:01:27 PST 2013
Pushed, thanks.
Marek
On Sat, Dec 21, 2013 at 4:14 AM, Mark Mueller <markkmueller at gmail.com> wrote:
> Signed-off-by: Mark Mueller <MarkKMueller at gmail.com>
> ---
> src/mesa/drivers/dri/r200/r200_texstate.c | 108 +++++++++++---------------
> src/mesa/drivers/dri/radeon/radeon_texstate.c | 64 ++++++---------
> 2 files changed, 70 insertions(+), 102 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
> index b20bd51..b89bb39 100644
> --- a/src/mesa/drivers/dri/r200/r200_texstate.c
> +++ b/src/mesa/drivers/dri/r200/r200_texstate.c
> @@ -60,20 +60,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #define R200_TXFORMAT_RGBA_DXT3 R200_TXFORMAT_DXT23
> #define R200_TXFORMAT_RGBA_DXT5 R200_TXFORMAT_DXT45
>
> -#define _COLOR(f) \
> - [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, 0 }
> -#define _COLOR_REV(f) \
> - [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f, 0 }
> -#define _ALPHA(f) \
> - [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
> -#define _ALPHA_REV(f) \
> - [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
> -#define _YUV(f) \
> - [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, R200_YUV_TO_RGB }
> -#define _INVALID(f) \
> - [ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
> #define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
> - && (tx_table_be[f].format != 0xffffffff) )
> + && (tx_table_be[f].format != 0xffffffff) )
>
> struct tx_table {
> GLuint format, filter;
> @@ -82,63 +70,59 @@ struct tx_table {
> static const struct tx_table tx_table_be[] =
> {
> [ MESA_FORMAT_RGBA8888 ] = { R200_TXFORMAT_ABGR8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> - _ALPHA_REV(RGBA8888),
> - _ALPHA(ARGB8888),
> - _ALPHA_REV(ARGB8888),
> - _INVALID(RGB888),
> - _COLOR(RGB565),
> - _COLOR_REV(RGB565),
> - _ALPHA(ARGB4444),
> - _ALPHA_REV(ARGB4444),
> - _ALPHA(ARGB1555),
> - _ALPHA_REV(ARGB1555),
> - _ALPHA(AL88),
> - _ALPHA_REV(AL88),
> - _ALPHA(A8),
> - _COLOR(L8),
> - _ALPHA(I8),
> - _YUV(YCBCR),
> - _YUV(YCBCR_REV),
> - _INVALID(RGB_FXT1),
> - _INVALID(RGBA_FXT1),
> - _COLOR(RGB_DXT1),
> - _ALPHA(RGBA_DXT1),
> - _ALPHA(RGBA_DXT3),
> - _ALPHA(RGBA_DXT5),
> + [ MESA_FORMAT_RGBA8888_REV ] = { R200_TXFORMAT_RGBA8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB8888 ] = { R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB8888_REV ] = { R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGB888 ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGB565 ] = { R200_TXFORMAT_RGB565, 0 },
> + [ MESA_FORMAT_RGB565_REV ] = { R200_TXFORMAT_RGB565, 0 },
> + [ MESA_FORMAT_ARGB4444 ] = { R200_TXFORMAT_ARGB4444 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB4444_REV ] = { R200_TXFORMAT_ARGB4444 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB1555 ] = { R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB1555_REV ] = { R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_AL88 ] = { R200_TXFORMAT_AL88 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_AL88_REV ] = { R200_TXFORMAT_AL88 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_A8 ] = { R200_TXFORMAT_A8 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_L8 ] = { R200_TXFORMAT_L8, 0 },
> + [ MESA_FORMAT_I8 ] = { R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_YCBCR ] = { R200_TXFORMAT_YCBCR, R200_YUV_TO_RGB },
> + [ MESA_FORMAT_YCBCR_REV ] = { R200_TXFORMAT_YCBCR_REV, R200_YUV_TO_RGB },
> + [ MESA_FORMAT_RGB_FXT1 ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGBA_FXT1 ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGB_DXT1 ] = { R200_TXFORMAT_RGB_DXT1, 0 },
> + [ MESA_FORMAT_RGBA_DXT1 ] = { R200_TXFORMAT_RGBA_DXT1 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGBA_DXT3 ] = { R200_TXFORMAT_RGBA_DXT3 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGBA_DXT5 ] = { R200_TXFORMAT_RGBA_DXT5 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> };
>
> static const struct tx_table tx_table_le[] =
> {
> - _ALPHA(RGBA8888),
> + [ MESA_FORMAT_RGBA8888 ] = { R200_TXFORMAT_RGBA8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> [ MESA_FORMAT_RGBA8888_REV ] = { R200_TXFORMAT_ABGR8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> - _ALPHA(ARGB8888),
> - _ALPHA_REV(ARGB8888),
> + [ MESA_FORMAT_ARGB8888 ] = { R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB8888_REV ] = { R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> [ MESA_FORMAT_RGB888 ] = { R200_TXFORMAT_ARGB8888, 0 },
> - _COLOR(RGB565),
> - _COLOR_REV(RGB565),
> - _ALPHA(ARGB4444),
> - _ALPHA_REV(ARGB4444),
> - _ALPHA(ARGB1555),
> - _ALPHA_REV(ARGB1555),
> - _ALPHA(AL88),
> - _ALPHA_REV(AL88),
> - _ALPHA(A8),
> - _COLOR(L8),
> - _ALPHA(I8),
> - _YUV(YCBCR),
> - _YUV(YCBCR_REV),
> - _INVALID(RGB_FXT1),
> - _INVALID(RGBA_FXT1),
> - _COLOR(RGB_DXT1),
> - _ALPHA(RGBA_DXT1),
> - _ALPHA(RGBA_DXT3),
> - _ALPHA(RGBA_DXT5),
> + [ MESA_FORMAT_RGB565 ] = { R200_TXFORMAT_RGB565, 0 },
> + [ MESA_FORMAT_RGB565_REV ] = { R200_TXFORMAT_RGB565, 0 },
> + [ MESA_FORMAT_ARGB4444 ] = { R200_TXFORMAT_ARGB4444 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB4444_REV ] = { R200_TXFORMAT_ARGB4444 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB1555 ] = { R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB1555_REV ] = { R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_AL88 ] = { R200_TXFORMAT_AL88 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_AL88_REV ] = { R200_TXFORMAT_AL88 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_A8 ] = { R200_TXFORMAT_A8 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_L8 ] = { R200_TXFORMAT_L8, 0 },
> + [ MESA_FORMAT_I8 ] = { R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_YCBCR ] = { R200_TXFORMAT_YCBCR, R200_YUV_TO_RGB },
> + [ MESA_FORMAT_YCBCR_REV ] = { R200_TXFORMAT_YCBCR_REV, R200_YUV_TO_RGB },
> + [ MESA_FORMAT_RGB_FXT1 ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGBA_FXT1 ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGB_DXT1 ] = { R200_TXFORMAT_RGB_DXT1, 0 },
> + [ MESA_FORMAT_RGBA_DXT1 ] = { R200_TXFORMAT_RGBA_DXT1 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGBA_DXT3 ] = { R200_TXFORMAT_RGBA_DXT3 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGBA_DXT5 ] = { R200_TXFORMAT_RGBA_DXT5 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
> };
>
> -#undef _COLOR
> -#undef _ALPHA
> -#undef _INVALID
> -
> /* ================================================================
> * Texture combine functions
> */
> diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c
> index 944bac6..09a7ccb 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c
> @@ -63,18 +63,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #define RADEON_TXFORMAT_RGBA_DXT3 RADEON_TXFORMAT_DXT23
> #define RADEON_TXFORMAT_RGBA_DXT5 RADEON_TXFORMAT_DXT45
>
> -#define _COLOR(f) \
> - [ MESA_FORMAT_ ## f ] = { RADEON_TXFORMAT_ ## f, 0 }
> -#define _COLOR_REV(f) \
> - [ MESA_FORMAT_ ## f ## _REV ] = { RADEON_TXFORMAT_ ## f, 0 }
> -#define _ALPHA(f) \
> - [ MESA_FORMAT_ ## f ] = { RADEON_TXFORMAT_ ## f | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 }
> -#define _ALPHA_REV(f) \
> - [ MESA_FORMAT_ ## f ## _REV ] = { RADEON_TXFORMAT_ ## f | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 }
> -#define _YUV(f) \
> - [ MESA_FORMAT_ ## f ] = { RADEON_TXFORMAT_ ## f, RADEON_YUV_TO_RGB }
> -#define _INVALID(f) \
> - [ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
> #define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
> && (tx_table[f].format != 0xffffffff) )
>
> @@ -85,37 +73,33 @@ struct tx_table {
> /* XXX verify this table against MESA_FORMAT_x values */
> static const struct tx_table tx_table[] =
> {
> - _INVALID(NONE), /* MESA_FORMAT_NONE */
> - _ALPHA(RGBA8888),
> - _ALPHA_REV(RGBA8888),
> - _ALPHA(ARGB8888),
> - _ALPHA_REV(ARGB8888),
> + [ MESA_FORMAT_NONE ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGBA8888 ] = { RADEON_TXFORMAT_RGBA8888 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGBA8888_REV ] = { RADEON_TXFORMAT_RGBA8888 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB8888 ] = { RADEON_TXFORMAT_ARGB8888 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB8888_REV ] = { RADEON_TXFORMAT_ARGB8888 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> [ MESA_FORMAT_RGB888 ] = { RADEON_TXFORMAT_ARGB8888, 0 },
> - _COLOR(RGB565),
> - _COLOR_REV(RGB565),
> - _ALPHA(ARGB4444),
> - _ALPHA_REV(ARGB4444),
> - _ALPHA(ARGB1555),
> - _ALPHA_REV(ARGB1555),
> - _ALPHA(AL88),
> - _ALPHA_REV(AL88),
> - _ALPHA(A8),
> - _COLOR(L8),
> - _ALPHA(I8),
> - _YUV(YCBCR),
> - _YUV(YCBCR_REV),
> - _INVALID(RGB_FXT1),
> - _INVALID(RGBA_FXT1),
> - _COLOR(RGB_DXT1),
> - _ALPHA(RGBA_DXT1),
> - _ALPHA(RGBA_DXT3),
> - _ALPHA(RGBA_DXT5),
> + [ MESA_FORMAT_RGB565 ] = { RADEON_TXFORMAT_RGB565, 0 },
> + [ MESA_FORMAT_RGB565_REV ] = { RADEON_TXFORMAT_RGB565, 0 },
> + [ MESA_FORMAT_ARGB4444 ] = { RADEON_TXFORMAT_ARGB4444 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB4444_REV ] = { RADEON_TXFORMAT_ARGB4444 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB1555 ] = { RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_ARGB1555_REV ] = { RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_AL88 ] = { RADEON_TXFORMAT_AL88 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_AL88_REV ] = { RADEON_TXFORMAT_AL88 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_A8 ] = { RADEON_TXFORMAT_A8 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_L8 ] = { RADEON_TXFORMAT_L8, 0 },
> + [ MESA_FORMAT_I8 ] = { RADEON_TXFORMAT_I8 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_YCBCR ] = { RADEON_TXFORMAT_YCBCR, RADEON_YUV_TO_RGB },
> + [ MESA_FORMAT_YCBCR_REV ] = { RADEON_TXFORMAT_YCBCR_REV, RADEON_YUV_TO_RGB },
> + [ MESA_FORMAT_RGB_FXT1 ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGBA_FXT1 ] = { 0xffffffff, 0 },
> + [ MESA_FORMAT_RGB_DXT1 ] = { RADEON_TXFORMAT_RGB_DXT1, 0 },
> + [ MESA_FORMAT_RGBA_DXT1 ] = { RADEON_TXFORMAT_RGBA_DXT1 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGBA_DXT3 ] = { RADEON_TXFORMAT_RGBA_DXT3 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> + [ MESA_FORMAT_RGBA_DXT5 ] = { RADEON_TXFORMAT_RGBA_DXT5 | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 },
> };
>
> -#undef _COLOR
> -#undef _ALPHA
> -#undef _INVALID
> -
> /* ================================================================
> * Texture combine functions
> */
> --
> 1.8.3.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list