X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Ftexformat.c;h=16d05cc7d0702e55697e15da1966ea5ce8d4b819;hp=ce2772c2992e5f1c13964bb31b25b22922d8fb85;hb=5340b6dff73a0a23531ce2a5f28fba8303adab6e;hpb=3059ceb7f8128f00846f261f1927f5ec72d5dd15 diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index ce2772c2992..16d05cc7d07 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -3,6 +3,7 @@ * Version: 6.5.1 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (c) 2008 VMware, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -333,6 +334,30 @@ const struct gl_texture_format _mesa_texformat_srgba8 = { store_texel_srgba8 /* StoreTexel */ }; +const struct gl_texture_format _mesa_texformat_sargb8 = { + MESA_FORMAT_SARGB8, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 8, /* RedBits */ + 8, /* GreenBits */ + 8, /* BlueBits */ + 8, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* StencilBits */ + 4, /* TexelBytes */ + _mesa_texstore_sargb8, /* StoreTexImageFunc */ + NULL, /* FetchTexel1D */ + NULL, /* FetchTexel2D */ + NULL, /* FetchTexel3D */ + fetch_texel_1d_sargb8, /* FetchTexel1Df */ + fetch_texel_2d_sargb8, /* FetchTexel2Df */ + fetch_texel_3d_sargb8, /* FetchTexel3Df */ + store_texel_sargb8 /* StoreTexel */ +}; + const struct gl_texture_format _mesa_texformat_sl8 = { MESA_FORMAT_SL8, /* MesaFormat */ GL_LUMINANCE, /* BaseFormat */ @@ -871,6 +896,30 @@ const struct gl_texture_format _mesa_texformat_rgb565_rev = { store_texel_rgb565_rev /* StoreTexel */ }; +const struct gl_texture_format _mesa_texformat_rgba4444 = { + MESA_FORMAT_RGBA4444, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /* RedBits */ + 4, /* GreenBits */ + 4, /* BlueBits */ + 4, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* StencilBits */ + 2, /* TexelBytes */ + _mesa_texstore_rgba4444, /* StoreTexImageFunc */ + fetch_texel_1d_rgba4444, /* FetchTexel1D */ + fetch_texel_2d_rgba4444, /* FetchTexel2D */ + fetch_texel_3d_rgba4444, /* FetchTexel3D */ + NULL, /* FetchTexel1Df */ + NULL, /* FetchTexel2Df */ + NULL, /* FetchTexel3Df */ + store_texel_rgba4444 /* StoreTexel */ +}; + const struct gl_texture_format _mesa_texformat_argb4444 = { MESA_FORMAT_ARGB4444, /* MesaFormat */ GL_RGBA, /* BaseFormat */ @@ -919,6 +968,30 @@ const struct gl_texture_format _mesa_texformat_argb4444_rev = { store_texel_argb4444_rev /* StoreTexel */ }; +const struct gl_texture_format _mesa_texformat_rgba5551 = { + MESA_FORMAT_RGBA5551, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 5, /* RedBits */ + 5, /* GreenBits */ + 5, /* BlueBits */ + 1, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* StencilBits */ + 2, /* TexelBytes */ + _mesa_texstore_rgba5551, /* StoreTexImageFunc */ + fetch_texel_1d_rgba5551, /* FetchTexel1D */ + fetch_texel_2d_rgba5551, /* FetchTexel2D */ + fetch_texel_3d_rgba5551, /* FetchTexel3D */ + NULL, /* FetchTexel1Df */ + NULL, /* FetchTexel2Df */ + NULL, /* FetchTexel3Df */ + store_texel_rgba5551 /* StoreTexel */ +}; + const struct gl_texture_format _mesa_texformat_argb1555 = { MESA_FORMAT_ARGB1555, /* MesaFormat */ GL_RGBA, /* BaseFormat */ @@ -1433,41 +1506,39 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, } } - if (ctx->Extensions.ARB_texture_compression) { - switch (internalFormat) { - case GL_COMPRESSED_ALPHA_ARB: - return &_mesa_texformat_alpha; - case GL_COMPRESSED_LUMINANCE_ARB: - return &_mesa_texformat_luminance; - case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: - return &_mesa_texformat_luminance_alpha; - case GL_COMPRESSED_INTENSITY_ARB: - return &_mesa_texformat_intensity; - case GL_COMPRESSED_RGB_ARB: + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + return &_mesa_texformat_alpha; + case GL_COMPRESSED_LUMINANCE_ARB: + return &_mesa_texformat_luminance; + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + return &_mesa_texformat_luminance_alpha; + case GL_COMPRESSED_INTENSITY_ARB: + return &_mesa_texformat_intensity; + case GL_COMPRESSED_RGB_ARB: #if FEATURE_texture_fxt1 - if (ctx->Extensions.TDFX_texture_compression_FXT1) - return &_mesa_texformat_rgb_fxt1; + if (ctx->Extensions.TDFX_texture_compression_FXT1) + return &_mesa_texformat_rgb_fxt1; #endif #if FEATURE_texture_s3tc - if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) - return &_mesa_texformat_rgb_dxt1; + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) + return &_mesa_texformat_rgb_dxt1; #endif - return &_mesa_texformat_rgb; - case GL_COMPRESSED_RGBA_ARB: + return &_mesa_texformat_rgb; + case GL_COMPRESSED_RGBA_ARB: #if FEATURE_texture_fxt1 - if (ctx->Extensions.TDFX_texture_compression_FXT1) - return &_mesa_texformat_rgba_fxt1; + if (ctx->Extensions.TDFX_texture_compression_FXT1) + return &_mesa_texformat_rgba_fxt1; #endif #if FEATURE_texture_s3tc - if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) - return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */ + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) + return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */ #endif - return &_mesa_texformat_rgba; - default: - ; /* fallthrough */ - } + return &_mesa_texformat_rgba; + default: + ; /* fallthrough */ } if (ctx->Extensions.MESA_ycbcr_texture) { @@ -1578,21 +1649,40 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_SLUMINANCE_ALPHA_EXT: case GL_SLUMINANCE8_ALPHA8_EXT: return &_mesa_texformat_sla8; - /* NOTE: not supporting any compression of sRGB at this time */ - case GL_COMPRESSED_SRGB_EXT: - return &_mesa_texformat_srgb8; - case GL_COMPRESSED_SRGB_ALPHA_EXT: - return &_mesa_texformat_srgba8; case GL_COMPRESSED_SLUMINANCE_EXT: return &_mesa_texformat_sl8; case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: return &_mesa_texformat_sla8; - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_EXT: +#if FEATURE_texture_s3tc + if (ctx->Extensions.EXT_texture_compression_s3tc) + return &_mesa_texformat_srgb_dxt1; +#endif return &_mesa_texformat_srgb8; + case GL_COMPRESSED_SRGB_ALPHA_EXT: +#if FEATURE_texture_s3tc + if (ctx->Extensions.EXT_texture_compression_s3tc) + return &_mesa_texformat_srgba_dxt3; /* Not srgba_dxt1, see spec */ +#endif + return &_mesa_texformat_srgba8; +#if FEATURE_texture_s3tc + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + if (ctx->Extensions.EXT_texture_compression_s3tc) + return &_mesa_texformat_srgb_dxt1; + break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + if (ctx->Extensions.EXT_texture_compression_s3tc) + return &_mesa_texformat_srgba_dxt1; + break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + if (ctx->Extensions.EXT_texture_compression_s3tc) + return &_mesa_texformat_srgba_dxt3; + break; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return &_mesa_texformat_srgba8; + if (ctx->Extensions.EXT_texture_compression_s3tc) + return &_mesa_texformat_srgba_dxt5; + break; +#endif default: ; /* fallthrough */ } @@ -1641,7 +1731,7 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format, case MESA_FORMAT_ARGB1555: case MESA_FORMAT_ARGB1555_REV: *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; - *comps = 3; + *comps = 4; return; case MESA_FORMAT_AL88: @@ -1694,6 +1784,7 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format, *comps = 3; return; case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: *datatype = GL_UNSIGNED_BYTE; *comps = 4; return; @@ -1716,6 +1807,12 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format, case MESA_FORMAT_RGBA_DXT1: case MESA_FORMAT_RGBA_DXT3: case MESA_FORMAT_RGBA_DXT5: +#if FEATURE_EXT_texture_sRGB + case MESA_FORMAT_SRGB_DXT1: + case MESA_FORMAT_SRGBA_DXT1: + case MESA_FORMAT_SRGBA_DXT3: + case MESA_FORMAT_SRGBA_DXT5: +#endif /* XXX generate error instead? */ *datatype = GL_UNSIGNED_BYTE; *comps = 0;