summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c71
1 files changed, 63 insertions, 8 deletions
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
index ebb06b1d35..b16f1caa6b 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -49,19 +49,56 @@
#include "tdfx_texman.h"
+/* no borders! can't halve 1x1! (stride > width * comp) not allowed */
void
-_mesa_halve2x2_teximage2d ( GLuint bytesPerPixel,
+_mesa_halve2x2_teximage2d ( GLcontext *ctx,
+ struct gl_texture_image *texImage,
+ GLuint bytesPerPixel,
GLint srcWidth, GLint srcHeight,
const GLvoid *srcImage, GLvoid *dstImage )
{
GLint i, j, k;
- const GLint dstWidth = srcWidth / 2;
- const GLint dstHeight = srcHeight / 2;
- const GLint srcRowStride = srcWidth * bytesPerPixel;
- const GLubyte *src = srcImage;
+ GLint dstWidth = srcWidth / 2;
+ GLint dstHeight = srcHeight / 2;
+ GLint srcRowStride = srcWidth * bytesPerPixel;
+ GLubyte *src = (GLubyte *)srcImage;
GLubyte *dst = dstImage;
- /* no borders! can't halve 1x1! (stride > width * comp) not allowed */
+ GLuint bpt = 0;
+ GLubyte *_s = NULL;
+ GLubyte *_d = NULL;
+ GLenum _t;
+
+ if (texImage->TexFormat->MesaFormat == MESA_FORMAT_RGB565) {
+ _t = GL_UNSIGNED_SHORT_5_6_5_REV;
+ bpt = bytesPerPixel;
+ } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) {
+ _t = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ bpt = bytesPerPixel;
+ } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) {
+ _t = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ bpt = bytesPerPixel;
+ }
+ if (bpt) {
+ bytesPerPixel = 4;
+ srcRowStride = srcWidth * bytesPerPixel;
+ if (dstWidth == 0) {
+ dstWidth = 1;
+ }
+ if (dstHeight == 0) {
+ dstHeight = 1;
+ }
+ _s = src = MALLOC(srcRowStride * srcHeight);
+ _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight);
+ _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
+ &_mesa_texformat_rgba8888_rev, src,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ srcRowStride, /* dstRowStride */
+ 0, /* dstImageStride */
+ srcWidth, srcHeight, 1,
+ texImage->Format, _t, srcImage, &ctx->DefaultPacking);
+ }
+
if (srcHeight == 1) {
for (i = 0; i < dstWidth; i++) {
for (k = 0; k < bytesPerPixel; k++) {
@@ -96,6 +133,20 @@ _mesa_halve2x2_teximage2d ( GLuint bytesPerPixel,
src += srcRowStride;
}
}
+
+ if (bpt) {
+ src = _s;
+ dst = _d;
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, dstImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstWidth * bpt,
+ 0, /* dstImageStride */
+ dstWidth, dstHeight, 1,
+ GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
+ FREE(dst);
+ FREE(src);
+ }
}
@@ -1363,7 +1414,9 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
NULL);
mipImage = _mesa_select_tex_image(ctx, texUnit, target, level);
mip = TDFX_TEXIMAGE_DATA(mipImage);
- _mesa_halve2x2_teximage2d(texelBytes,
+ _mesa_halve2x2_teximage2d(ctx,
+ texImage,
+ texelBytes,
mml->width, mml->height,
texImage->Data, mipImage->Data);
texImage = mipImage;
@@ -1470,7 +1523,9 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
++level;
mipImage = _mesa_select_tex_image(ctx, texUnit, target, level);
mip = TDFX_TEXIMAGE_DATA(mipImage);
- _mesa_halve2x2_teximage2d(texelBytes,
+ _mesa_halve2x2_teximage2d(ctx,
+ texImage,
+ texelBytes,
mml->width, mml->height,
texImage->Data, mipImage->Data);
texImage = mipImage;