nv40: "rect" textures, anisotropic filtering
authorBen Skeggs <skeggsb@gmail.com>
Tue, 20 Nov 2007 10:13:33 +0000 (21:13 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Tue, 20 Nov 2007 10:13:33 +0000 (21:13 +1100)
src/mesa/pipe/nv40/nv40_context.c
src/mesa/pipe/nv40/nv40_state.c
src/mesa/pipe/nv40/nv40_state.h
src/mesa/pipe/nv40/nv40_state_tex.c

index 8462d08f8d9b93e205f06d7b63da451aa3a858c3..6f2709164325beafa387b9f8b5815884fd03c46a 100644 (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:
index 37b07352bec23e9866d97e85020f2169f9848f13..9b58409e51ebbe733abd56daaac0bacdb53c9008 100644 (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) |
index ae162b95cef1f4c6e1df64e1e01a29b31cc4e33d..14bf5d83e3e1424728c27223692fa956128dfe65 100644 (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;
 };
index 832abbf1f398730ddb40a6d881f2ef099749b959..cf2a7a9fe0fc4de61ade49a4c56a377f927c4116 100644 (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*/);