From 7a642d4a9763da873074d38726b752e2a4174b0d Mon Sep 17 00:00:00 2001
From: Cooper Yuan <cooperyuan@gmail.com>
Date: Wed, 30 Sep 2009 15:39:43 +0800
Subject: [PATCH] st/mesa: fix texture lastLevel calculation

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

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 771a0e2..e0718bd 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1765,8 +1765,13 @@ st_finalize_texture(GLcontext *ctx,
        * from the st_generate_mipmap() function when the texture object is
        * incomplete.  In that case, we'll have set stObj->lastLevel before
        * we get here.
+       * If face 0 has more than one image, that means it's a mipmap case,
+       * otherwise the lastLevel should be BaseLevel.
        */
-      stObj->lastLevel = stObj->base._MaxLevel - stObj->base.BaseLevel;
+      if (stObj->base.Image[0][1])
+          stObj->lastLevel = stObj->base._MaxLevel - stObj->base.BaseLevel;
+      else
+          stObj->lastLevel = stObj->base.BaseLevel;
    }
 
    firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
-- 
1.5.3.4

