[Mesa-dev] [PATCH 1/1] st/mesa: Set samplers views' first_level.

Henri Verbeet hverbeet at gmail.com
Tue Jan 4 13:05:59 PST 2011


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.
---
 src/mesa/state_tracker/st_atom_sampler.c |    9 +++------
 src/mesa/state_tracker/st_atom_texture.c |    4 +++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index b67068d..e47cb94 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -207,12 +207,9 @@ update_samplers(struct st_context *st)
 
          sampler->lod_bias = st->ctx->Texture.Unit[su].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.
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 029b040..f5176fa 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -145,6 +145,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);
@@ -232,7 +233,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);
-- 
1.7.2.3



More information about the mesa-dev mailing list