summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2005-01-25 15:29:50 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2005-01-25 15:29:50 +0000
commitb3000ba9185da63b16de76149b4d8a6ac294ea8f (patch)
tree1ab9516e893e21c6ef72eb928e1966d8ade1a104
parent2de70eebbc28b0e4f05bb5b6c8b708c33e9a39f1 (diff)
Use memcpy for some texture uploads -- it's faster.
-rw-r--r--src/mesa/drivers/dri/unichrome/via_texmem.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_texmem.c b/src/mesa/drivers/dri/unichrome/via_texmem.c
index 78153f6817..a2b71afd0d 100644
--- a/src/mesa/drivers/dri/unichrome/via_texmem.c
+++ b/src/mesa/drivers/dri/unichrome/via_texmem.c
@@ -90,6 +90,17 @@ void viaSwapOutTexObj(viaContextPtr vmesa, viaTextureObjectPtr t)
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
+
+static void do_memcpy(void *dst, const void *src, size_t sz)
+{
+ if (sz & 3) {
+ memcpy(dst, src, sz);
+ }
+ else {
+ memcpy(dst, src, sz);
+ }
+}
+
/* Upload an image from mesa's internal copy.
*/
static void viaUploadTexLevel(viaTextureObjectPtr t, int level)
@@ -117,13 +128,8 @@ static void viaUploadTexLevel(viaTextureObjectPtr t, int level)
}
}
else {
- for (j = 0; j < image->Height * image->Width; j++) {
- *dst = *src;
- dst++;
- src++;
- }
+ do_memcpy(dst, src, image->Height * image->Width * sizeof(GLuint));
}
- /*memcpy(dst, src, image->Height * image->Width * sizeof(GLuint));*/
}
else {
GLushort *dst = (GLushort *)(t->bufAddr + t->image[level].offset);
@@ -139,13 +145,8 @@ static void viaUploadTexLevel(viaTextureObjectPtr t, int level)
}
}
else {
- for (j = 0; j < image->Height * image->Width; j++) {
- *dst = *src;
- dst++;
- src++;
- }
+ do_memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));
}
- /*memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));*/
}
}
break;
@@ -166,13 +167,8 @@ static void viaUploadTexLevel(viaTextureObjectPtr t, int level)
}
}
else {
- for (j = 0; j < image->Height * image->Width; j++) {
- *dst = *src;
- src++;
- dst++;
- }
+ do_memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));
}
- /*memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));*/
if (VIA_DEBUG) fprintf(stderr, "GL_RGBA MESA_FORMAT_ARGB4444\n");
}
else if(image->TexFormat->MesaFormat == MESA_FORMAT_ARGB8888) {
@@ -189,13 +185,8 @@ static void viaUploadTexLevel(viaTextureObjectPtr t, int level)
}
}
else {
- for (j = 0; j < image->Height * image->Width; j++) {
- *dst = *src;
- dst++;
- src++;
- }
+ do_memcpy(dst, src, image->Height * image->Width * sizeof(GLuint));
}
- /*memcpy(dst, src, image->Height * image->Width * sizeof(GLuint));*/
}
else if(image->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) {
GLushort *dst = (GLushort *)(t->bufAddr + t->image[level].offset);
@@ -210,13 +201,8 @@ static void viaUploadTexLevel(viaTextureObjectPtr t, int level)
}
}
else {
- for (j = 0; j < image->Height * image->Width; j++) {
- *dst = *src;
- src++;
- dst++;
- }
+ do_memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));
}
- /*memcpy(dst, src, image->Height * image->Width * sizeof(GLushort));*/
if (VIA_DEBUG) fprintf(stderr, "GL_RGBA MESA_FORMAT_ARGB1555\n");
}
}