aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/formats.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-09-09 16:49:03 +0200
committermarha <marha@users.sourceforge.net>2011-09-09 16:49:03 +0200
commit05cf7dd22994a1dbfd3580b00690c01c392a5797 (patch)
treeec1c29b5f8a67c54b13b44f1eb7aa700f91fef9e /mesalib/src/mesa/main/formats.c
parent0947b921a3223c14322f10d83e71618d1724b734 (diff)
parentf9cf11136d65f20aab4fb6d5fc3ec3c59185a0b4 (diff)
downloadvcxsrv-05cf7dd22994a1dbfd3580b00690c01c392a5797.tar.gz
vcxsrv-05cf7dd22994a1dbfd3580b00690c01c392a5797.tar.bz2
vcxsrv-05cf7dd22994a1dbfd3580b00690c01c392a5797.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/include/GL/internal/dri_interface.h mesalib/scons/gallium.py mesalib/src/glsl/ast_to_hir.cpp mesalib/src/glsl/glsl_parser_extras.cpp mesalib/src/glsl/ir_variable.cpp mesalib/src/glsl/linker.cpp mesalib/src/mesa/SConscript mesalib/src/mesa/drivers/common/driverfuncs.c mesalib/src/mesa/main/compiler.h mesalib/src/mesa/main/formats.c mesalib/src/mesa/main/formats.h mesalib/src/mesa/main/texcompress.c mesalib/src/mesa/main/texgetimage.c mesalib/src/mesa/sources.mak
Diffstat (limited to 'mesalib/src/mesa/main/formats.c')
-rw-r--r--mesalib/src/mesa/main/formats.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index fd16d98c5..47f876b76 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -1343,6 +1343,70 @@ _mesa_get_srgb_format_linear(gl_format format)
/**
+ * If the given format is a compressed format, return a corresponding
+ * uncompressed format.
+ */
+gl_format
+_mesa_get_uncompressed_format(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_RGB_FXT1:
+ return MESA_FORMAT_RGB888;
+ case MESA_FORMAT_RGBA_FXT1:
+ return MESA_FORMAT_RGBA8888;
+ case MESA_FORMAT_RGB_DXT1:
+ case MESA_FORMAT_SRGB_DXT1:
+ return MESA_FORMAT_RGB888;
+ case MESA_FORMAT_RGBA_DXT1:
+ case MESA_FORMAT_SRGBA_DXT1:
+ return MESA_FORMAT_RGBA8888;
+ case MESA_FORMAT_RGBA_DXT3:
+ case MESA_FORMAT_SRGBA_DXT3:
+ return MESA_FORMAT_RGBA8888;
+ case MESA_FORMAT_RGBA_DXT5:
+ case MESA_FORMAT_SRGBA_DXT5:
+ return MESA_FORMAT_RGBA8888;
+ case MESA_FORMAT_RED_RGTC1:
+ return MESA_FORMAT_R8;
+ case MESA_FORMAT_SIGNED_RED_RGTC1:
+ return MESA_FORMAT_SIGNED_R8;
+ case MESA_FORMAT_RG_RGTC2:
+ return MESA_FORMAT_RG88;
+ case MESA_FORMAT_SIGNED_RG_RGTC2:
+ return MESA_FORMAT_SIGNED_RG88_REV;
+ case MESA_FORMAT_L_LATC1:
+ return MESA_FORMAT_L8;
+ case MESA_FORMAT_SIGNED_L_LATC1:
+ return MESA_FORMAT_SIGNED_L8;
+ case MESA_FORMAT_LA_LATC2:
+ return MESA_FORMAT_AL88;
+ case MESA_FORMAT_SIGNED_LA_LATC2:
+ return MESA_FORMAT_SIGNED_AL88;
+ default:
+#ifdef DEBUG
+ assert(!_mesa_is_format_compressed(format));
+#endif
+ return format;
+ }
+}
+
+
+GLuint
+_mesa_format_num_components(gl_format format)
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ return ((info->RedBits > 0) +
+ (info->GreenBits > 0) +
+ (info->BlueBits > 0) +
+ (info->AlphaBits > 0) +
+ (info->LuminanceBits > 0) +
+ (info->IntensityBits > 0) +
+ (info->DepthBits > 0) +
+ (info->StencilBits > 0));
+}
+
+
+/**
* Return number of bytes needed to store an image of the given size
* in the given format.
*/