We dont need to call r300EmitAOS if we arent going to draw anything(r300_get_num_vert...
[mesa.git] / src / mesa / drivers / dri / unichrome / via_tex.c
index 97a4c8572a6d57d3c4454e47e727b1651936992d..3ed1a5308821db52b6c6abaf3a0a6d4f8d0cfec3 100644 (file)
 #include "via_ioctl.h"
 
 
-/*
- * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
- */
-/* 
-static GLuint viaComputeLodBias(GLfloat bias)
-{
-    int b = (int)(bias * 16.0) + 12;
-    if (b > 63)
-        b = 63;
-    else if (b < -64)
-        b = -64;
-    return (GLuint)(b & MLC_LOD_BIAS_MASK);
-}
-*/
-
 viaTextureObjectPtr viaAllocTextureObject(struct gl_texture_object *texObj)
 {
     viaTextureObjectPtr t;
@@ -76,25 +61,6 @@ viaTextureObjectPtr viaAllocTextureObject(struct gl_texture_object *texObj)
     return t;
 }
 
-static void viaTexParameter(GLcontext *ctx, GLenum target,
-                            struct gl_texture_object *texObj,
-                            GLenum pname, const GLfloat *params)
-{
-    viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
-    if (!t)
-        return;
-
-    if (target != GL_TEXTURE_2D)
-        return;
-}
-
-static void viaTexEnv(GLcontext *ctx, GLenum target,
-                      GLenum pname, const GLfloat *param)
-{
-    viaContextPtr vmesa = VIA_CONTEXT(ctx);
-    vmesa = vmesa;
-} 
-
 static void viaTexImage1D(GLcontext *ctx, GLenum target, GLint level,
                           GLint internalFormat,
                           GLint width, GLint border,
@@ -105,9 +71,7 @@ static void viaTexImage1D(GLcontext *ctx, GLenum target, GLint level,
                           struct gl_texture_image *texImage)
 {
     viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
-#ifdef DEBUG    
     if (VIA_DEBUG) fprintf(stderr, "viaTexImage1D - in\n");
-#endif
     if (t) {
         if (level == 0) {
            viaSwapOutTexObj(VIA_CONTEXT(ctx), t);
@@ -127,9 +91,7 @@ static void viaTexImage1D(GLcontext *ctx, GLenum target, GLint level,
     _mesa_store_teximage1d(ctx, target, level, internalFormat,
                            width, border, format, type,
                            pixels, packing, texObj, texImage);
-#ifdef DEBUG                      
     if (VIA_DEBUG) fprintf(stderr, "viaTexImage1D - out\n");
-#endif
 }
 static void viaTexSubImage1D(GLcontext *ctx,
                              GLenum target,
@@ -164,9 +126,7 @@ static void viaTexImage2D(GLcontext *ctx, GLenum target, GLint level,
                           struct gl_texture_image *texImage)
 {
     viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
-#ifdef DEBUG    
     if (VIA_DEBUG) fprintf(stderr, "viaTexImage2D - in\n");
-#endif    
     if (t) {
         if (level == 0) {
            viaSwapOutTexObj(VIA_CONTEXT(ctx), t);
@@ -186,9 +146,7 @@ static void viaTexImage2D(GLcontext *ctx, GLenum target, GLint level,
     _mesa_store_teximage2d(ctx, target, level, internalFormat,
                            width, height, border, format, type,
                            pixels, packing, texObj, texImage);
-#ifdef DEBUG                      
     if (VIA_DEBUG) fprintf(stderr, "viaTexImage2D - out\n");
-#endif
 }
 
 static void viaTexSubImage2D(GLcontext *ctx,
@@ -221,9 +179,7 @@ static void viaTexSubImage2D(GLcontext *ctx,
 static void viaBindTexture(GLcontext *ctx, GLenum target,
                            struct gl_texture_object *texObj)
 {
-#ifdef DEBUG    
     if (VIA_DEBUG) fprintf(stderr, "viaBindTexture - in\n");
-#endif
     if (target == GL_TEXTURE_2D) {
         viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
 
@@ -237,32 +193,27 @@ static void viaBindTexture(GLcontext *ctx, GLenum target,
             texObj->DriverData = t;
         }
     }
-#ifdef DEBUG    
     if (VIA_DEBUG) fprintf(stderr, "viaBindTexture - out\n");
-#endif
 }
 
 static void viaDeleteTexture(GLcontext *ctx, struct gl_texture_object *texObj)
 {
     viaTextureObjectPtr t = (viaTextureObjectPtr)texObj->DriverData;
-#ifdef DEBUG    
     if (VIA_DEBUG) fprintf(stderr, "viaDeleteTexture - in\n");    
-#endif
     if (t) {
         viaContextPtr vmesa = VIA_CONTEXT(ctx);
         if (vmesa) {
-           /*=* John Sheng [2003.7.18] viewperf frames/sec *=*/
-           /*VIA_FIREVERTICES(vmesa);*/
-           if (vmesa->dma[0].map) { /* imply vmesa is not under destroying */
-               VIA_FIREVERTICES(vmesa);
+           if (vmesa->dma) { /* imply vmesa is not under destroying */
+               VIA_FLUSH_DMA(vmesa);
            }
            viaDestroyTexObj(vmesa, t);
        }
         texObj->DriverData = 0;
     }
-#ifdef DEBUG    
     if (VIA_DEBUG) fprintf(stderr, "viaDeleteTexture - out\n");    
-#endif
+
+   /* Free mipmap images and the texture object itself */
+   _mesa_delete_texture_object(ctx, texObj);
 }
 
 static GLboolean viaIsTextureResident(GLcontext *ctx,
@@ -280,10 +231,8 @@ viaChooseTexFormat(GLcontext *ctx, GLint internalFormat,
     viaContextPtr vmesa = VIA_CONTEXT(ctx);
     (void)format;
     (void)type;
-#ifdef DEBUG    
     if (VIA_DEBUG) fprintf(stderr, "%s in\n", __FUNCTION__);    
     if (VIA_DEBUG) fprintf(stderr, "internalFormat:%d format:%d\n", internalFormat, format);    
-#endif    
     switch (internalFormat) {
     case 1:
     case GL_LUMINANCE:
@@ -304,9 +253,7 @@ viaChooseTexFormat(GLcontext *ctx, GLint internalFormat,
     case GL_R3_G3_B2:  
     case GL_RGB4:    
     case GL_RGB5:
-#ifdef DEBUG    
        if (VIA_DEBUG) fprintf(stderr, "2 &_mesa_texformat_arg565\n");    
-#endif
         return &_mesa_texformat_rgb565;    
     case 3:
     case GL_RGB:
@@ -315,50 +262,36 @@ viaChooseTexFormat(GLcontext *ctx, GLint internalFormat,
     case GL_RGB12:    
     case GL_RGB16:
        if (vmesa->viaScreen->bitsPerPixel == 0x20) {
-#ifdef DEBUG    
            if (VIA_DEBUG) fprintf(stderr,"3 argb8888\n");
-#endif
            return &_mesa_texformat_argb8888;
        }           
        else {
-#ifdef DEBUG    
            if (VIA_DEBUG) fprintf(stderr,"3 rgb565\n");        
-#endif
             return &_mesa_texformat_rgb565;
        }
     case 4:
        if (vmesa->viaScreen->bitsPerPixel == 0x20) {
-#ifdef DEBUG    
            if (VIA_DEBUG) fprintf(stderr, "4 &_mesa_texformat_argb8888\n");
-#endif
            return &_mesa_texformat_argb8888;
        }
        else {
-#ifdef DEBUG    
            if (VIA_DEBUG) fprintf(stderr, "4 &_mesa_texformat_argb4444\n");
-#endif
            return &_mesa_texformat_argb4444;               
        }
     case GL_RGBA2:    
     case GL_RGBA4:         
-#ifdef DEBUG
        if (VIA_DEBUG) fprintf(stderr, "GL_RGBA4 &_mesa_texformat_argb4444\n");    
-#endif
         return &_mesa_texformat_argb4444;
 
     case GL_RGB5_A1:
-#ifdef DEBUG
        if (VIA_DEBUG) fprintf(stderr, "GL_RGB5_A1 &_mesa_texformat_argb1555\n");
-#endif
         return &_mesa_texformat_argb1555;    
     case GL_RGBA:
     case GL_RGBA8:
     case GL_RGBA12:
     case GL_RGBA16:    
     case GL_RGB10_A2:
-#ifdef DEBUG
        if (VIA_DEBUG) fprintf(stderr, "GL_RGBA &_mesa_texformat_argb8888\n");
-#endif
         return &_mesa_texformat_argb8888;
     case GL_ALPHA:     
     case GL_ALPHA4:            
@@ -388,34 +321,20 @@ viaChooseTexFormat(GLcontext *ctx, GLint internalFormat,
 
 void viaInitTextureFuncs(struct dd_function_table * functions)
 {
-#ifdef DEBUG
     if (VIA_DEBUG) fprintf(stderr, "viaInitTextureFuncs - in\n");
-#endif    
-    functions->TexEnv = viaTexEnv;
     functions->ChooseTextureFormat = viaChooseTexFormat;
     functions->TexImage1D = viaTexImage1D;
     functions->TexImage2D = viaTexImage2D;
-    functions->TexImage3D = _mesa_store_teximage3d;
     functions->TexSubImage1D = viaTexSubImage1D;
     functions->TexSubImage2D = viaTexSubImage2D;
-    functions->TexSubImage3D = _mesa_store_texsubimage3d;
-    functions->CopyTexImage1D = _swrast_copy_teximage1d;
-    functions->CopyTexImage2D = _swrast_copy_teximage2d;
-    functions->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
-    functions->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
-    functions->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
 
     functions->NewTextureObject = _mesa_new_texture_object;
     functions->BindTexture = viaBindTexture;
     functions->DeleteTexture = viaDeleteTexture;
-    functions->TexParameter = viaTexParameter;
     functions->UpdateTexturePalette = 0;
     functions->IsTextureResident = viaIsTextureResident;
-    functions->TestProxyTexImage = _mesa_test_proxy_teximage;
 
-#ifdef DEBUG
     if (VIA_DEBUG) fprintf(stderr, "viaInitTextureFuncs - out\n");
-#endif
 }
 
 void viaInitTextures(GLcontext *ctx)