mesa: replace gl_texture_format with gl_format
[mesa.git] / src / mesa / drivers / dri / r128 / r128_texmem.c
index f6a5dfbbcf379341f978cf12348a083c0bf6f7a4..84f8563b89d08e3f280e694c90e36618f3aeeb90 100644 (file)
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -36,15 +35,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r128_context.h"
 #include "r128_state.h"
 #include "r128_ioctl.h"
-#include "r128_vb.h"
 #include "r128_tris.h"
 #include "r128_tex.h"
 
-#include "context.h"
-#include "macros.h"
-#include "simple_list.h"
-#include "texformat.h"
-#include "imports.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/simple_list.h"
+#include "main/texformat.h"
+#include "main/imports.h"
 
 #define TEX_0  1
 #define TEX_1  2
@@ -86,18 +84,18 @@ static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
    int imageWidth, imageHeight;
    int remaining, rows;
    int format, dwords;
-   CARD32 pitch, offset;
+   uint32_t pitch, offset;
    int i;
 
    /* Ensure we have a valid texture to upload */
    if ( ( level < 0 ) || ( level > R128_MAX_TEXTURE_LEVELS ) )
       return;
 
-   image = t->base.tObj->Image[level];
+   image = t->base.tObj->Image[0][level];
    if ( !image )
       return;
 
-   switch ( image->TexFormat->TexelBytes ) {
+   switch ( _mesa_get_format_bytes(image->TexFormat) ) {
    case 1: texelsPerDword = 4; break;
    case 2: texelsPerDword = 2; break;
    case 4: texelsPerDword = 1; break;
@@ -202,7 +200,7 @@ static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
         remaining > 0 ;
         remaining -= rows, y += rows, i++ )
    {
-      CARD32 *dst;
+      uint32_t *dst;
       drmBufPtr buffer;
 
       assert(image->Data);
@@ -213,13 +211,15 @@ static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
       LOCK_HARDWARE( rmesa );
       buffer = r128GetBufferLocked( rmesa );
 
-      dst = (CARD32 *)((char *)buffer->address + R128_HOSTDATA_BLIT_OFFSET);
+      dst = (uint32_t *)((char *)buffer->address + R128_HOSTDATA_BLIT_OFFSET);
 
       /* Copy the next chunck of the texture image into the blit buffer */
       {
+         const GLuint texelBytes =
+            _mesa_get_format_bytes(image->TexFormat);
          const GLubyte *src = (const GLubyte *) image->Data +
-            (y * image->Width + x) * image->TexFormat->TexelBytes;
-         const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+            (y * image->Width + x) * texelBytes;            
+         const GLuint bytes = width * height * texelBytes;
          memcpy(dst, src, bytes);
       }
 
@@ -245,7 +245,7 @@ void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t )
 
    if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
       fprintf( stderr, "%s( %p, %p )\n",
-              __FUNCTION__, rmesa->glCtx, t );
+              __FUNCTION__, (void *) rmesa->glCtx, (void *) t );
    }
 
    assert(t);