i965: set mt->cpp differently with compressed texture
authorXiang, Haihao <haihao.xiang@intel.com>
Fri, 10 Aug 2007 07:14:12 +0000 (15:14 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 10 Aug 2007 07:14:12 +0000 (15:14 +0800)
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_tex_validate.c

index 8486086b274d5cdb5ff7a4279ece19a78963e49a..d7b1946ce3424de2ae109628b541e8b41a956a1b 100644 (file)
@@ -75,7 +75,7 @@ struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel,
    mt->width0 = width0;
    mt->height0 = height0;
    mt->depth0 = depth0;
-   mt->cpp = compressed ? 2 : cpp;
+   mt->cpp = cpp;
    mt->compressed = compressed;
 
    switch (intel->intelScreen->deviceID) {
index 44ee94614d58822c5aa8d2c1f05b83b272c5eaa6..8c05e7cdabccf7177ef5461c0feefaab5878c506 100644 (file)
@@ -122,6 +122,29 @@ static void intel_texture_invalidate_cb( struct intel_context *intel,
    intel_texture_invalidate( (struct intel_texture_object *) ptr );
 }
 
+#include "texformat.h"
+static GLuint intel_compressed_num_bytes(GLenum mesaFormat)
+{
+    GLuint bytes = 0;
+
+    switch (mesaFormat) {
+    case MESA_FORMAT_RGB_FXT1:
+    case MESA_FORMAT_RGBA_FXT1:
+    case MESA_FORMAT_RGB_DXT1:
+    case MESA_FORMAT_RGBA_DXT1:
+        bytes = 2;
+        break;
+
+    case MESA_FORMAT_RGBA_DXT3:
+    case MESA_FORMAT_RGBA_DXT5:
+        bytes = 4;
+    
+    default:
+        break;
+    }
+
+    return bytes;
+}
 
 /*  
  */
@@ -132,7 +155,8 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
    GLuint face, i;
    GLuint nr_faces = 0;
    struct gl_texture_image *firstImage;
-
+   GLuint cpp = 0;
+   
    if( tObj == intel->frame_buffer_texobj )
       return GL_FALSE;
    
@@ -165,6 +189,12 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
 
 
 
+   if (firstImage->IsCompressed) {
+       cpp = intel_compressed_num_bytes(firstImage->TexFormat->MesaFormat);
+   } else {
+       cpp = firstImage->TexFormat->TexelBytes;
+   }
+       
    /* Check tree can hold all active levels.  Check tree matches
     * target, imageFormat, etc.
     */
@@ -176,7 +206,7 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
        intelObj->mt->width0 != firstImage->Width ||
        intelObj->mt->height0 != firstImage->Height ||
        intelObj->mt->depth0 != firstImage->Depth ||
-       intelObj->mt->cpp != firstImage->TexFormat->TexelBytes ||
+       intelObj->mt->cpp != cpp ||
        intelObj->mt->compressed != firstImage->IsCompressed)) 
    {
       intel_miptree_destroy(intel, intelObj->mt);
@@ -199,7 +229,7 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
                                          firstImage->Width,
                                          firstImage->Height,
                                          firstImage->Depth,
-                                         firstImage->TexFormat->TexelBytes,
+                                         cpp,
                                          firstImage->IsCompressed);
 
       /* Tell the buffer manager that we will manage the backing