Mesa (master): st/mesa: move some texture size calculation code

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


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

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

st/mesa: move some texture size calculation code

---

 src/mesa/state_tracker/st_cb_texture.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 60e1d42..cd15e3a 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -526,7 +526,6 @@ st_TexImage(GLcontext * ctx,
    struct pipe_screen *screen = st->pipe->screen;
    struct st_texture_object *stObj = st_texture_object(texObj);
    struct st_texture_image *stImage = st_texture_image(texImage);
-   GLint texelBytes, sizeInBytes;
    GLuint dstRowStride = 0;
    struct gl_pixelstore_attrib unpackNB;
    enum pipe_transfer_usage transfer_usage = 0;
@@ -562,14 +561,6 @@ st_TexImage(GLcontext * ctx,
 
    _mesa_set_fetch_functions(texImage, dims);
 
-   if (_mesa_is_format_compressed(texImage->TexFormat)) {
-      /* must be a compressed format */
-      texelBytes = 0;
-   }
-   else {
-      texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
-   }
-
    /* Release the reference to a potentially orphaned buffer.   
     * Release any old malloced memory.
     */
@@ -667,6 +658,7 @@ st_TexImage(GLcontext * ctx,
    }
 
    if (stImage->pt) {
+      /* Store the image in the gallium texture memory buffer */
       if (format == GL_DEPTH_COMPONENT &&
           util_format_is_depth_and_stencil(stImage->pt->format))
          transfer_usage = PIPE_TRANSFER_READ_WRITE;
@@ -682,6 +674,8 @@ st_TexImage(GLcontext * ctx,
    }
    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,
@@ -691,6 +685,8 @@ st_TexImage(GLcontext * ctx,
          assert(dims != 3);
       }
       else {
+         GLint texelBytes;
+         texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
          dstRowStride = width * texelBytes;
          sizeInBytes = depth * dstRowStride * height;
       }
@@ -707,7 +703,7 @@ st_TexImage(GLcontext * ctx,
       goto done;
 
    DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
-       width, height, depth, width * texelBytes, dstRowStride);
+       width, height, depth, width, dstRowStride);
 
    /* Copy data.  Would like to know when it's ok for us to eg. use
     * the blitter to copy.  Or, use the hardware to do the format




More information about the mesa-commit mailing list