[Mesa-dev] [PATCH 2/2] intel: Skip texture validation logic when nothing has changed.

Eric Anholt eric at anholt.net
Sun Dec 23 23:43:33 PST 2012


Improves GLBenchmark 2.1 offscreen performance by 3.2% +/- 1.5% (n=52).
---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c  |    3 +++
 src/mesa/drivers/dri/intel/intel_tex.c          |    4 ++++
 src/mesa/drivers/dri/intel/intel_tex_image.c    |    1 +
 src/mesa/drivers/dri/intel/intel_tex_obj.h      |    6 ++++++
 src/mesa/drivers/dri/intel/intel_tex_validate.c |   18 ++++++++++++++++--
 5 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 6c883e7..9bf8388 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -773,6 +773,8 @@ intel_miptree_copy_teximage(struct intel_context *intel,
 			    struct intel_mipmap_tree *dst_mt)
 {
    struct intel_mipmap_tree *src_mt = intelImage->mt;
+   struct intel_texture_object *intel_obj =
+      intel_texture_object(intelImage->base.Base.TexObject);
    int level = intelImage->base.Base.Level;
    int face = intelImage->base.Base.Face;
    GLuint depth = intelImage->base.Base.Depth;
@@ -782,6 +784,7 @@ intel_miptree_copy_teximage(struct intel_context *intel,
    }
 
    intel_miptree_reference(&intelImage->mt, dst_mt);
+   intel_obj->needs_validate = true;
 }
 
 bool
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
index 6820f98..a2a3693 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -36,6 +36,8 @@ intelNewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
    DBG("%s\n", __FUNCTION__);
    _mesa_initialize_texture_object(&obj->base, name, target);
 
+   obj->needs_validate = true;
+
    return &obj->base;
 }
 
@@ -107,6 +109,8 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx,
           image->Width, image->Height, image->Depth, intel_image->mt);
    }
 
+   intel_texobj->needs_validate = true;
+
    return true;
 }
 
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index cc4d49f..7361e6a 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -274,6 +274,7 @@ intel_set_texture_image_region(struct gl_context *ctx,
 						     region);
    if (intel_image->mt == NULL)
        return;
+   intel_texobj->needs_validate = true;
 
    intel_image->mt->offset = offset;
    intel_image->base.RowStride = region->pitch;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_obj.h b/src/mesa/drivers/dri/intel/intel_tex_obj.h
index d1a5f05..8c166b4 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_obj.h
+++ b/src/mesa/drivers/dri/intel/intel_tex_obj.h
@@ -49,6 +49,12 @@ struct intel_texture_object
     * regions will be copied to this region and the old storage freed.
     */
    struct intel_mipmap_tree *mt;
+
+   /**
+    * Set when mipmap trees in the texture images of this texture object
+    * might not all be the mipmap tree above.
+    */
+   bool needs_validate;
 };
 
 
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
index 3f21601..fee5842 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
@@ -21,12 +21,18 @@ intel_update_max_level(struct intel_texture_object *intelObj,
 		       struct gl_sampler_object *sampler)
 {
    struct gl_texture_object *tObj = &intelObj->base;
+   int maxlevel;
 
    if (sampler->MinFilter == GL_NEAREST ||
        sampler->MinFilter == GL_LINEAR) {
-      intelObj->_MaxLevel = tObj->BaseLevel;
+      maxlevel = tObj->BaseLevel;
    } else {
-      intelObj->_MaxLevel = tObj->_MaxLevel;
+      maxlevel = tObj->_MaxLevel;
+   }
+
+   if (intelObj->_MaxLevel != maxlevel) {
+      intelObj->_MaxLevel = maxlevel;
+      intelObj->needs_validate = true;
    }
 }
 
@@ -55,6 +61,12 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
    /* What levels must the tree include at a minimum?
     */
    intel_update_max_level(intelObj, sampler);
+   if (intelObj->mt && intelObj->mt->first_level != tObj->BaseLevel)
+      intelObj->needs_validate = true;
+
+   if (!intelObj->needs_validate)
+      return true;
+
    firstImage = intel_texture_image(tObj->Image[0][tObj->BaseLevel]);
 
    /* Check tree can hold all active levels.  Check tree matches
@@ -122,6 +134,8 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
       }
    }
 
+   intelObj->needs_validate = false;
+
    return true;
 }
 
-- 
1.7.10.4



More information about the mesa-dev mailing list