Browse Source

applied Jonn Carmack's patch for faster glTexSubImage2D() in Quake

tags/mesa_3_1
Brian Paul 26 years ago
parent
commit
64a79b2f3a
1 changed files with 22 additions and 3 deletions
  1. 22
    3
      src/mesa/main/teximage.c

+ 22
- 3
src/mesa/main/teximage.c View File

@@ -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 );

Loading…
Cancel
Save