nv40: "rect" textures, anisotropic filtering

This commit is contained in:
Ben Skeggs 2007-11-20 21:13:33 +11:00
parent 30837fd24f
commit b9b5f4b3c1
4 changed files with 43 additions and 8 deletions

View file

@ -52,7 +52,7 @@ nv40_get_param(struct pipe_context *pipe, int param)
case PIPE_CAP_S3TC:
return 0;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 0;
return 1;
case PIPE_CAP_POINT_SPRITE:
return 0;
case PIPE_CAP_MAX_RENDER_TARGETS:

View file

@ -166,7 +166,42 @@ nv40_sampler_state_create(struct pipe_context *pipe,
uint32_t filter = 0;
ps = malloc(sizeof(struct nv40_sampler_state));
ps->fmt = 0;
if (!cso->normalized_coords)
ps->fmt |= NV40TCL_TEX_FORMAT_RECT;
ps->wrap = ((wrap_mode(cso->wrap_s) << NV40TCL_TEX_WRAP_S_SHIFT) |
(wrap_mode(cso->wrap_t) << NV40TCL_TEX_WRAP_T_SHIFT) |
(wrap_mode(cso->wrap_r) << NV40TCL_TEX_WRAP_R_SHIFT));
ps->en = 0;
if (cso->max_anisotropy >= 2.0) {
/* no idea, binary driver sets it, works without it.. meh.. */
ps->wrap |= (1 << 5);
if (cso->max_anisotropy >= 16.0) {
ps->en |= (7 << 4);
} else
if (cso->max_anisotropy >= 12.0) {
ps->en |= (6 << 4);
} else
if (cso->max_anisotropy >= 10.0) {
ps->en |= (5 << 4);
} else
if (cso->max_anisotropy >= 8.0) {
ps->en |= (4 << 4);
} else
if (cso->max_anisotropy >= 6.0) {
ps->en |= (3 << 4);
} else
if (cso->max_anisotropy >= 4.0) {
ps->en |= (2 << 4);
} else {
ps->en |= (1 << 4); /* 2.0 */
}
}
switch (cso->mag_img_filter) {
case PIPE_TEX_FILTER_LINEAR:
filter |= NV40TCL_TEX_FILTER_MAG_LINEAR;
@ -209,11 +244,8 @@ nv40_sampler_state_create(struct pipe_context *pipe,
break;
}
ps->wrap = ((wrap_mode(cso->wrap_s) << NV40TCL_TEX_WRAP_S_SHIFT) |
(wrap_mode(cso->wrap_t) << NV40TCL_TEX_WRAP_T_SHIFT) |
(wrap_mode(cso->wrap_r) << NV40TCL_TEX_WRAP_R_SHIFT));
ps->filt = filter;
ps->bcol = ((float_to_ubyte(cso->border_color[3]) << 24) |
(float_to_ubyte(cso->border_color[0]) << 16) |
(float_to_ubyte(cso->border_color[1]) << 8) |

View file

@ -24,7 +24,9 @@ struct nv40_blend_state {
};
struct nv40_sampler_state {
uint32_t fmt;
uint32_t wrap;
uint32_t en;
uint32_t filt;
uint32_t bcol;
};

View file

@ -66,7 +66,8 @@ nv40_tex_unit_enable(struct nv40_context *nv40, int unit)
return;
}
txf = tf->format | 0x8000;
txf = ps->fmt;
txf |= tf->format | 0x8000;
txf |= ((mt->last_level - mt->first_level + 1) <<
NV40TCL_TEX_FORMAT_MIPMAP_COUNT_SHIFT);
@ -107,7 +108,7 @@ nv40_tex_unit_enable(struct nv40_context *nv40, int unit)
NOUVEAU_BO_OR | NOUVEAU_BO_RD, NV40TCL_TEX_FORMAT_DMA0,
NV40TCL_TEX_FORMAT_DMA1);
OUT_RING (ps->wrap);
OUT_RING (NV40TCL_TEX_ENABLE_ENABLE |
OUT_RING (NV40TCL_TEX_ENABLE_ENABLE | ps->en |
(0x00078000) /* mipmap related? */);
OUT_RING (txs);
OUT_RING (ps->filt | 0x3fd6 /*voodoo*/);