gallium: fix some BaseLevel, lastLevel bugs
authorBrian Paul <brian.paul@tungstengraphics.com>
Sat, 3 May 2008 23:01:20 +0000 (17:01 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Sat, 3 May 2008 23:01:20 +0000 (17:01 -0600)
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_cb_texture.c

index 7515bb30cc72b1a500081ac3a2cff77014ee0af2..0c22e03883ac5ace9eea1876f760f987c0d9c6f6 100644 (file)
@@ -148,8 +148,9 @@ update_samplers(struct st_context *st)
             sampler->normalized_coords = 1;
 
          sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias;
-         sampler->min_lod = MAX2(texobj->BaseLevel, texobj->MinLod);
-         sampler->max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod);
+         sampler->min_lod = MAX2(0.0f, texobj->MinLod - texobj->BaseLevel);
+         sampler->max_lod = MIN2(texobj->MaxLevel - texobj->BaseLevel,
+                                 texobj->MaxLod);
 
          sampler->border_color[0] = texobj->BorderColor[RCOMP];
          sampler->border_color[1] = texobj->BorderColor[GCOMP];
index 06caa06e7767b8ab1b8ffbca358862232e9a9ffb..21c0141ac3c1f6b35c50c2a5974871f04b6c7cf4 100644 (file)
@@ -1363,7 +1363,7 @@ calculate_first_last_level(struct st_texture_object *stObj)
       }
       else {
          firstLevel = 0;
-         lastLevel = MIN2(tObj->MaxLevel, tObj->Image[0][0]->WidthLog2);
+         lastLevel = MIN2(tObj->MaxLevel, tObj->Image[0][tObj->BaseLevel]->WidthLog2);
       }
       break;
    case GL_TEXTURE_RECTANGLE_NV:
@@ -1488,6 +1488,9 @@ st_finalize_texture(GLcontext *ctx,
        st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat) ||
        stObj->pt->last_level < stObj->lastLevel ||
        stObj->pt->cpp != cpp ||
+        stObj->pt->width[0] != firstImage->base.Width2 ||
+        stObj->pt->height[0] != firstImage->base.Height2 ||
+        stObj->pt->depth[0] != firstImage->base.Depth2 ||
        stObj->pt->compressed != firstImage->base.IsCompressed)) {
       pipe_texture_release(&stObj->pt);
    }