diff options
author | Daniel Borca <[email protected]> | 2004-05-04 06:27:06 +0000 |
---|---|---|
committer | Daniel Borca <[email protected]> | 2004-05-04 06:27:06 +0000 |
commit | 33ffbd1c58dc8582f67d946f9eb26127e9851a10 (patch) | |
tree | a3a97552ee012bb549701e0b98020e6adaf3e479 /src/mesa/main | |
parent | abe4a72cfcde712d4b18832e2751d26b94a7718e (diff) |
texture compression: getting warmer
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/texcompress_fxt1.c | 32 | ||||
-rw-r--r-- | src/mesa/main/texcompress_s3tc.c | 8 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 34 | ||||
-rw-r--r-- | src/mesa/main/texstore.h | 6 |
4 files changed, 57 insertions, 23 deletions
diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 2d25f5b6e03..e6545123712 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -40,14 +40,14 @@ #include "texstore.h" -static GLint +static GLuint compress_fxt1 (GLcontext *ctx, - GLint srcWidth, - GLint srcHeight, + GLsizei srcWidth, + GLsizei srcHeight, GLenum srcFormat, - const GLvoid *pixels, + const GLchan *source, GLint srcRowStride, - GLvoid *dst, + GLubyte *dest, GLint dstRowStride); @@ -69,12 +69,9 @@ texstore_rgb_fxt1(STORE_PARAMS) const GLchan *pixels; GLint srcRowStride; GLubyte *dst; - GLint texWidth; + const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ const GLchan *tempImage = NULL; - dstRowStride = _mesa_compressed_row_stride(GL_COMPRESSED_RGB_FXT1_3DFX, srcWidth); - texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ - ASSERT(dstFormat == &_mesa_texformat_rgb_fxt1); ASSERT(dstXoffset % 8 == 0); ASSERT(dstYoffset % 4 == 0); @@ -130,13 +127,10 @@ texstore_rgba_fxt1(STORE_PARAMS) const GLchan *pixels; GLint srcRowStride; GLubyte *dst; - GLint texWidth; + GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ const GLchan *tempImage = NULL; - dstRowStride = _mesa_compressed_row_stride(GL_COMPRESSED_RGBA_FXT1_3DFX, srcWidth); - texWidth = dstRowStride * 8 / 16; /* a bit of a hack */ - - ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1); + ASSERT(dstFormat == &_mesa_texformat_rgba_fxt1); ASSERT(dstXoffset % 8 == 0); ASSERT(dstYoffset % 4 == 0); ASSERT(dstZoffset == 0); @@ -269,14 +263,14 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { }; -static GLint +static GLuint compress_fxt1 (GLcontext *ctx, - GLint srcWidth, - GLint srcHeight, + GLsizei srcWidth, + GLsizei srcHeight, GLenum srcFormat, - const GLvoid *pixels, + const GLchan *source, GLint srcRowStride, - GLvoid *dst, + GLubyte *dest, GLint dstRowStride) { /* here be dragons */ diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 35f358a8f38..07ca6b0f014 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -57,7 +57,7 @@ texstore_rgb_dxt1(STORE_PARAMS) const GLchan *pixels; GLint srcRowStride; GLubyte *dst; - const GLint texWidth = dstRowStride / 2; /* a bit of a hack */ + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ const GLchan *tempImage = NULL; ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1); @@ -114,7 +114,7 @@ texstore_rgba_dxt1(STORE_PARAMS) const GLchan *pixels; GLint srcRowStride; GLubyte *dst; - const GLint texWidth = dstRowStride / 2; /* a bit of a hack */ + const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */ const GLchan *tempImage = NULL; ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1); @@ -169,7 +169,7 @@ texstore_rgba_dxt3(STORE_PARAMS) const GLchan *pixels; GLint srcRowStride; GLubyte *dst; - const GLint texWidth = dstRowStride / 4; /* a bit of a hack */ + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ const GLchan *tempImage = NULL; ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3); @@ -223,7 +223,7 @@ texstore_rgba_dxt5(STORE_PARAMS) const GLchan *pixels; GLint srcRowStride; GLubyte *dst; - const GLint texWidth = dstRowStride / 4; /* a bit of a hack */ + const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */ const GLchan *tempImage = NULL; ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5); diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 3dae1929c4d..ea7d7cebb17 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -3280,3 +3280,37 @@ do { \ _mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d"); } } + + +/** + * Upscale an image by replication, not (typical) stretching. + * We use this when the image width or height is less than a + * certain size (4, 8) and we need to upscale an image. + */ +void +_mesa_upscale_teximage2d (GLsizei inWidth, GLsizei inHeight, + GLsizei outWidth, GLsizei outHeight, + GLint comps, const GLchan *src, GLint srcRowStride, + GLchan *dest ) +{ + GLint i, j, k; + + ASSERT(outWidth >= inWidth); + ASSERT(outHeight >= inHeight); + ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2); +#if 0 + ASSERT((outWidth & 3) == 0); + ASSERT((outHeight & 3) == 0); +#endif + + for (i = 0; i < outHeight; i++) { + const GLint ii = i % inHeight; + for (j = 0; j < outWidth; j++) { + const GLint jj = j % inWidth; + for (k = 0; k < comps; k++) { + dest[(i * outWidth + j) * comps + k] + = src[ii * srcRowStride + jj * comps + k]; + } + } + } +} diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index d276ff94e47..4edad034d0b 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -232,4 +232,10 @@ _mesa_rescale_teximage2d(GLuint bytesPerPixel, GLuint dstRowStride, GLint dstWidth, GLint dstHeight, const GLvoid *srcImage, GLvoid *dstImage); +extern void +_mesa_upscale_teximage2d( GLsizei inWidth, GLsizei inHeight, + GLsizei outWidth, GLsizei outHeight, + GLint comps, const GLchan *src, GLint srcRowStride, + GLchan *dest ); + #endif |