intel: Remove the unrelaxed relocation assertion
[mesa.git] / src / mesa / drivers / dri / i810 / i810texmem.c
index 9c24fcd8f5788d48f0a617b817959792be635813..6e6b21cf2b9c0f88e0c3916c5c5ce7ce8b3a5c75 100644 (file)
  *
  */
 
-#include "glheader.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "simple_list.h"
-#include "enums.h"
-#include "colormac.h"
-#include "mm.h"
-#include "texformat.h"
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/simple_list.h"
+#include "main/enums.h"
+#include "main/colormac.h"
+#include "main/mm.h"
 
 #include "i810screen.h"
 #include "i810_dri.h"
-
 #include "i810context.h"
 #include "i810tex.h"
-#include "i810state.h"
 #include "i810ioctl.h"
 
 
@@ -93,44 +90,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);
    }
 }
 
@@ -155,6 +155,7 @@ int i810UploadTexImagesLocked( i810ContextPtr imesa, i810TextureObjectPtr t )
        return -1;
       }
       
+      assert(t->base.memBlock);
       ofs = t->base.memBlock->ofs;
       t->BufAddr = imesa->i810Screen->tex.map + ofs;
       t->Setup[I810_TEXREG_MI3] = imesa->i810Screen->textureOffset + ofs;