svga: fix max_lod clamping in update_tss_binding()
authorBrian Paul <brianp@vmware.com>
Wed, 29 Feb 2012 14:52:18 +0000 (07:52 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 29 Feb 2012 15:34:37 +0000 (08:34 -0700)
After biasing we need to clamp to be sure we don't exceed the number of
levels in the mipmap.  This fixes an assertion at svga_sampler_view.c:70

v2: simplify the biasing, clamping code per Jose's suggestion.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_state_tss.c

index 8eb0dbf..d5ed804 100644 (file)
@@ -87,8 +87,8 @@ update_tss_binding(struct svga_context *svga,
       /* get min max lod */
       if (sv) {
          min_lod = MAX2(0, (s->view_min_lod + sv->u.tex.first_level));
-         max_lod = MIN2(s->view_max_lod, sv->texture->last_level);
-         max_lod += sv->u.tex.first_level;
+         max_lod = MIN2(s->view_max_lod + sv->u.tex.first_level,
+                        sv->texture->last_level);
          texture = sv->texture;
       } else {
          min_lod = 0;