r300g: adapt to stencil ref changes
authorRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 17:48:57 +0000 (18:48 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 17:48:57 +0000 (18:48 +0100)
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c

index 84617578128ddd1e03c5aa4e23cf7cccb9c5aa60..ba64b3eb7259b564954cbd71e6874e0e0f5eef4a 100644 (file)
@@ -318,6 +318,8 @@ struct r300_context {
     struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
     int vertex_element_count;
 
+    struct pipe_stencil_ref stencil_ref;
+
     /* Bitmask of dirty state objects. */
     uint32_t dirty_state;
     /* Flag indicating whether or not the HW is dirty. */
index ae83511a85694cd7015590fb09e818bbb76f861d..59709e7d648116727e658c9d27eda941956ea892 100644 (file)
@@ -114,6 +114,7 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state)
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     struct pipe_framebuffer_state* fb =
         (struct pipe_framebuffer_state*)r300->fb_state.state;
+    struct pipe_stencil_ref stencil_ref = r300->stencil_ref;
     CS_LOCALS(r300);
 
     BEGIN_CS(r300screen->caps->is_r500 ? 8 : 6);
@@ -128,10 +129,10 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state)
         OUT_CS(0);
     }
 
-    OUT_CS(dsa->stencil_ref_mask);
+    OUT_CS(dsa->stencil_ref_mask | stencil_ref.ref_value[0]);
 
     if (r300screen->caps->is_r500) {
-        OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf);
+        OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf | stencil_ref.ref_value[1]);
     }
     END_CS;
 }
index d07e90860c28e2f2b61a093045044eb3dfd556bd..a6a4f99d730f6f527ff0a8070a3fa979b4e09708 100644 (file)
@@ -425,7 +425,7 @@ static void*
             (r300_translate_stencil_op(state->stencil[0].zfail_op) <<
                 R300_S_FRONT_ZFAIL_OP_SHIFT);
 
-        dsa->stencil_ref_mask = (state->stencil[0].ref_value) |
+        dsa->stencil_ref_mask =
                 (state->stencil[0].valuemask << R300_STENCILMASK_SHIFT) |
                 (state->stencil[0].writemask << R300_STENCILWRITEMASK_SHIFT);
 
@@ -444,7 +444,7 @@ static void*
             if (caps->is_r500)
             {
                 dsa->z_buffer_control |= R500_STENCIL_REFMASK_FRONT_BACK;
-                dsa->stencil_ref_bf = (state->stencil[1].ref_value) |
+                dsa->stencil_ref_bf =
                     (state->stencil[1].valuemask <<
                     R300_STENCILMASK_SHIFT) |
                     (state->stencil[1].writemask <<
@@ -488,6 +488,14 @@ static void r300_delete_dsa_state(struct pipe_context* pipe,
     FREE(state);
 }
 
+static void r300_set_stencil_ref(struct pipe_context* pipe,
+                                 const struct pipe_stencil_ref* sr)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    r300->stencil_ref = *sr;
+    r300->dsa_state.dirty = TRUE;
+}
+
 static void
     r300_set_framebuffer_state(struct pipe_context* pipe,
                                const struct pipe_framebuffer_state* state)
@@ -1087,6 +1095,8 @@ void r300_init_state_functions(struct r300_context* r300)
     r300->context.bind_depth_stencil_alpha_state = r300_bind_dsa_state;
     r300->context.delete_depth_stencil_alpha_state = r300_delete_dsa_state;
 
+    r300->context.set_stencil_ref = r300_set_stencil_ref;
+
     r300->context.set_framebuffer_state = r300_set_framebuffer_state;
 
     r300->context.create_fs_state = r300_create_fs_state;