Merge branch 'mesa_7_7_branch'
[mesa.git] / src / gallium / drivers / nv50 / nv50_state.c
index 116866a8e781cb223331c5552ac8f1de8db68e18..07318f23947bc34ba33d37527e2729e885e8b18e 100644 (file)
@@ -146,6 +146,7 @@ nv50_sampler_state_create(struct pipe_context *pipe,
                  (wrap_mode(cso->wrap_r) << 6));
 
        switch (cso->mag_img_filter) {
+       case PIPE_TEX_FILTER_ANISO:
        case PIPE_TEX_FILTER_LINEAR:
                tsc[1] |= NV50TSC_1_1_MAGF_LINEAR;
                break;
@@ -156,6 +157,7 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        }
 
        switch (cso->min_img_filter) {
+       case PIPE_TEX_FILTER_ANISO:
        case PIPE_TEX_FILTER_LINEAR:
                tsc[1] |= NV50TSC_1_1_MINF_LINEAR;
                break;
@@ -183,21 +185,15 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        else
        if (cso->max_anisotropy >= 12.0)
                tsc[0] |= (6 << 20);
-       else
-       if (cso->max_anisotropy >= 10.0)
-               tsc[0] |= (5 << 20);
-       else
-       if (cso->max_anisotropy >= 8.0)
-               tsc[0] |= (4 << 20);
-       else
-       if (cso->max_anisotropy >= 6.0)
-               tsc[0] |= (3 << 20);
-       else
-       if (cso->max_anisotropy >= 4.0)
-               tsc[0] |= (2 << 20);
-       else
-       if (cso->max_anisotropy >= 2.0)
-               tsc[0] |= (1 << 20);
+       else {
+               tsc[0] |= (int)(cso->max_anisotropy * 0.5f) << 20;
+
+               if (cso->max_anisotropy >= 4.0)
+                       tsc[1] |= NV50TSC_1_1_UNKN_ANISO_35;
+               else
+               if (cso->max_anisotropy >= 2.0)
+                       tsc[1] |= NV50TSC_1_1_UNKN_ANISO_15;
+       }
 
        if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
                tsc[0] |= (1 << 8);
@@ -205,11 +201,16 @@ nv50_sampler_state_create(struct pipe_context *pipe,
        }
 
        limit = CLAMP(cso->lod_bias, -16.0, 15.0);
-       tsc[1] |= ((int)(limit * 256.0) & 0x1fff) << 11;
+       tsc[1] |= ((int)(limit * 256.0) & 0x1fff) << 12;
 
        tsc[2] |= ((int)CLAMP(cso->max_lod, 0.0, 15.0) << 20) |
                  ((int)CLAMP(cso->min_lod, 0.0, 15.0) << 8);
 
+       tsc[4] = fui(cso->border_color[0]);
+       tsc[5] = fui(cso->border_color[1]);
+       tsc[6] = fui(cso->border_color[2]);
+       tsc[7] = fui(cso->border_color[3]);
+
        sso->normalized = cso->normalized_coords;
        return (void *)sso;
 }
@@ -268,6 +269,11 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
        so_method(so, tesla, NV50TCL_SHADE_MODEL, 1);
        so_data  (so, cso->flatshade ? NV50TCL_SHADE_MODEL_FLAT :
                                       NV50TCL_SHADE_MODEL_SMOOTH);
+       so_method(so, tesla, 0x1684, 1);
+       so_data  (so, cso->flatshade_first ? 0 : 1);
+
+       so_method(so, tesla, NV50TCL_VERTEX_TWO_SIDE_ENABLE, 1);
+       so_data  (so, cso->light_twoside);
 
        so_method(so, tesla, NV50TCL_LINE_WIDTH, 1);
        so_data  (so, fui(cso->line_width));
@@ -287,6 +293,9 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
        so_method(so, tesla, NV50TCL_POINT_SIZE, 1);
        so_data  (so, fui(cso->point_size));
 
+       so_method(so, tesla, NV50TCL_POINT_SPRITE_ENABLE, 1);
+       so_data  (so, cso->point_sprite);
+
        so_method(so, tesla, NV50TCL_POLYGON_MODE_FRONT, 3);
        if (cso->front_winding == PIPE_WINDING_CCW) {
                so_data(so, nvgl_polygon_mode(cso->fill_ccw));
@@ -404,35 +413,35 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
                so_data  (so, 0);
        }
 
-       /*XXX: yes, I know they're backwards.. header needs fixing */
+       /* XXX: keep hex values until header is updated (names reversed) */
        if (cso->stencil[0].enabled) {
-               so_method(so, tesla, NV50TCL_STENCIL_BACK_ENABLE, 5);
+               so_method(so, tesla, 0x1380, 8);
                so_data  (so, 1);
                so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
                so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
                so_data  (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
                so_data  (so, nvgl_comparison_op(cso->stencil[0].func));
-               so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 3);
                so_data  (so, cso->stencil[0].ref_value);
                so_data  (so, cso->stencil[0].writemask);
                so_data  (so, cso->stencil[0].valuemask);
        } else {
-               so_method(so, tesla, NV50TCL_STENCIL_BACK_ENABLE, 1);
+               so_method(so, tesla, 0x1380, 1);
                so_data  (so, 0);
        }
 
        if (cso->stencil[1].enabled) {
-               so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 8);
+               so_method(so, tesla, 0x1594, 5);
                so_data  (so, 1);
                so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
                so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
                so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
                so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
+               so_method(so, tesla, 0x0f54, 3);
                so_data  (so, cso->stencil[1].ref_value);
                so_data  (so, cso->stencil[1].writemask);
                so_data  (so, cso->stencil[1].valuemask);
        } else {
-               so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 1);
+               so_method(so, tesla, 0x1594, 1);
                so_data  (so, 0);
        }
 
@@ -639,9 +648,9 @@ nv50_init_state_functions(struct nv50_context *nv50)
        nv50->pipe.delete_blend_state = nv50_blend_state_delete;
 
        nv50->pipe.create_sampler_state = nv50_sampler_state_create;
-       nv50->pipe.bind_sampler_states = nv50_sampler_state_bind;
+       nv50->pipe.bind_fragment_sampler_states = nv50_sampler_state_bind;
        nv50->pipe.delete_sampler_state = nv50_sampler_state_delete;
-       nv50->pipe.set_sampler_textures = nv50_set_sampler_texture;
+       nv50->pipe.set_fragment_sampler_textures = nv50_set_sampler_texture;
 
        nv50->pipe.create_rasterizer_state = nv50_rasterizer_state_create;
        nv50->pipe.bind_rasterizer_state = nv50_rasterizer_state_bind;