Merge branch 'mesa_7_6_branch' into mesa_7_7_branch
[mesa.git] / src / mesa / drivers / dri / i810 / i810texmem.c
index 5ad66dbf5cb1e38d6066227757c4fab98833b412..d93afbf9ef6b5b9e3164b2f246b55b312f878e1d 100644 (file)
@@ -30,7 +30,6 @@
 #include "main/enums.h"
 #include "main/colormac.h"
 #include "main/mm.h"
-#include "main/texformat.h"
 
 #include "i810screen.h"
 #include "i810_dri.h"
@@ -92,44 +91,47 @@ static void i810UploadTexLevel( i810ContextPtr imesa,
 {
    const struct gl_texture_image *image = t->image[hwlevel].image;
    int j;
+   GLuint texelBytes;
 
    if (!image || !image->Data)
       return;
 
-   if (image->Width * image->TexFormat->TexelBytes == t->Pitch) {
+   texelBytes = _mesa_get_format_bytes(image->TexFormat);
+
+   if (image->Width * texelBytes == t->Pitch) {
         GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
         GLubyte *src = (GLubyte *)image->Data;
         
         memcpy( dst, src, t->Pitch * image->Height );
    }
-   else switch (image->TexFormat->TexelBytes) {
-   case 1:
-      {
-        GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
-        GLubyte *src = (GLubyte *)image->Data;
-
-        for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
-           __memcpy(dst, src, image->Width );
-           src += image->Width;
-        }
+   else {
+      switch (texelBytes) {
+      case 1:
+         {
+            GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
+            GLubyte *src = (GLubyte *)image->Data;
+
+            for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+               __memcpy(dst, src, image->Width );
+               src += image->Width;
+            }
+         }
+         break;
+      case 2:
+         {
+            GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset);
+            GLushort *src = (GLushort *)image->Data;
+
+            for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+               __memcpy(dst, src, image->Width * 2 );
+               src += image->Width;
+            }
+         }
+         break;
+      default:
+         fprintf(stderr, "%s: Not supported texel size %d\n",
+                 __FUNCTION__, texelBytes);
       }
-      break;
-
-   case 2:
-      {
-        GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset);
-        GLushort *src = (GLushort *)image->Data;
-
-        for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
-           __memcpy(dst, src, image->Width * 2 );
-           src += image->Width;
-        }
-      }
-      break;
-
-   default:
-      fprintf(stderr, "%s: Not supported texel size %d\n",
-             __FUNCTION__, image->TexFormat->TexelBytes);
    }
 }