intel: Calculate compress_byte in intel_miptree_create.
authorEric Anholt <eric@anholt.net>
Thu, 9 Jun 2011 17:18:36 +0000 (10:18 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 14 Jun 2011 18:17:39 +0000 (11:17 -0700)
One less argument and thing to get wrong.

src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.h
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/intel/intel_tex_validate.c

index 02f40f51dfcb188c1423de091cd378f660654d86..fbe93c270e041d342b9abafbcc259ab3a578674c 100644 (file)
@@ -633,10 +633,7 @@ intel_render_texture(struct gl_context * ctx,
       struct intel_context *intel = intel_context(ctx);
       struct intel_mipmap_tree *old_mt = intel_image->mt;
       struct intel_mipmap_tree *new_mt;
-      int comp_byte = 0, texel_bytes;
-
-      if (_mesa_is_format_compressed(intel_image->base.TexFormat))
-        comp_byte = intel_compressed_num_bytes(intel_image->base.TexFormat);
+      int texel_bytes;
 
       texel_bytes = _mesa_get_format_bytes(intel_image->base.TexFormat);
 
@@ -647,7 +644,7 @@ intel_render_texture(struct gl_context * ctx,
                                    intel_image->base.Width,
                                    intel_image->base.Height,
                                    intel_image->base.Depth,
-                                   texel_bytes, comp_byte, GL_TRUE);
+                                   texel_bytes, GL_TRUE);
 
       intel_miptree_image_copy(intel,
                                new_mt,
index be18e515df0219a5e98d378150a1f0032f6c2aae..f9dd9f3abb7315aaa4fc7117f0946715f75fe2b5 100644 (file)
@@ -29,6 +29,7 @@
 #include "intel_mipmap_tree.h"
 #include "intel_regions.h"
 #include "intel_tex_layout.h"
+#include "intel_tex.h"
 #include "main/enums.h"
 #include "main/formats.h"
 
@@ -60,17 +61,21 @@ intel_miptree_create_internal(struct intel_context *intel,
                              GLuint last_level,
                              GLuint width0,
                              GLuint height0,
-                             GLuint depth0, GLuint cpp, GLuint compress_byte,
+                             GLuint depth0, GLuint cpp,
                              uint32_t tiling)
 {
    GLboolean ok;
    struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+   int compress_byte = 0;
 
    DBG("%s target %s format %s level %d..%d <-- %p\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target),
        _mesa_get_format_name(format),
        first_level, last_level, mt);
 
+   if (_mesa_is_format_compressed(format))
+      compress_byte = intel_compressed_num_bytes(format);
+
    mt->target = target_to_target(target);
    mt->format = format;
    mt->first_level = first_level;
@@ -109,14 +114,14 @@ intel_miptree_create(struct intel_context *intel,
                     GLuint last_level,
                     GLuint width0,
                     GLuint height0,
-                    GLuint depth0, GLuint cpp, GLuint compress_byte,
+                    GLuint depth0, GLuint cpp,
                     GLboolean expect_accelerated_upload)
 {
    struct intel_mipmap_tree *mt;
    uint32_t tiling = I915_TILING_NONE;
    GLenum base_format = _mesa_get_format_base_format(format);
 
-   if (intel->use_texture_tiling && compress_byte == 0) {
+   if (intel->use_texture_tiling && !_mesa_is_format_compressed(format)) {
       if (intel->gen >= 4 &&
          (base_format == GL_DEPTH_COMPONENT ||
           base_format == GL_DEPTH_STENCIL_EXT))
@@ -127,7 +132,7 @@ intel_miptree_create(struct intel_context *intel,
 
    mt = intel_miptree_create_internal(intel, target, format,
                                      first_level, last_level, width0,
-                                     height0, depth0, cpp, compress_byte,
+                                     height0, depth0, cpp,
                                      tiling);
    /*
     * pitch == 0 || height == 0  indicates the null texture
@@ -158,15 +163,14 @@ intel_miptree_create_for_region(struct intel_context *intel,
                                GLenum target,
                                gl_format format,
                                struct intel_region *region,
-                               GLuint depth0,
-                               GLuint compress_byte)
+                               GLuint depth0)
 {
    struct intel_mipmap_tree *mt;
 
    mt = intel_miptree_create_internal(intel, target, format,
                                      0, 0,
                                      region->width, region->height, 1,
-                                     region->cpp, compress_byte,
+                                     region->cpp,
                                      I915_TILING_NONE);
    if (!mt)
       return mt;
index c259e5147872f44a60180250fad69d38b1b2030c..a531ecf6b4d45b4d3565e4999fb58793fa028a8e 100644 (file)
@@ -143,7 +143,6 @@ struct intel_mipmap_tree *intel_miptree_create(struct intel_context *intel,
                                                GLuint height0,
                                                GLuint depth0,
                                                GLuint cpp,
-                                               GLuint compress_byte,
                                               GLboolean expect_accelerated_upload);
 
 struct intel_mipmap_tree *
@@ -151,8 +150,7 @@ intel_miptree_create_for_region(struct intel_context *intel,
                                GLenum target,
                                gl_format format,
                                struct intel_region *region,
-                               GLuint depth0,
-                               GLuint compress_byte);
+                               GLuint depth0);
 
 int intel_miptree_pitch_align (struct intel_context *intel,
                               struct intel_mipmap_tree *mt,
index b7d0eb1a44911b8d633c27aad56d575fcccf2364..6fa5c1309df7505074a699c9d8985841017a9a28 100644 (file)
@@ -54,7 +54,7 @@ intel_miptree_create_for_teximage(struct intel_context *intel,
    GLuint width = intelImage->base.Width;
    GLuint height = intelImage->base.Height;
    GLuint depth = intelImage->base.Depth;
-   GLuint i, comp_byte = 0;
+   GLuint i;
    GLuint texelBytes;
 
    DBG("%s\n", __FUNCTION__);
@@ -108,9 +108,6 @@ intel_miptree_create_for_teximage(struct intel_context *intel,
       }
    }
 
-   if (_mesa_is_format_compressed(intelImage->base.TexFormat))
-      comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat);
-
    texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
 
    return intel_miptree_create(intel,
@@ -122,7 +119,6 @@ intel_miptree_create_for_teximage(struct intel_context *intel,
                               height,
                               depth,
                               texelBytes,
-                              comp_byte,
                               expect_accelerated_upload);
 }
 
@@ -692,7 +688,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
    }
 
    mt = intel_miptree_create_for_region(intel, target, texFormat,
-                                       rb->region, 1, 0);
+                                       rb->region, 1);
    if (mt == NULL)
        return;
 
@@ -756,7 +752,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
       return;
 
    mt = intel_miptree_create_for_region(intel, target, image->format,
-                                       image->region, 1, 0);
+                                       image->region, 1);
    if (mt == NULL)
        return;
 
index e810db85c1493df1080873daa677794565e9cda9..84facdbf27e3a41c28151b772a9c59f919722bf5 100644 (file)
@@ -77,7 +77,6 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
    struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
    struct intel_texture_object *intelObj = intel_texture_object(tObj);
    struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
-   int comp_byte = 0;
    int cpp;
    GLuint face, i;
    GLuint nr_faces = 0;
@@ -102,8 +101,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
    }
 
    if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
-      comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat);
-      cpp = comp_byte;
+      cpp = intel_compressed_num_bytes(firstImage->base.TexFormat);
    }
    else
       cpp = _mesa_get_format_bytes(firstImage->base.TexFormat);
@@ -140,7 +138,6 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
                                           firstImage->base.Height,
                                           firstImage->base.Depth,
                                           cpp,
-                                          comp_byte,
                                          GL_TRUE);
       if (!intelObj->mt)
          return GL_FALSE;