Mesa (master): i965: Stop allocating miptrees with first_level != 0.

Eric Anholt anholt at kemper.freedesktop.org
Mon Sep 30 21:36:03 UTC 2013


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 30 12:37:15 2013 -0700

i965: Stop allocating miptrees with first_level != 0.

If the caller shows up with GL_BASE_LEVEL != 0, it doesn't mean that the
texture will over the course of its lifetime have that nonzero baselevel,
it means that the caller is filling the texture from the bottom up for
some reason (one could imagine demand-loading detailed texture layers at
runtime, for example).  If we allocate from just the current baselevel, it
means when they come along with the next level up, we'll have to allocate
a new miptree and copy all of our bits out of the first miptree.

Reviewed-by: Chad Versace <chad.versace at linux.intel.com>

---

 src/mesa/drivers/dri/i965/intel_tex_image.c |   23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 725d315..fe274bf 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -35,7 +35,6 @@ intel_miptree_create_for_teximage(struct brw_context *brw,
 				  struct intel_texture_image *intelImage,
 				  bool expect_accelerated_upload)
 {
-   GLuint firstLevel;
    GLuint lastLevel;
    int width, height, depth;
    GLuint i;
@@ -45,16 +44,8 @@ intel_miptree_create_for_teximage(struct brw_context *brw,
 
    DBG("%s\n", __FUNCTION__);
 
-   /* If this image disrespects BaseLevel, allocate from level zero.
-    * Usually BaseLevel == 0, so it's unlikely to happen.
-    */
-   if (intelImage->base.Base.Level < intelObj->base.BaseLevel)
-      firstLevel = 0;
-   else
-      firstLevel = intelObj->base.BaseLevel;
-
    /* Figure out image dimensions at start level. */
-   for (i = intelImage->base.Base.Level; i > firstLevel; i--) {
+   for (i = intelImage->base.Base.Level; i > 0; i--) {
       width <<= 1;
       if (height != 1)
          height <<= 1;
@@ -69,19 +60,17 @@ intel_miptree_create_for_teximage(struct brw_context *brw,
     */
    if ((intelObj->base.Sampler.MinFilter == GL_NEAREST ||
         intelObj->base.Sampler.MinFilter == GL_LINEAR) &&
-       intelImage->base.Base.Level == firstLevel &&
-       firstLevel == 0) {
-      lastLevel = firstLevel;
+       intelImage->base.Base.Level == 0) {
+      lastLevel = 0;
    } else {
-      lastLevel = (firstLevel +
-                   _mesa_get_tex_max_num_levels(intelObj->base.Target,
-                                                width, height, depth) - 1);
+      lastLevel = _mesa_get_tex_max_num_levels(intelObj->base.Target,
+                                               width, height, depth) - 1;
    }
 
    return intel_miptree_create(brw,
 			       intelObj->base.Target,
 			       intelImage->base.Base.TexFormat,
-			       firstLevel,
+			       0,
 			       lastLevel,
 			       width,
 			       height,




More information about the mesa-commit mailing list