summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe/sp_tex_sample.c
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-10-15 11:47:53 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-10-15 11:47:53 -0600
commit369eefc34c8d7acdb881ea5b0516406d71344fc4 (patch)
tree323628a281f794df317aa89577266ac4bfc8649e /src/mesa/pipe/softpipe/sp_tex_sample.c
parentc8bf63e992f902f1bef0c20e5b50f397c4d219a7 (diff)
add 'normalized_coords' field to pipe_sampler_state
This controls whether texcoords are interpreted as-is or scaled up from [0,1]. Fixes glDrawPixels/glBitmap problems on i915 when image is non power-of-two. Also, cleans up the CSO sampler state for i915 a bit.
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_tex_sample.c')
-rw-r--r--src/mesa/pipe/softpipe/sp_tex_sample.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/mesa/pipe/softpipe/sp_tex_sample.c b/src/mesa/pipe/softpipe/sp_tex_sample.c
index aab26f0b0e..6ff84119e5 100644
--- a/src/mesa/pipe/softpipe/sp_tex_sample.c
+++ b/src/mesa/pipe/softpipe/sp_tex_sample.c
@@ -427,8 +427,9 @@ compute_lambda(struct tgsi_sampler *sampler,
float dsdy = s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT];
dsdx = FABSF(dsdx);
dsdy = FABSF(dsdy);
- /* XXX only multiply by width for NORMALIZEd texcoords */
- rho = MAX2(dsdx, dsdy) * sampler->texture->width0;
+ rho = MAX2(dsdx, dsdy);
+ if (sampler->state->normalized_coords)
+ rho *= sampler->texture->width0;
}
if (t) {
float dtdx = t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT];
@@ -436,8 +437,9 @@ compute_lambda(struct tgsi_sampler *sampler,
float max;
dtdx = FABSF(dtdx);
dtdy = FABSF(dtdy);
- /* XXX only multiply by height for NORMALIZEd texcoords */
- max = MAX2(dtdx, dtdy) * sampler->texture->height0;
+ max = MAX2(dtdx, dtdy);
+ if (sampler->state->normalized_coords)
+ max *= sampler->texture->height0;
rho = MAX2(rho, max);
}
if (p) {
@@ -446,8 +448,9 @@ compute_lambda(struct tgsi_sampler *sampler,
float max;
dpdx = FABSF(dpdx);
dpdy = FABSF(dpdy);
- /* XXX only multiply by depth for NORMALIZEd texcoords */
- max = MAX2(dpdx, dpdy) * sampler->texture->depth0;
+ max = MAX2(dpdx, dpdy);
+ if (sampler->state->normalized_coords)
+ max *= sampler->texture->depth0;
rho = MAX2(rho, max);
}
@@ -647,8 +650,13 @@ sp_get_samples_2d_common(struct tgsi_sampler *sampler,
choose_mipmap_levels(sampler, s, t, p, lodbias,
&level0, &level1, &levelBlend, &imgFilter);
- width = sampler->texture->level[level0].width;
- height = sampler->texture->level[level0].height;
+ if (sampler->state->normalized_coords) {
+ width = sampler->texture->level[level0].width;
+ height = sampler->texture->level[level0].height;
+ }
+ else {
+ width = height = 1.0;
+ }
assert(width > 0);