Mesa (master): st/mesa: Clamp min_lod to the max miplevel as well.

Marek Olšák mareko at kemper.freedesktop.org
Fri Apr 8 02:51:11 UTC 2011


Module: Mesa
Branch: master
Commit: 79db70bd8aa04e19a4e1b9ee98eb568d90bb6d62
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=79db70bd8aa04e19a4e1b9ee98eb568d90bb6d62

Author: Henri Verbeet <hverbeet at gmail.com>
Date:   Mon Jan 17 22:03:30 2011 +0100

st/mesa: Clamp min_lod to the max miplevel as well.

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 at vmware.com>

---

 src/mesa/state_tracker/st_atom_sampler.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 2b53741..19d41e7 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -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) {




More information about the mesa-commit mailing list