i915g: adapt to stencil ref changes
authorRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 17:16:09 +0000 (18:16 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 17:16:09 +0000 (18:16 +0100)
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i915/i915_state_dynamic.c
src/gallium/drivers/i915/i915_state_immediate.c

index 1479d2201a91935ce799c7a2aa3816925fe465d8..da769e7b290a5453e201cef05829abcbb2312ec8 100644 (file)
@@ -232,6 +232,7 @@ struct i915_context
    struct i915_fragment_shader *fs;
 
    struct pipe_blend_color blend_color;
+   struct pipe_stencil_ref stencil_ref;
    struct pipe_clip_state clip;
    /* XXX unneded */
    struct pipe_buffer *constants[PIPE_SHADER_TYPES];
index beb26e996a46260b3da7551794508da6fa8d73aa..14a9314dab33e2147907343ffae5c44e8c99f1ef 100644 (file)
@@ -190,7 +190,7 @@ static void i915_delete_blend_state(struct pipe_context *pipe, void *blend)
 }
 
 static void i915_set_blend_color( struct pipe_context *pipe,
-                            const struct pipe_blend_color *blend_color )
+                                  const struct pipe_blend_color *blend_color )
 {
    struct i915_context *i915 = i915_context(pipe);
    draw_flush(i915->draw);
@@ -200,6 +200,17 @@ static void i915_set_blend_color( struct pipe_context *pipe,
    i915->dirty |= I915_NEW_BLEND;
 }
 
+static void i915_set_stencil_ref( struct pipe_context *pipe,
+                                  const struct pipe_stencil_ref *stencil_ref )
+{
+   struct i915_context *i915 = i915_context(pipe);
+   draw_flush(i915->draw);
+
+   i915->stencil_ref = *stencil_ref;
+
+   i915->dirty |= I915_NEW_DEPTH_STENCIL;
+}
+
 static void *
 i915_create_sampler_state(struct pipe_context *pipe,
                           const struct pipe_sampler_state *sampler)
@@ -334,11 +345,9 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
       int fop  = i915_translate_stencil_op(depth_stencil->stencil[0].fail_op);
       int dfop = i915_translate_stencil_op(depth_stencil->stencil[0].zfail_op);
       int dpop = i915_translate_stencil_op(depth_stencil->stencil[0].zpass_op);
-      int ref  = depth_stencil->stencil[0].ref_value & 0xff;
 
       cso->stencil_LIS5 |= (S5_STENCIL_TEST_ENABLE |
                             S5_STENCIL_WRITE_ENABLE |
-                            (ref  << S5_STENCIL_REF_SHIFT) |
                             (test << S5_STENCIL_TEST_FUNC_SHIFT) |
                             (fop  << S5_STENCIL_FAIL_SHIFT) |
                             (dfop << S5_STENCIL_PASS_Z_FAIL_SHIFT) |
@@ -350,7 +359,6 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
       int fop   = i915_translate_stencil_op(depth_stencil->stencil[1].fail_op);
       int dfop  = i915_translate_stencil_op(depth_stencil->stencil[1].zfail_op);
       int dpop  = i915_translate_stencil_op(depth_stencil->stencil[1].zpass_op);
-      int ref   = depth_stencil->stencil[1].ref_value & 0xff;
       int tmask = depth_stencil->stencil[1].valuemask & 0xff;
       int wmask = depth_stencil->stencil[1].writemask & 0xff;
 
@@ -359,7 +367,6 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
                      BFO_ENABLE_STENCIL_TWO_SIDE |
                      BFO_ENABLE_STENCIL_REF |
                      BFO_STENCIL_TWO_SIDE |
-                     (ref  << BFO_STENCIL_REF_SHIFT) |
                      (test << BFO_STENCIL_TEST_SHIFT) |
                      (fop  << BFO_STENCIL_FAIL_SHIFT) |
                      (dfop << BFO_STENCIL_PASS_Z_FAIL_SHIFT) |
@@ -777,6 +784,7 @@ i915_init_state_functions( struct i915_context *i915 )
    i915->base.delete_vs_state = i915_delete_vs_state;
 
    i915->base.set_blend_color = i915_set_blend_color;
+   i915->base.set_stencil_ref = i915_set_stencil_ref;
    i915->base.set_clip_state = i915_set_clip_state;
    i915->base.set_constant_buffer = i915_set_constant_buffer;
    i915->base.set_framebuffer_state = i915_set_framebuffer_state;
index 86126a5a1522939ae24ecce1ccdd8cf04beb5db8..9c6723b39167906a35eedea81c5dca625c893437 100644 (file)
@@ -94,9 +94,16 @@ const struct i915_tracked_state i915_upload_MODES4 = {
 
 static void upload_BFO( struct i915_context *i915 )
 {
+   unsigned bfo[2];
+   bfo[0] = i915->depth_stencil->bfo[0];
+   bfo[1] = i915->depth_stencil->bfo[1];
+   /* I don't get it only allowed to set a ref mask when the enable bit is set? */
+   if (bfo[0] & BFO_ENABLE_STENCIL_REF) {
+      bfo[0] |= i915->stencil_ref.ref_value[1] << BFO_STENCIL_REF_SHIFT;
+   }
    set_dynamic_indirect( i915,
                         I915_DYNAMIC_BFO_0,
-                        &(i915->depth_stencil->bfo[0]),
+                        &(bfo[0]),
                         2 );
 }
 
index 8c16bb4e2710e63ede4c3e428f7fb02387bc55ca..d2c6f1514342a5d39da5c3d33538a17c6100ae91 100644 (file)
@@ -129,6 +129,8 @@ static void upload_S5( struct i915_context *i915 )
    unsigned LIS5 = 0;
 
    LIS5 |= i915->depth_stencil->stencil_LIS5;
+   /* hope it's safe to set stencil ref value even if stencil test is disabled? */
+   LIS5 |= i915->stencil_ref.ref_value[0] << S5_STENCIL_REF_SHIFT;
 
    LIS5 |= i915->blend->LIS5;