diff options
author | Luca Barbieri <[email protected]> | 2010-02-24 15:08:48 +0100 |
---|---|---|
committer | Younes Manton <[email protected]> | 2010-03-15 00:03:03 -0400 |
commit | 7d210fa05f286eb19398ac2f8c8f631f6f83c859 (patch) | |
tree | 5f070b61e5ffb7cf67d1957ef67ac11ef4c8e8e2 /src/gallium/drivers/nv30/nv30_fragtex.c | |
parent | 5bb68e5d174afa7a177c5e972fa80bf66e37f6ab (diff) |
nv30, nv40: partially non-trivially unify sampler state in nv[34]0_state.c
Many things, like texture wrap modes and min/mag filters are common.
Some others, like annisotropy and lod settings, are not.
Diffstat (limited to 'src/gallium/drivers/nv30/nv30_fragtex.c')
-rw-r--r-- | src/gallium/drivers/nv30/nv30_fragtex.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c index 52f7c52a9b1..081362d1509 100644 --- a/src/gallium/drivers/nv30/nv30_fragtex.c +++ b/src/gallium/drivers/nv30/nv30_fragtex.c @@ -2,6 +2,36 @@ #include "nvfx_context.h" #include "nouveau/nouveau_util.h" +#include "nvfx_tex.h" + +void +nv30_sampler_state_init(struct pipe_context *pipe, + struct nvfx_sampler_state *ps, + const struct pipe_sampler_state *cso) +{ + if (cso->max_anisotropy >= 8) { + ps->en |= NV34TCL_TX_ENABLE_ANISO_8X; + } else + if (cso->max_anisotropy >= 4) { + ps->en |= NV34TCL_TX_ENABLE_ANISO_4X; + } else + if (cso->max_anisotropy >= 2) { + ps->en |= NV34TCL_TX_ENABLE_ANISO_2X; + } + + { + float limit; + + limit = CLAMP(cso->lod_bias, -16.0, 15.0); + ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff; + + limit = CLAMP(cso->max_lod, 0.0, 15.0); + ps->en |= (int)(limit) << 14 /*NV34TCL_TX_ENABLE_MIPMAP_MAX_LOD_SHIFT*/; + + limit = CLAMP(cso->min_lod, 0.0, 15.0); + ps->en |= (int)(limit) << 26 /*NV34TCL_TX_ENABLE_MIPMAP_MIN_LOD_SHIFT*/; + } +} #define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w) \ { \ |