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

Author: Xavier Chantry <chantry.xav...@gmail.com>
Date:   Sat Mar 13 19:28:07 2010 +0100

dri/nouveau: only reallocate texture when needed

nouveau reallocated the mipmap tree on every MIN_FILTER call to account
for mipmap change. We only need to do this if the texture does not fit
in the existing mipmap tree. This gives a big performance boost for a
game like bzflag which changes MIN_FILTER all the time for its font
rendering.

Signed-off-by: Xavier Chantry <chantry.xav...@gmail.com>
Signed-off-by: Francisco Jerez <curroje...@riseup.net>

---

 src/mesa/drivers/dri/nouveau/nouveau_texture.c |   25 +++++++++++++----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c 
b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index bf365bf..20bc0f6 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -177,15 +177,15 @@ nouveau_choose_tex_format(GLcontext *ctx, GLint 
internalFormat,
 }
 
 static GLboolean
-teximage_fits(struct gl_texture_object *t, int level,
-             struct gl_texture_image *ti)
+teximage_fits(struct gl_texture_object *t, int level)
 {
        struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level];
+       struct gl_texture_image *ti = t->Image[0][level];
 
-       return t->Target == GL_TEXTURE_RECTANGLE ||
-               (s->bo && s->width == ti->Width &&
-                s->height == ti->Height &&
-                s->format == ti->TexFormat);
+       return ti && (t->Target == GL_TEXTURE_RECTANGLE ||
+                     (s->bo && s->width == ti->Width &&
+                      s->height == ti->Height &&
+                      s->format == ti->TexFormat));
 }
 
 static GLboolean
@@ -195,7 +195,7 @@ validate_teximage(GLcontext *ctx, struct gl_texture_object 
*t,
 {
        struct gl_texture_image *ti = t->Image[0][level];
 
-       if (ti && teximage_fits(t, level, ti)) {
+       if (teximage_fits(t, level)) {
                struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
                struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
 
@@ -304,9 +304,12 @@ nouveau_texture_validate(GLcontext *ctx, struct 
gl_texture_object *t)
 void
 nouveau_texture_reallocate(GLcontext *ctx, struct gl_texture_object *t)
 {
-       texture_dirty(t);
-       relayout_texture(ctx, t);
-       nouveau_texture_validate(ctx, t);
+       if (!teximage_fits(t, t->BaseLevel) ||
+           !teximage_fits(t, get_last_level(t))) {
+               texture_dirty(t);
+               relayout_texture(ctx, t);
+               nouveau_texture_validate(ctx, t);
+       }
 }
 
 static unsigned
@@ -364,7 +367,7 @@ nouveau_teximage(GLcontext *ctx, GLint dims, GLenum target, 
GLint level,
        }
 
        if (level == t->BaseLevel) {
-               if (!teximage_fits(t, level, ti))
+               if (!teximage_fits(t, level))
                        relayout_texture(ctx, t);
                nouveau_texture_validate(ctx, t);
        }

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to