nv50: adapt to stencil ref changes
authorRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 21:48:39 +0000 (22:48 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 21:48:39 +0000 (22:48 +0100)
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nv50/nv50_state_validate.c

index 14cef4c0bf81791f4cfce7332c286d3adb216629..b4de3e2ba574d7ca95d0537010cb40a9870af5b5 100644 (file)
@@ -50,6 +50,7 @@
 #define NV50_NEW_ARRAYS                (1 << 14)
 #define NV50_NEW_SAMPLER       (1 << 15)
 #define NV50_NEW_TEXTURE       (1 << 16)
+#define NV50_NEW_STENCIL_REF   (1 << 17)
 
 struct nv50_blend_stateobj {
        struct pipe_blend_state pipe;
@@ -120,6 +121,7 @@ struct nv50_state {
        struct nouveau_stateobj *blend;
        struct nouveau_stateobj *blend_colour;
        struct nouveau_stateobj *zsa;
+       struct nouveau_stateobj *stencil_ref;
        struct nouveau_stateobj *rast;
        struct nouveau_stateobj *stipple;
        struct nouveau_stateobj *scissor;
@@ -155,6 +157,7 @@ struct nv50_context {
        struct nv50_zsa_stateobj *zsa;
        struct nv50_rasterizer_stateobj *rasterizer;
        struct pipe_blend_color blend_colour;
+       struct pipe_stencil_ref stencil_ref;
        struct pipe_poly_stipple stipple;
        struct pipe_scissor_state scissor;
        struct pipe_viewport_state viewport;
index 7c531b50a50e2fb8fed15d072c49fd7b2910544a..05d519a2f95b41a4629691f71f2282b4338ce656 100644 (file)
@@ -447,7 +447,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
 {
        struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla;
        struct nv50_zsa_stateobj *zsa = CALLOC_STRUCT(nv50_zsa_stateobj);
-       struct nouveau_stateobj *so = so_new(8, 22, 0);
+       struct nouveau_stateobj *so = so_new(9, 21, 0);
 
        so_method(so, tesla, NV50TCL_DEPTH_WRITE_ENABLE, 1);
        so_data  (so, cso->depth.writemask ? 1 : 0);
@@ -462,13 +462,13 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
        }
 
        if (cso->stencil[0].enabled) {
-               so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 8);
+               so_method(so, tesla, NV50TCL_STENCIL_FRONT_ENABLE, 5);
                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_data  (so, cso->stencil[0].ref_value);
+               so_method(so, tesla, NV50TCL_STENCIL_FRONT_MASK, 2);
                so_data  (so, cso->stencil[0].writemask);
                so_data  (so, cso->stencil[0].valuemask);
        } else {
@@ -483,8 +483,7 @@ nv50_depth_stencil_alpha_state_create(struct pipe_context *pipe,
                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, NV50TCL_STENCIL_BACK_FUNC_REF, 3);
-               so_data  (so, cso->stencil[1].ref_value);
+               so_method(so, tesla, NV50TCL_STENCIL_BACK_MASK, 2);
                so_data  (so, cso->stencil[1].writemask);
                so_data  (so, cso->stencil[1].valuemask);
        } else {
@@ -633,6 +632,16 @@ nv50_set_blend_color(struct pipe_context *pipe,
        nv50->dirty |= NV50_NEW_BLEND_COLOUR;
 }
 
+ static void
+nv50_set_stencil_ref(struct pipe_context *pipe,
+                    const struct pipe_stencil_ref *sr)
+{
+       struct nv50_context *nv50 = nv50_context(pipe);
+
+       nv50->stencil_ref = *sr;
+       nv50->dirty |= NV50_NEW_STENCIL_REF;
+}
+
 static void
 nv50_set_clip_state(struct pipe_context *pipe,
                    const struct pipe_clip_state *clip)
@@ -761,6 +770,7 @@ nv50_init_state_functions(struct nv50_context *nv50)
        nv50->pipe.delete_gs_state = nv50_gp_state_delete;
 
        nv50->pipe.set_blend_color = nv50_set_blend_color;
+        nv50->pipe.set_stencil_ref = nv50_set_stencil_ref;
        nv50->pipe.set_clip_state = nv50_set_clip_state;
        nv50->pipe.set_constant_buffer = nv50_set_constant_buffer;
        nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state;
index ee28fa63c1466f6b808884a49337ff3d8c675449..3afeb2b241f689c5d70af7640a61e93438ef7655 100644 (file)
@@ -205,6 +205,8 @@ nv50_state_emit(struct nv50_context *nv50)
                        nv50->state.dirty |= NV50_NEW_RASTERIZER;
                if (nv50->state.blend_colour)
                        nv50->state.dirty |= NV50_NEW_BLEND_COLOUR;
+               if (nv50->state.stencil_ref)
+                       nv50->state.dirty |= NV50_NEW_STENCIL_REF;
                if (nv50->state.stipple)
                        nv50->state.dirty |= NV50_NEW_STIPPLE;
                if (nv50->state.scissor)
@@ -242,6 +244,8 @@ nv50_state_emit(struct nv50_context *nv50)
                so_emit(chan, nv50->state.rast);
        if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR)
                so_emit(chan, nv50->state.blend_colour);
+       if (nv50->state.dirty & NV50_NEW_STENCIL_REF)
+               so_emit(chan, nv50->state.stencil_ref);
        if (nv50->state.dirty & NV50_NEW_STIPPLE)
                so_emit(chan, nv50->state.stipple);
        if (nv50->state.dirty & NV50_NEW_SCISSOR)
@@ -325,6 +329,16 @@ nv50_state_validate(struct nv50_context *nv50)
                so_ref(NULL, &so);
        }
 
+       if (nv50->dirty & NV50_NEW_STENCIL_REF) {
+               so = so_new(2, 2, 0);
+               so_method(so, tesla, NV50TCL_STENCIL_FRONT_FUNC_REF, 1);
+               so_data  (so, nv50->stencil_ref.ref_value[0];
+               so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 1);
+               so_data  (so, nv50->stencil_ref.ref_value[1];
+               so_ref(so, &nv50->state.stencil_ref);
+               so_ref(NULL, &so);
+       }
+
        if (nv50->dirty & NV50_NEW_STIPPLE) {
                so = so_new(1, 32, 0);
                so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32);