nv40: attempt at obeying sampler min_lod/max_lod/lod_bias
authorBen Skeggs <skeggsb@gmail.com>
Wed, 13 Feb 2008 08:33:41 +0000 (19:33 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Fri, 15 Feb 2008 02:51:12 +0000 (13:51 +1100)
src/mesa/pipe/nv40/nv40_context.c
src/mesa/pipe/nv40/nv40_fragtex.c
src/mesa/pipe/nv40/nv40_state.c

index 302ad04..a8a2eaf 100644 (file)
@@ -74,7 +74,7 @@ nv40_get_paramf(struct pipe_context *pipe, int param)
        case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
                return 16.0;
        case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
-               return 4.0;
+               return 16.0;
        case PIPE_CAP_BITMAP_TEXCOORD_BIAS:
                return 0.0;
        default:
index 69c0fcb..5af5fbe 100644 (file)
@@ -108,10 +108,9 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
        so_reloc (so, nv40mt->buffer, txf, tex_flags | NOUVEAU_BO_OR,
                  NV40TCL_TEX_FORMAT_DMA0, NV40TCL_TEX_FORMAT_DMA1);
        so_data  (so, ps->wrap);
-       so_data  (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en |
-                  (0x00078000) /* mipmap related? */);
+       so_data  (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en);
        so_data  (so, txs);
-       so_data  (so, ps->filt | 0x3fd6 /*voodoo*/);
+       so_data  (so, ps->filt | 0x2000 /*voodoo*/);
        so_data  (so, (pt->width[0] << NV40TCL_TEX_SIZE0_W_SHIFT) |
                       pt->height[0]);
        so_data  (so, ps->bcol);
index 80e9473..bcd2445 100644 (file)
@@ -193,6 +193,20 @@ nv40_sampler_state_create(struct pipe_context *pipe,
 
        ps->filt = filter;
 
+       {
+               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;
+       }
+
+
        if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
                switch (cso->compare_func) {
                case PIPE_FUNC_NEVER: