st/mesa: program struct comments
[mesa.git] / src / mesa / state_tracker / st_atom_sampler.c
index 7b84a86ba485d35762b8888cec48c776760c7b8b..b67068df373d7a358c701a08b7714efceda81404 100644 (file)
@@ -37,7 +37,6 @@
 #include "st_context.h"
 #include "st_cb_texture.h"
 #include "st_atom.h"
-#include "st_program.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 
@@ -122,6 +121,18 @@ static void
 xlate_border_color(const GLfloat *colorIn, GLenum baseFormat, GLfloat *colorOut)
 {
    switch (baseFormat) {
+   case GL_RED:
+      colorOut[0] = colorIn[0];
+      colorOut[1] = 0.0F;
+      colorOut[2] = 0.0F;
+      colorOut[3] = 1.0F;
+      break;
+   case GL_RG:
+      colorOut[0] = colorIn[0];
+      colorOut[1] = colorIn[1];
+      colorOut[2] = 0.0F;
+      colorOut[3] = 1.0F;
+      break;
    case GL_RGB:
       colorOut[0] = colorIn[0];
       colorOut[1] = colorIn[1];
@@ -195,9 +206,13 @@ update_samplers(struct st_context *st)
             sampler->normalized_coords = 1;
 
          sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias;
-         sampler->min_lod = MAX2(0.0f, texobj->MinLod);
-         sampler->max_lod = MIN2(texobj->MaxLevel - texobj->BaseLevel,
-                                 texobj->MaxLod);
+
+         sampler->min_lod = texobj->BaseLevel + texobj->MinLod;
+         if (sampler->min_lod < texobj->BaseLevel)
+            sampler->min_lod = texobj->BaseLevel;
+
+         sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel,
+                                 (texobj->MaxLod + texobj->BaseLevel));
          if (sampler->max_lod < sampler->min_lod) {
             /* The GL spec doesn't seem to specify what to do in this case.
              * Swap the values.
@@ -212,7 +227,7 @@ update_samplers(struct st_context *st)
                             teximg ? teximg->_BaseFormat : GL_RGBA,
                             sampler->border_color);
 
-        sampler->max_anisotropy = texobj->MaxAnisotropy;
+        sampler->max_anisotropy = (texobj->MaxAnisotropy == 1.0 ? 0 : (GLuint)texobj->MaxAnisotropy);
 
          /* only care about ARB_shadow, not SGI shadow */
          if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) {