From 2c7953a1a94199e6a0ab241001cd6241c3ebb963 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 17 Jan 2011 22:03:30 +0100 Subject: [PATCH 4/4] 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 --- 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 e47cb94..2b663dc 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -207,7 +207,9 @@ update_samplers(struct st_context *st) sampler->lod_bias = st->ctx->Texture.Unit[su].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) { -- 1.7.3.4