summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
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
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')
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c3
-rw-r--r--src/mesa/pipe/i915simple/i915_state_sampler.c4
-rw-r--r--src/mesa/pipe/p_state.h1
-rw-r--r--src/mesa/pipe/softpipe/sp_tex_sample.c24
4 files changed, 20 insertions, 12 deletions
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 4a31747fe8..8da5662e3f 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -262,6 +262,9 @@ i915_create_sampler_state(struct pipe_context *pipe,
(translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) |
(translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT));
+ if (sampler->normalized_coords)
+ cso->state[1] |= SS3_NORMALIZED_COORDS;
+
{
ubyte r = float_to_ubyte(sampler->border_color[0]);
ubyte g = float_to_ubyte(sampler->border_color[1]);
diff --git a/src/mesa/pipe/i915simple/i915_state_sampler.c b/src/mesa/pipe/i915simple/i915_state_sampler.c
index 3b736f9c55..8dec6781cd 100644
--- a/src/mesa/pipe/i915simple/i915_state_sampler.c
+++ b/src/mesa/pipe/i915simple/i915_state_sampler.c
@@ -127,10 +127,6 @@ static void update_sampler(struct i915_context *i915,
#endif
state[1] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
-
- if (is_power_of_two_texture(mt)) {
- state[1] |= SS3_NORMALIZED_COORDS;
- }
}
void i915_update_samplers( struct i915_context *i915 )
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 99ec574124..da62aa1b27 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -243,6 +243,7 @@ struct pipe_sampler_state
unsigned compare:1; /**< shadow/depth compare enabled? */
unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */
unsigned compare_func:3; /**< PIPE_FUNC_x */
+ unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */
float shadow_ambient; /**< shadow test fail color/intensity */
float min_lod;
float max_lod;
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);