[Mesa-dev] [PATCH] st/mesa/softpipe: fix tex-miplevel tests

Dave Airlie airlied at gmail.com
Sat Jan 28 14:08:53 PST 2012


From: Dave Airlie <airlied at redhat.com>

I'm not sure this is the correct way to do this, but it fixes

tex-miplevel-selection-texture2DLod + 2 others, if there is an explicit MaxLevel
set from the application, we seem to ignore it and not clamp to it.

softpipe was also treating explicit lod as the final value when the spec
says it just replaces lod-base.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/drivers/softpipe/sp_tex_sample.c |    7 ++++---
 src/mesa/state_tracker/st_atom_texture.c     |    4 +++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index bd0546e..16e532c 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -1648,9 +1648,10 @@ mip_filter_nearest(struct tgsi_sampler *tgsi_sampler,
       lambda = samp->compute_lambda(samp, s, t, p) + samp->sampler->lod_bias;
       compute_lod(samp->sampler, lambda, c0, lod);
    } else {
+      static const float zero[QUAD_SIZE];
       assert(control == tgsi_sampler_lod_explicit);
-
-      memcpy(lod, c0, sizeof(lod));
+      lambda = c0[0] + samp->sampler->lod_bias;
+      compute_lod(samp->sampler, lambda, zero, lod);
    }
 
    /* XXX: Take into account all lod values.
@@ -1663,7 +1664,7 @@ mip_filter_nearest(struct tgsi_sampler *tgsi_sampler,
    }
    else {
       samp->level = samp->view->u.tex.first_level + (int)(lambda + 0.5F) ;
-      samp->level = MIN2(samp->level, (int)texture->last_level);
+      samp->level = MIN2(samp->level, (int)samp->view->u.tex.last_level);
       samp->min_img_filter(tgsi_sampler, s, t, p, NULL, tgsi_sampler_lod_bias, rgba);
    }
 
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 88e6128..b0d61a9 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -152,6 +152,7 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
                                    stObj->pt,
                                    format);
    templ.u.tex.first_level = stObj->base.BaseLevel;
+   templ.u.tex.last_level = stObj->base._MaxLevel;
 
    if (swizzle != SWIZZLE_NOOP) {
       templ.swizzle_r = GET_SWZ(swizzle, 0);
@@ -241,7 +242,8 @@ update_single_texture(struct st_context *st,
 				stObj->base._Swizzle,
 				samp->DepthMode) ||
 	  (st_view_format != stObj->sampler_view->format) ||
-	  stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) {
+	  stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level ||
+	  stObj->base.MaxLevel != stObj->sampler_view->u.tex.last_level) {
 	 pipe_sampler_view_reference(&stObj->sampler_view, NULL);
       }
    }
-- 
1.7.7.4



More information about the mesa-dev mailing list