st/mesa: Clamp min_lod to the max miplevel as well.
authorHenri Verbeet <hverbeet@gmail.com>
Mon, 17 Jan 2011 21:03:30 +0000 (22:03 +0100)
committerMarek Olšák <maraeo@gmail.com>
Fri, 8 Apr 2011 02:45:03 +0000 (04:45 +0200)
Otherwise min_lod can potentially be larger than the clamped max_lod. The
code that follows will swap min_lod and max_lod in that case, resulting in a
max_lod larger than MAX_LEVEL.

Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_atom_sampler.c

index 2b53741460f1984050ccd6b8570e61159449705b..19d41e7061a8a00b7cd3f9ad385f6c1ff99f8c1f 100644 (file)
@@ -166,7 +166,9 @@ update_samplers(struct st_context *st)
          sampler->lod_bias = st->ctx->Texture.Unit[texUnit].LodBias +
             texobj->LodBias;
 
-         sampler->min_lod = MAX2(0.0f, texobj->MinLod);
+         sampler->min_lod = CLAMP(texobj->MinLod,
+                                  0.0f,
+                                  (GLfloat) texobj->MaxLevel - texobj->BaseLevel);
          sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel - texobj->BaseLevel,
                                  texobj->MaxLod);
          if (sampler->max_lod < sampler->min_lod) {