diff options
author | Brian Paul <[email protected]> | 1999-10-22 10:43:35 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 1999-10-22 10:43:35 +0000 |
commit | 64a79b2f3ad964fa61c46bf3239634736e508a44 (patch) | |
tree | 5408041bf4a151c4ae106b29ad104cde302dc635 /src/mesa/main | |
parent | d13c0a90c7b57d8e29b9105290bc05f21f2c97d8 (diff) |
applied Jonn Carmack's patch for faster glTexSubImage2D() in Quake
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/teximage.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index a5d3ef97a57..0f6bde4bb01 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,4 +1,4 @@ -/* $Id: teximage.c,v 1.7 1999/10/21 12:45:03 brianp Exp $ */ +/* $Id: teximage.c,v 1.8 1999/10/22 10:43:35 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -1674,7 +1674,7 @@ void gl_TexSubImage2D( GLcontext *ctx, /* row by row. */ GLubyte *dst = destTex->Data + (yoffsetb * destTex->Width + xoffsetb) * texcomponents; - GLubyte *src = (GLubyte *) image->Data; + const GLubyte *src = (const GLubyte *) image->Data; GLint j; for (j=0;j<height;j++) { MEMCPY( dst, src, width * texcomponents ); @@ -1682,13 +1682,32 @@ void gl_TexSubImage2D( GLcontext *ctx, src += width * texcomponents * sizeof(GLubyte); } } + else if (image->Type==GL_UNSIGNED_BYTE + && texcomponents==3 && image->Components == 4 ) { + /* 32 bit (padded) to 24 bit case, used heavily by quake */ + GLubyte *dst = destTex->Data + + (yoffsetb * destTex->Width + xoffsetb) * texcomponents; + const GLubyte *src = (const GLubyte *) image->Data; + GLint j; + for (j=0;j<height;j++) { + const GLubyte *stop = src + (width << 2); + for ( ; src != stop ; ) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst += 3; + src += 4; + } + dst += (destTex->Width - width) * texcomponents * sizeof(GLubyte); + } + } else { /* General case, convert image pixels into texels, scale, bias, etc */ struct gl_texture_image *subTexImg = image_to_texture(ctx, image, destTex->IntFormat, destTex->Border); GLubyte *dst = destTex->Data + (yoffsetb * destTex->Width + xoffsetb) * texcomponents; - GLubyte *src = subTexImg->Data; + const GLubyte *src = subTexImg->Data; GLint j; for (j=0;j<height;j++) { MEMCPY( dst, src, width * texcomponents ); |