Mesa (master): st/mesa: fix incorrect texture size allocation in st_finalize_texture()

Brian Paul brianp at kemper.freedesktop.org
Mon Feb 21 22:16:21 UTC 2011


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

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Feb 21 15:11:44 2011 -0700

st/mesa: fix incorrect texture size allocation in st_finalize_texture()

If finalizing a non-POW mipmapped texture with an odd-sized base texture
image we were allocating the wrong size of gallium texture (off by one).
Need to be more careful about computing the base texture image size.

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=34463

---

 src/mesa/state_tracker/st_cb_texture.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 7568b31..a40a79b 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1746,9 +1746,24 @@ st_finalize_texture(struct gl_context *ctx,
 
    /* Find gallium format for the Mesa texture */
    firstImageFormat = st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
-   st_gl_texture_dims_to_pipe_dims(stObj->base.Target, stObj->width0,
-                                   stObj->height0, stObj->depth0,
-                                   &ptWidth, &ptHeight, &ptDepth, &ptLayers);
+
+   /* Find size of level=0 Gallium mipmap image, plus number of texture layers */
+   {
+      GLuint width, height, depth;
+      if (!guess_base_level_size(stObj->base.Target,
+                                 firstImage->base.Width2,
+                                 firstImage->base.Height2,
+                                 firstImage->base.Depth2,
+                                 stObj->base.BaseLevel,
+                                 &width, &height, &depth)) {
+         width = stObj->width0;
+         height = stObj->height0;
+         depth = stObj->depth0;
+      }
+      /* convert GL dims to Gallium dims */
+      st_gl_texture_dims_to_pipe_dims(stObj->base.Target, width, height, depth,
+                                      &ptWidth, &ptHeight, &ptDepth, &ptLayers);
+   }
 
    /* If we already have a gallium texture, check that it matches the texture
     * object's format, target, size, num_levels, etc.




More information about the mesa-commit mailing list