i915g: Don't emit state when it's already bound.
authorStéphane Marchesin <marcheu@chromium.org>
Tue, 7 Feb 2012 22:33:31 +0000 (14:33 -0800)
committerStéphane Marchesin <marcheu@chromium.org>
Mon, 13 Feb 2012 00:32:15 +0000 (16:32 -0800)
src/gallium/drivers/i915/i915_state.c

index 764547e3e064a145a4e899a7c1808ae197147cd3..02cb3eafa9457a74d4a9e42d8cfae6b7eb565c49 100644 (file)
@@ -177,6 +177,10 @@ static void i915_bind_blend_state(struct pipe_context *pipe,
                                   void *blend)
 {
    struct i915_context *i915 = i915_context(pipe);
+
+   if (i915->blend == blend)
+      return;
+
    draw_flush(i915->draw);
 
    i915->blend = (struct i915_blend_state*)blend;
@@ -194,6 +198,10 @@ static void i915_set_blend_color( struct pipe_context *pipe,
                                   const struct pipe_blend_color *blend_color )
 {
    struct i915_context *i915 = i915_context(pipe);
+
+   if (!blend_color)
+      return;
+
    draw_flush(i915->draw);
 
    i915->blend_color = *blend_color;
@@ -205,6 +213,7 @@ 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;
@@ -527,6 +536,10 @@ static void i915_bind_depth_stencil_state(struct pipe_context *pipe,
                                           void *depth_stencil)
 {
    struct i915_context *i915 = i915_context(pipe);
+
+   if (i915->depth_stencil == depth_stencil)
+      return;
+
    draw_flush(i915->draw);
 
    i915->depth_stencil = (const struct i915_depth_stencil_state *)depth_stencil;
@@ -545,6 +558,7 @@ static void i915_set_scissor_state( struct pipe_context *pipe,
                                  const struct pipe_scissor_state *scissor )
 {
    struct i915_context *i915 = i915_context(pipe);
+
    draw_flush(i915->draw);
 
    memcpy( &i915->scissor, scissor, sizeof(*scissor) );
@@ -586,6 +600,10 @@ static void
 i915_fixup_bind_fs_state(struct pipe_context *pipe, void *shader)
 {
    struct i915_context *i915 = i915_context(pipe);
+
+   if (i915->saved_fs == shader)
+      return;
+
    draw_flush(i915->draw);
 
    i915->saved_fs = shader;
@@ -597,6 +615,10 @@ static void
 i915_bind_fs_state(struct pipe_context *pipe, void *shader)
 {
    struct i915_context *i915 = i915_context(pipe);
+
+   if (i915->fs == shader)
+      return;
+
    draw_flush(i915->draw);
 
    i915->fs = (struct i915_fragment_shader*) shader;
@@ -643,6 +665,9 @@ static void i915_bind_vs_state(struct pipe_context *pipe, void *shader)
 {
    struct i915_context *i915 = i915_context(pipe);
 
+   if (i915->saved_vs == shader)
+      return;
+
    i915->saved_vs = shader;
 
    /* just pass-through to draw module */
@@ -848,6 +873,7 @@ static void i915_set_clip_state( struct pipe_context *pipe,
                             const struct pipe_clip_state *clip )
 {
    struct i915_context *i915 = i915_context(pipe);
+
    draw_flush(i915->draw);
 
    i915->saved_clip = *clip;
@@ -949,6 +975,9 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe,
 {
    struct i915_context *i915 = i915_context(pipe);
 
+   if (i915->rasterizer == raster)
+      return;
+
    i915->rasterizer = (struct i915_rasterizer_state *)raster;
 
    /* pass-through to draw module */
@@ -1016,6 +1045,9 @@ i915_bind_vertex_elements_state(struct pipe_context *pipe,
    struct i915_context *i915 = i915_context(pipe);
    struct i915_velems_state *i915_velems = (struct i915_velems_state *) velems;
 
+   if (i915->saved_velems == velems)
+      return;
+
    i915->saved_velems = velems;
 
    /* pass-through to draw module */