Mesa (master): st/mesa: consolidate and clean-up texture memory allocation code

Brian Paul brianp at kemper.freedesktop.org
Mon May 3 23:14:27 UTC 2010


Module: Mesa
Branch: master
Commit: c7d1d34c580e8c76bf2f3f8687223e648e7ec5f1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c7d1d34c580e8c76bf2f3f8687223e648e7ec5f1

Author: Brian Paul <brianp at vmware.com>
Date:   Mon May  3 15:48:00 2010 -0600

st/mesa: consolidate and clean-up texture memory allocation code

---

 src/mesa/state_tracker/st_cb_texture.c |   33 ++++++++++---------------------
 1 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index cd15e3a..d99bba6 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -555,6 +555,11 @@ st_TexImage(GLcontext * ctx,
       texImage->Border = 0;
       border = 0;
    }
+   else {
+      assert(texImage->Width == width);
+      assert(texImage->Height == height);
+      assert(texImage->Depth == depth);
+   }
 
    stImage->face = _mesa_tex_target_to_face(target);
    stImage->level = level;
@@ -666,32 +671,17 @@ st_TexImage(GLcontext * ctx,
          transfer_usage = PIPE_TRANSFER_WRITE;
 
       texImage->Data = st_texture_image_map(st, stImage, 0,
-                                            transfer_usage, 0, 0,
-                                            stImage->base.Width,
-                                            stImage->base.Height);
+                                            transfer_usage, 0, 0, width, height);
       if(stImage->transfer)
          dstRowStride = stImage->transfer->stride;
    }
    else {
       /* Allocate regular memory and store the image there temporarily.   */
-      GLint sizeInBytes;
-
-      if (_mesa_is_format_compressed(texImage->TexFormat)) {
-         sizeInBytes = _mesa_format_image_size(texImage->TexFormat,
-                                               texImage->Width,
-                                               texImage->Height,
-                                               texImage->Depth);
-         dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
-         assert(dims != 3);
-      }
-      else {
-         GLint texelBytes;
-         texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
-         dstRowStride = width * texelBytes;
-         sizeInBytes = depth * dstRowStride * height;
-      }
+      GLuint imageSize = _mesa_format_image_size(texImage->TexFormat,
+                                                 width, height, depth);
+      dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
 
-      texImage->Data = _mesa_align_malloc(sizeInBytes, 16);
+      texImage->Data = _mesa_align_malloc(imageSize, 16);
    }
 
    if (!texImage->Data) {
@@ -754,8 +744,7 @@ st_TexImage(GLcontext * ctx,
             /* map next slice of 3D texture */
 	    texImage->Data = st_texture_image_map(st, stImage, i + 1,
                                                   transfer_usage, 0, 0,
-                                                  stImage->base.Width,
-                                                  stImage->base.Height);
+                                                  width, height);
 	    src += srcImageStride;
 	 }
       }




More information about the mesa-commit mailing list