Merge commit 'origin/gallium-0.1' into gallium-tex-surfaces
[mesa.git] / src / mesa / state_tracker / st_atom_sampler.c
index 7515bb30cc72b1a500081ac3a2cff77014ee0af2..4ce7c41e90beeac830819f4191eb8829d3abdce5 100644 (file)
   */
  
 
+#include "main/macros.h"
+
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_program.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+
 #include "cso_cache/cso_context.h"
 
 
@@ -148,8 +150,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];