diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2007-11-20 21:13:33 +1100 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2007-11-20 21:13:33 +1100 |
commit | b9b5f4b3c16f0b7bc8ae2d7cca03597e0029cb02 (patch) | |
tree | 7a63e92161205c13afcf15f9fad25b30eed3a770 | |
parent | 30837fd24f76131ef5ea77a1396c304d9fc87f4e (diff) |
nv40: "rect" textures, anisotropic filtering
-rw-r--r-- | src/mesa/pipe/nv40/nv40_context.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/nv40/nv40_state.c | 42 | ||||
-rw-r--r-- | src/mesa/pipe/nv40/nv40_state.h | 2 | ||||
-rw-r--r-- | src/mesa/pipe/nv40/nv40_state_tex.c | 5 |
4 files changed, 43 insertions, 8 deletions
diff --git a/src/mesa/pipe/nv40/nv40_context.c b/src/mesa/pipe/nv40/nv40_context.c index 8462d08f8d..6f27091643 100644 --- a/src/mesa/pipe/nv40/nv40_context.c +++ b/src/mesa/pipe/nv40/nv40_context.c @@ -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: diff --git a/src/mesa/pipe/nv40/nv40_state.c b/src/mesa/pipe/nv40/nv40_state.c index 37b07352be..9b58409e51 100644 --- a/src/mesa/pipe/nv40/nv40_state.c +++ b/src/mesa/pipe/nv40/nv40_state.c @@ -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) | diff --git a/src/mesa/pipe/nv40/nv40_state.h b/src/mesa/pipe/nv40/nv40_state.h index ae162b95ce..14bf5d83e3 100644 --- a/src/mesa/pipe/nv40/nv40_state.h +++ b/src/mesa/pipe/nv40/nv40_state.h @@ -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; }; diff --git a/src/mesa/pipe/nv40/nv40_state_tex.c b/src/mesa/pipe/nv40/nv40_state_tex.c index 832abbf1f3..cf2a7a9fe0 100644 --- a/src/mesa/pipe/nv40/nv40_state_tex.c +++ b/src/mesa/pipe/nv40/nv40_state_tex.c @@ -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*/); |