diff options
author | marha <marha@users.sourceforge.net> | 2012-12-17 11:51:13 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-12-17 11:51:13 +0100 |
commit | 840c8745518b92303d40f6834e9c616587242231 (patch) | |
tree | 097a30453fb59b6a88708c3f576e824e8f237c52 /mesalib/src/mesa/main/texcompress.c | |
parent | b395c3c85251d4e8761704d8e3a3c9f9fa5b45cc (diff) | |
download | vcxsrv-840c8745518b92303d40f6834e9c616587242231.tar.gz vcxsrv-840c8745518b92303d40f6834e9c616587242231.tar.bz2 vcxsrv-840c8745518b92303d40f6834e9c616587242231.zip |
libXft pixman mesa git update 17 dec 2012
libXft: 835cd2a6cb4aa8f89e6e7dead66483643a6e7ee8
pixman: 526dc06e5694172abf979c03a5cf530207fe2d27
mesa: 1358f3a905448f6fb546aba951e317f743a83c76
Diffstat (limited to 'mesalib/src/mesa/main/texcompress.c')
-rw-r--r-- | mesalib/src/mesa/main/texcompress.c | 139 |
1 files changed, 38 insertions, 101 deletions
diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index 372a483fa..33c580a88 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -42,7 +42,6 @@ #include "texcompress_rgtc.h" #include "texcompress_s3tc.h" #include "texcompress_etc.h" -#include "swrast/s_context.h" /** @@ -523,129 +522,67 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img, /** - * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image. - * \param srcRowStride stride in bytes between rows of blocks in the - * compressed source image. + * Return a texel-fetch function for the given format, or NULL if + * invalid format. */ -void -_mesa_decompress_image(gl_format format, GLuint width, GLuint height, - const GLubyte *src, GLint srcRowStride, - GLfloat *dest) +compressed_fetch_func +_mesa_get_compressed_fetch_func(gl_format format) { - void (*fetch)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); - struct swrast_texture_image texImage; /* dummy teximage */ - GLuint i, j; - GLuint bytes, bw, bh; - - bytes = _mesa_get_format_bytes(format); - _mesa_get_format_block_size(format, &bw, &bh); - - /* setup dummy texture image info */ - memset(&texImage, 0, sizeof(texImage)); - texImage.Map = (void *) src; - - /* XXX This line is a bit of a hack to adapt to the row stride - * convention used by the texture decompression functions. - */ - texImage.RowStride = srcRowStride * bh / bytes; - switch (format) { - /* DXT formats */ case MESA_FORMAT_RGB_DXT1: - fetch = _mesa_fetch_texel_rgb_dxt1; - break; case MESA_FORMAT_RGBA_DXT1: - fetch = _mesa_fetch_texel_rgba_dxt1; - break; case MESA_FORMAT_RGBA_DXT3: - fetch = _mesa_fetch_texel_rgba_dxt3; - break; case MESA_FORMAT_RGBA_DXT5: - fetch = _mesa_fetch_texel_rgba_dxt5; - break; - - /* FXT1 formats */ + return _mesa_get_dxt_fetch_func(format); case MESA_FORMAT_RGB_FXT1: - fetch = _mesa_fetch_texel_2d_f_rgb_fxt1; - break; case MESA_FORMAT_RGBA_FXT1: - fetch = _mesa_fetch_texel_2d_f_rgba_fxt1; - break; - - /* Red/RG formats */ + return _mesa_get_fxt_fetch_func(format); case MESA_FORMAT_RED_RGTC1: - fetch = _mesa_fetch_texel_red_rgtc1; - break; - case MESA_FORMAT_SIGNED_RED_RGTC1: - fetch = _mesa_fetch_texel_signed_red_rgtc1; - break; - case MESA_FORMAT_RG_RGTC2: - fetch = _mesa_fetch_texel_rg_rgtc2; - break; - case MESA_FORMAT_SIGNED_RG_RGTC2: - fetch = _mesa_fetch_texel_signed_rg_rgtc2; - break; - - /* L/LA formats */ case MESA_FORMAT_L_LATC1: - fetch = _mesa_fetch_texel_l_latc1; - break; + case MESA_FORMAT_SIGNED_RED_RGTC1: case MESA_FORMAT_SIGNED_L_LATC1: - fetch = _mesa_fetch_texel_signed_l_latc1; - break; + case MESA_FORMAT_RG_RGTC2: case MESA_FORMAT_LA_LATC2: - fetch = _mesa_fetch_texel_la_latc2; - break; + case MESA_FORMAT_SIGNED_RG_RGTC2: case MESA_FORMAT_SIGNED_LA_LATC2: - fetch = _mesa_fetch_texel_signed_la_latc2; - break; - - /* ETC1 formats */ + return _mesa_get_compressed_rgtc_func(format); case MESA_FORMAT_ETC1_RGB8: - fetch = _mesa_fetch_texel_2d_f_etc1_rgb8; - break; + return _mesa_get_etc_fetch_func(format); + default: + return NULL; + } +} - /* ETC2 formats */ - case MESA_FORMAT_ETC2_RGB8: - fetch = _mesa_fetch_texel_2d_f_etc2_rgb8; - break; - case MESA_FORMAT_ETC2_SRGB8: - fetch = _mesa_fetch_texel_2d_f_etc2_srgb8; - break; - case MESA_FORMAT_ETC2_RGBA8_EAC: - fetch = _mesa_fetch_texel_2d_f_etc2_rgba8_eac; - break; - case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC: - fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac; - break; - case MESA_FORMAT_ETC2_R11_EAC: - fetch = _mesa_fetch_texel_2d_f_etc2_r11_eac; - break; - case MESA_FORMAT_ETC2_RG11_EAC: - fetch = _mesa_fetch_texel_2d_f_etc2_rg11_eac; - break; - case MESA_FORMAT_ETC2_SIGNED_R11_EAC: - fetch = _mesa_fetch_texel_2d_f_etc2_signed_r11_eac; - break; - case MESA_FORMAT_ETC2_SIGNED_RG11_EAC: - fetch = _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac; - break; - case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1: - fetch = _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1; - break; - case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: - fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1; - break; - default: +/** + * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image. + * \param srcRowStride stride in bytes between rows of blocks in the + * compressed source image. + */ +void +_mesa_decompress_image(gl_format format, GLuint width, GLuint height, + const GLubyte *src, GLint srcRowStride, + GLfloat *dest) +{ + compressed_fetch_func fetch; + GLuint i, j; + GLuint bytes, bw, bh; + GLint stride; + + bytes = _mesa_get_format_bytes(format); + _mesa_get_format_block_size(format, &bw, &bh); + + fetch = _mesa_get_compressed_fetch_func(format); + if (!fetch) { _mesa_problem(NULL, "Unexpected format in _mesa_decompress_image()"); return; } + + stride = srcRowStride * bh / bytes; for (j = 0; j < height; j++) { for (i = 0; i < width; i++) { - fetch(&texImage, i, j, 0, dest); + fetch(src, NULL, stride, i, j, 0, dest); dest += 4; } } |