(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]);
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;
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];
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) {
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);
}
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);
sampler.min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter);
sampler.mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter);
+ if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB)
+ sampler.normalized_coords = 1;
+
sampler.lod_bias = st->ctx->Texture.Unit[u].LodBias;
#if 1
sampler.min_lod = texobj->MinLod;
sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
+ sampler.normalized_coords = 1;
cso = st_cached_sampler_state(ctx->st, &sampler);
pipe->bind_sampler_state(pipe, unit, cso->data);
}