diff options
author | Roland Scheidegger <sroland@vmware.com> | 2014-06-26 02:37:44 +0200 |
---|---|---|
committer | Roland Scheidegger <sroland@vmware.com> | 2014-06-26 16:57:12 +0200 |
commit | b1c1c7d31b3ad625243616597028e7d599eb8190 (patch) | |
tree | 2dbf2df126cc0cd45f5b4720aef68809c362f8f6 /src/gallium/drivers | |
parent | f3a97c0381acc73fa4404a8793059bd8e8d44a38 (diff) |
softpipe: use last_level from sampler view, not from the resource
The last_level from the sampler view may be limited by the state tracker
to a value lower than what the base texture provides.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=80541.
Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 6d97664f97f..8565a01822a 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -1860,22 +1860,22 @@ mip_filter_linear(struct sp_sampler_view *sp_sview, enum tgsi_sampler_control control, float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]) { - const struct pipe_resource *texture = sp_sview->base.texture; + const struct pipe_sampler_view *psview = &sp_sview->base; int j; float lod[TGSI_QUAD_SIZE]; compute_lambda_lod(sp_sview, sp_samp, s, t, p, lod_in, control, lod); for (j = 0; j < TGSI_QUAD_SIZE; j++) { - int level0 = sp_sview->base.u.tex.first_level + (int)lod[j]; + int level0 = psview->u.tex.first_level + (int)lod[j]; if (lod[j] < 0.0) mag_filter(sp_sview, sp_samp, s[j], t[j], p[j], - sp_sview->base.u.tex.first_level, + psview->u.tex.first_level, sp_sview->faces[j], &rgba[0][j]); - else if (level0 >= (int) texture->last_level) - min_filter(sp_sview, sp_samp, s[j], t[j], p[j], texture->last_level, + else if (level0 >= (int) psview->u.tex.last_level) + min_filter(sp_sview, sp_samp, s[j], t[j], p[j], psview->u.tex.last_level, sp_sview->faces[j], &rgba[0][j]); else { @@ -1918,7 +1918,7 @@ mip_filter_nearest(struct sp_sampler_view *sp_sview, enum tgsi_sampler_control control, float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]) { - const struct pipe_resource *texture = sp_sview->base.texture; + const struct pipe_sampler_view *psview = &sp_sview->base; float lod[TGSI_QUAD_SIZE]; int j; @@ -1927,11 +1927,11 @@ mip_filter_nearest(struct sp_sampler_view *sp_sview, for (j = 0; j < TGSI_QUAD_SIZE; j++) { if (lod[j] < 0.0) mag_filter(sp_sview, sp_samp, s[j], t[j], p[j], - sp_sview->base.u.tex.first_level, + psview->u.tex.first_level, sp_sview->faces[j], &rgba[0][j]); else { - int level = sp_sview->base.u.tex.first_level + (int)(lod[j] + 0.5F); - level = MIN2(level, (int)texture->last_level); + int level = psview->u.tex.first_level + (int)(lod[j] + 0.5F); + level = MIN2(level, (int)psview->u.tex.last_level); min_filter(sp_sview, sp_samp, s[j], t[j], p[j], level, sp_sview->faces[j], &rgba[0][j]); } @@ -2230,12 +2230,13 @@ mip_filter_linear_aniso(struct sp_sampler_view *sp_sview, float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]) { const struct pipe_resource *texture = sp_sview->base.texture; + const struct pipe_sampler_view *psview = &sp_sview->base; int level0; float lambda; float lod[TGSI_QUAD_SIZE]; - float s_to_u = u_minify(texture->width0, sp_sview->base.u.tex.first_level); - float t_to_v = u_minify(texture->height0, sp_sview->base.u.tex.first_level); + float s_to_u = u_minify(texture->width0, psview->u.tex.first_level); + float t_to_v = u_minify(texture->height0, psview->u.tex.first_level); float dudx = (s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]) * s_to_u; float dudy = (s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]) * s_to_u; float dvdx = (t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]) * t_to_v; @@ -2292,15 +2293,15 @@ mip_filter_linear_aniso(struct sp_sampler_view *sp_sview, /* XXX: Take into account all lod values. */ lambda = lod[0]; - level0 = sp_sview->base.u.tex.first_level + (int)lambda; + level0 = psview->u.tex.first_level + (int)lambda; /* If the ellipse covers the whole image, we can * simply return the average of the whole image. */ - if (level0 >= (int) texture->last_level) { + if (level0 >= (int) psview->u.tex.last_level) { int j; for (j = 0; j < TGSI_QUAD_SIZE; j++) - min_filter(sp_sview, sp_samp, s[j], t[j], p[j], texture->last_level, + min_filter(sp_sview, sp_samp, s[j], t[j], p[j], psview->u.tex.last_level, sp_sview->faces[j], &rgba[0][j]); } else { @@ -2336,25 +2337,25 @@ mip_filter_linear_2d_linear_repeat_POT( enum tgsi_sampler_control control, float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]) { - const struct pipe_resource *texture = sp_sview->base.texture; + const struct pipe_sampler_view *psview = &sp_sview->base; int j; float lod[TGSI_QUAD_SIZE]; compute_lambda_lod(sp_sview, sp_samp, s, t, p, lod_in, control, lod); for (j = 0; j < TGSI_QUAD_SIZE; j++) { - int level0 = sp_sview->base.u.tex.first_level + (int)lod[j]; + int level0 = psview->u.tex.first_level + (int)lod[j]; /* Catches both negative and large values of level0: */ - if ((unsigned)level0 >= texture->last_level) { + if ((unsigned)level0 >= psview->u.tex.last_level) { if (level0 < 0) img_filter_2d_linear_repeat_POT(sp_sview, sp_samp, s[j], t[j], p[j], - sp_sview->base.u.tex.first_level, + psview->u.tex.first_level, sp_sview->faces[j], &rgba[0][j]); else img_filter_2d_linear_repeat_POT(sp_sview, sp_samp, s[j], t[j], p[j], - sp_sview->base.texture->last_level, + psview->u.tex.last_level, sp_sview->faces[j], &rgba[0][j]); } |