mesa: Remove unnecessary parameters from AllocTextureImageBuffer
authorPauli Nieminen <pauli.nieminen@linux.intel.com>
Tue, 12 Jun 2012 18:38:44 +0000 (21:38 +0300)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 12 Aug 2012 22:49:28 +0000 (15:49 -0700)
Size and format information is always stored in gl_texture_image
structure. That makes it preferable to remove duplicate information from
parameters to make interface easier to understand.

Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/intel/intel_tex.c
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/radeon/radeon_texture.c
src/mesa/main/dd.h
src/mesa/main/mipmap.c
src/mesa/main/texstore.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/swrast/s_texture.c
src/mesa/swrast/swrast.h

index b3ac2267b7d86d15ed5160f1b9d0a96bef3856f9..92481b9b55f7a858776def611f8091be7b93e96f 100644 (file)
@@ -51,9 +51,7 @@ intelDeleteTextureObject(struct gl_context *ctx,
 
 static GLboolean
 intel_alloc_texture_image_buffer(struct gl_context *ctx,
-                                struct gl_texture_image *image,
-                                gl_format format, GLsizei width,
-                                GLsizei height, GLsizei depth)
+                                struct gl_texture_image *image)
 {
    struct intel_context *intel = intel_context(ctx);
    struct intel_texture_image *intel_image = intel_texture_image(image);
@@ -84,14 +82,14 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
    assert(!intel_image->base.ImageOffsets);
    intel_image->base.ImageOffsets = malloc(slices * sizeof(GLuint));
 
-   _swrast_init_texture_image(image, width, height, depth);
+   _swrast_init_texture_image(image);
 
    if (intel_texobj->mt &&
        intel_miptree_match_image(intel_texobj->mt, image)) {
       intel_miptree_reference(&intel_image->mt, intel_texobj->mt);
       DBG("%s: alloc obj %p level %d %dx%dx%d using object's miptree %p\n",
           __FUNCTION__, texobj, image->Level,
-          width, height, depth, intel_texobj->mt);
+          image->Width, image->Height, image->Depth, intel_texobj->mt);
    } else {
       intel_image->mt = intel_miptree_create_for_teximage(intel, intel_texobj,
                                                           intel_image,
@@ -106,7 +104,7 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
 
       DBG("%s: alloc obj %p level %d %dx%dx%d using new miptree %p\n",
           __FUNCTION__, texobj, image->Level,
-          width, height, depth, intel_image->mt);
+          image->Width, image->Height, image->Depth, intel_image->mt);
    }
 
    return true;
index acb21fbc7e4abefd15ccf58aefc447dadaf993c7..fe9040cf1b6f9b1384fee1fb050bca0256d243a9 100644 (file)
@@ -160,8 +160,7 @@ try_pbo_upload(struct gl_context *ctx,
       return false;
    }
 
-   ctx->Driver.AllocTextureImageBuffer(ctx, image, image->TexFormat,
-                                       image->Width, image->Height, 1);
+   ctx->Driver.AllocTextureImageBuffer(ctx, image);
 
    if (!intelImage->mt) {
       DBG("%s: no miptree\n", __FUNCTION__);
index 04f3e232b3727fb6a51cfd64bd24ee7c26696f81..157cc096a3151a314dca45ec47bc785837325e08 100644 (file)
@@ -103,9 +103,7 @@ radeonDeleteTextureImage(struct gl_context *ctx, struct gl_texture_image *img)
 
 static GLboolean
 radeonAllocTextureImageBuffer(struct gl_context *ctx,
-                             struct gl_texture_image *timage,
-                             gl_format format, GLsizei width,
-                             GLsizei height, GLsizei depth)
+                             struct gl_texture_image *timage)
 {
        radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
        radeon_texture_image *image = get_radeon_texture_image(timage);
index 546e360819a8269fdb54f85556248eecd4353657..4346b9e61550aaf3d9fb614f90e9b0c63da9fb5d 100644 (file)
@@ -327,9 +327,7 @@ struct dd_function_table {
 
    /** Called to allocate memory for a single texture image */
    GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
-                                        struct gl_texture_image *texImage,
-                                        gl_format format, GLsizei width,
-                                        GLsizei height, GLsizei depth);
+                                        struct gl_texture_image *texImage);
 
    /** Free the memory for a single texture image */
    void (*FreeTextureImageBuffer)(struct gl_context *ctx,
index 9f531ae20bbf4cdea924182da52417f10914f0e9..00d3e8f9ed60b0324eb15a88e154222cdbe4022f 100644 (file)
@@ -1865,8 +1865,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx,
                                     width, height, depth,
                                     border, intFormat, format);
 
-         ctx->Driver.AllocTextureImageBuffer(ctx, dstImage,
-                                             format, width, height, depth);
+         ctx->Driver.AllocTextureImageBuffer(ctx, dstImage);
 
          /* in case the mipmap level is part of an FBO: */
          _mesa_update_fbo_texture(ctx, texObj, face, level);
index 52eef3ebab37f920f34c9d425ce915e672a3fd6a..393b9a8a5f1f4ba15f9c5936e629e51fae75c22b 100644 (file)
@@ -4345,9 +4345,7 @@ _mesa_store_teximage(struct gl_context *ctx,
       return;
 
    /* allocate storage for texture data */
-   if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
-                                            texImage->Width, texImage->Height,
-                                            texImage->Depth)) {
+   if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims);
       return;
    }
@@ -4402,8 +4400,7 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
    ASSERT(texImage->Depth == 1);
 
    /* allocate storage for texture data */
-   if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
-                                            width, height, 1)) {
+   if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
       return;
    }
index 0c4e8a8f47b365c4afdbe5fa1756c8ef49d0c449..5385ed8a4b91a7971aac1dbaee6b34d202bfee0e 100644 (file)
@@ -415,20 +415,18 @@ guess_and_alloc_texture(struct st_context *st,
  */
 static GLboolean
 st_AllocTextureImageBuffer(struct gl_context *ctx,
-                           struct gl_texture_image *texImage,
-                           gl_format format, GLsizei width,
-                           GLsizei height, GLsizei depth)
+                           struct gl_texture_image *texImage)
 {
    struct st_context *st = st_context(ctx);
    struct st_texture_image *stImage = st_texture_image(texImage);
    struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
    const GLuint level = texImage->Level;
+   GLuint width = texImage->Width;
+   GLuint height = texImage->Height;
+   GLuint depth = texImage->Depth;
 
    DBG("%s\n", __FUNCTION__);
 
-   assert(width > 0);
-   assert(height > 0);
-   assert(depth > 0);
    assert(!stImage->TexData);
    assert(!stImage->pt); /* xxx this might be wrong */
 
index 9718367a8df13a086eaf597ffcb61166bae34e93..8df4b84398ee8e8915017684aaa63ba7b5a029de 100644 (file)
@@ -63,40 +63,34 @@ _swrast_delete_texture_image(struct gl_context *ctx,
  */
 GLboolean
 _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
-                                   struct gl_texture_image *texImage,
-                                   gl_format format, GLsizei width,
-                                   GLsizei height, GLsizei depth)
+                                   struct gl_texture_image *texImage)
 {
    struct swrast_texture_image *swImg = swrast_texture_image(texImage);
-   GLuint bytes = _mesa_format_image_size(format, width, height, depth);
+   GLuint bytes = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
+                                          texImage->Height, texImage->Depth);
    GLuint i;
 
-   /* This _should_ be true (revisit if these ever fail) */
-   assert(texImage->Width == width);
-   assert(texImage->Height == height);
-   assert(texImage->Depth == depth);
-
    assert(!swImg->Buffer);
    swImg->Buffer = _mesa_align_malloc(bytes, 512);
    if (!swImg->Buffer)
       return GL_FALSE;
 
    /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
-   swImg->RowStride = width;
+   swImg->RowStride = texImage->Width;
 
    /* Allocate the ImageOffsets array and initialize to typical values.
     * We allocate the array for 1D/2D textures too in order to avoid special-
     * case code in the texstore routines.
     */
-   swImg->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint));
+   swImg->ImageOffsets = (GLuint *) malloc(texImage->Depth * sizeof(GLuint));
    if (!swImg->ImageOffsets)
       return GL_FALSE;
 
-   for (i = 0; i < depth; i++) {
-      swImg->ImageOffsets[i] = i * width * height;
+   for (i = 0; i < texImage->Depth; i++) {
+      swImg->ImageOffsets[i] = i * texImage->Width * texImage->Height;
    }
 
-   _swrast_init_texture_image(texImage, width, height, depth);
+   _swrast_init_texture_image(texImage);
 
    return GL_TRUE;
 }
@@ -110,14 +104,13 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
  * Returns GL_TRUE on success, GL_FALSE on memory allocation failure.
  */
 void
-_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
-                           GLsizei height, GLsizei depth)
+_swrast_init_texture_image(struct gl_texture_image *texImage)
 {
    struct swrast_texture_image *swImg = swrast_texture_image(texImage);
 
-   if ((width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
-       (height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
-       (depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
+   if ((texImage->Width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
+       (texImage->Height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
+       (texImage->Depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
       swImg->_IsPowerOfTwo = GL_TRUE;
    else
       swImg->_IsPowerOfTwo = GL_FALSE;
@@ -348,11 +341,7 @@ _swrast_AllocTextureStorage(struct gl_context *ctx,
    for (face = 0; face < numFaces; face++) {
       for (level = 0; level < levels; level++) {
          struct gl_texture_image *texImage = texObj->Image[face][level];
-         if (!_swrast_alloc_texture_image_buffer(ctx, texImage,
-                                                 texImage->TexFormat,
-                                                 texImage->Width,
-                                                 texImage->Height,
-                                                 texImage->Depth)) {
+         if (!_swrast_alloc_texture_image_buffer(ctx, texImage)) {
             return GL_FALSE;
          }
       }
index a299e6fda87895b92bb52a98e49cb977e64df29e..97cc5ee631329dd978a5bd8fc11c21a9333a1643 100644 (file)
@@ -215,13 +215,10 @@ _swrast_delete_texture_image(struct gl_context *ctx,
 
 extern GLboolean
 _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
-                                   struct gl_texture_image *texImage,
-                                   gl_format format, GLsizei width,
-                                   GLsizei height, GLsizei depth);
+                                   struct gl_texture_image *texImage);
 
 extern void
-_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
-                           GLsizei height, GLsizei depth);
+_swrast_init_texture_image(struct gl_texture_image *texImage);
 
 extern void
 _swrast_free_texture_image_buffer(struct gl_context *ctx,