gallium: check if sampler->max_lod < sampler->min_lod
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 17 Jun 2008 16:28:00 +0000 (10:28 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 17 Jun 2008 16:28:00 +0000 (10:28 -0600)
src/mesa/state_tracker/st_atom_sampler.c

index 10283d31a19eda552a4e46e56bcc8c36f1b89170..9abd0b3531d90d8b71b0fa263d3569e62d929121 100644 (file)
@@ -153,6 +153,15 @@ update_samplers(struct st_context *st)
          sampler->min_lod = MAX2(0.0f, texobj->MinLod);
          sampler->max_lod = MIN2(texobj->MaxLevel - texobj->BaseLevel,
                                  texobj->MaxLod);
+         if (sampler->max_lod < sampler->min_lod) {
+            /* The GL spec doesn't seem to specify what to do in this case.
+             * Swap the values.
+             */
+            float tmp = sampler->max_lod;
+            sampler->max_lod = sampler->min_lod;
+            sampler->min_lod = tmp;
+            assert(sampler->min_lod <= sampler->max_lod);
+         }
 
          sampler->border_color[0] = texobj->BorderColor[RCOMP];
          sampler->border_color[1] = texobj->BorderColor[GCOMP];