summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv40/nv40_fragtex.c
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-02-24 15:08:48 +0100
committerYounes Manton <younes.m@gmail.com>2010-03-15 00:03:03 -0400
commit7d210fa05f286eb19398ac2f8c8f631f6f83c859 (patch)
tree5f070b61e5ffb7cf67d1957ef67ac11ef4c8e8e2 /src/gallium/drivers/nv40/nv40_fragtex.c
parent5bb68e5d174afa7a177c5e972fa80bf66e37f6ab (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/nv40/nv40_fragtex.c')
-rw-r--r--src/gallium/drivers/nv40/nv40_fragtex.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
index 7615095025..5889b5e40d 100644
--- a/src/gallium/drivers/nv40/nv40_fragtex.c
+++ b/src/gallium/drivers/nv40/nv40_fragtex.c
@@ -1,5 +1,51 @@
#include "util/u_format.h"
#include "nvfx_context.h"
+#include "nvfx_tex.h"
+
+void
+nv40_sampler_state_init(struct pipe_context *pipe,
+ struct nvfx_sampler_state *ps,
+ const struct pipe_sampler_state *cso)
+{
+ if (cso->max_anisotropy >= 2) {
+ /* no idea, binary driver sets it, works without it.. meh.. */
+ ps->wrap |= (1 << 5);
+
+ if (cso->max_anisotropy >= 16) {
+ ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X;
+ } else
+ if (cso->max_anisotropy >= 12) {
+ ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X;
+ } else
+ if (cso->max_anisotropy >= 10) {
+ ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X;
+ } else
+ if (cso->max_anisotropy >= 8) {
+ ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X;
+ } else
+ if (cso->max_anisotropy >= 6) {
+ ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X;
+ } else
+ if (cso->max_anisotropy >= 4) {
+ ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X;
+ } else {
+ ps->en |= NV40TCL_TEX_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 * 256.0) << 7;
+
+ limit = CLAMP(cso->min_lod, 0.0, 15.0);
+ ps->en |= (int)(limit * 256.0) << 19;
+ }
+}
#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w,sx,sy,sz,sw) \
{ \