st/mesa: Set samplers views' first_level.
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:44:21 +0000 (04:44 +0200)
Base level and min LOD aren't equivalent. In particular, min LOD has no
effect on image array selection for magnification and non-mipmapped
minification.

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

index 5f1849dcd8368be6582eb5e935cbca3ba374dcd0..2b53741460f1984050ccd6b8570e61159449705b 100644 (file)
@@ -166,12 +166,9 @@ update_samplers(struct st_context *st)
          sampler->lod_bias = st->ctx->Texture.Unit[texUnit].LodBias +
             texobj->LodBias;
 
-         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));
+         sampler->min_lod = MAX2(0.0f, texobj->MinLod);
+         sampler->max_lod = MIN2((GLfloat) 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.
index fd03669e66062403f2f065550ddad24cdedc0399..6b9f969ac006570becba490f7b1111b4471713aa 100644 (file)
@@ -148,6 +148,7 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
    u_sampler_view_default_template(&templ,
                                    stObj->pt,
                                    format);
+   templ.u.tex.first_level = stObj->base.BaseLevel;
 
    if (swizzle != SWIZZLE_NOOP) {
       templ.swizzle_r = GET_SWZ(swizzle, 0);
@@ -248,7 +249,8 @@ update_textures(struct st_context *st)
             if (check_sampler_swizzle(stObj->sampler_view,
                                       stObj->base._Swizzle,
                                       stObj->base.DepthMode) ||
-                (st_view_format != stObj->sampler_view->format))
+                (st_view_format != stObj->sampler_view->format) ||
+                stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level)
               pipe_sampler_view_reference(&stObj->sampler_view, NULL);
 
          sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe, st_view_format);