u_blitter: restore some states conditionally
authorMarek Olšák <maraeo@gmail.com>
Mon, 15 Aug 2011 18:52:44 +0000 (20:52 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 16 Aug 2011 07:15:11 +0000 (09:15 +0200)
src/gallium/auxiliary/util/u_blitter.c

index 7ecb76f38f231a7b83c6d0ea5dc802b2329c10a7..d8e46f07c88ff57af173fba8d360a7f171700492 100644 (file)
@@ -26,8 +26,8 @@
 
 /**
  * @file
- * Blitter utility to facilitate acceleration of the clear, clear_render_target, clear_depth_stencil
- * resource_copy_region functions.
+ * Blitter utility to facilitate acceleration of the clear, clear_render_target,
+ * clear_depth_stencil, and resource_copy_region functions.
  *
  * @author Marek Olšák
  */
@@ -197,8 +197,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
    memset(&velem[0], 0, sizeof(velem[0]) * 2);
    for (i = 0; i < 2; i++) {
       velem[i].src_offset = i * 4 * sizeof(float);
-      velem[i].instance_divisor = 0;
-      velem[i].vertex_buffer_index = 0;
       velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
    }
    ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
@@ -288,26 +286,33 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
    unsigned i;
 
    /* restore the state objects which are always required to be saved */
-   pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
-   pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
    pipe->bind_rasterizer_state(pipe, ctx->base.saved_rs_state);
-   pipe->bind_fs_state(pipe, ctx->base.saved_fs);
    pipe->bind_vs_state(pipe, ctx->base.saved_vs);
    pipe->bind_vertex_elements_state(pipe, ctx->base.saved_velem_state);
 
-   ctx->base.saved_blend_state = INVALID_PTR;
-   ctx->base.saved_dsa_state = INVALID_PTR;
    ctx->base.saved_rs_state = INVALID_PTR;
-   ctx->base.saved_fs = INVALID_PTR;
    ctx->base.saved_vs = INVALID_PTR;
    ctx->base.saved_velem_state = INVALID_PTR;
 
+   /* restore the state objects which are required to be saved for clear/copy
+    */
+   if (ctx->base.saved_blend_state != INVALID_PTR) {
+      pipe->bind_blend_state(pipe, ctx->base.saved_blend_state);
+      ctx->base.saved_blend_state = INVALID_PTR;
+   }
+   if (ctx->base.saved_dsa_state != INVALID_PTR) {
+      pipe->bind_depth_stencil_alpha_state(pipe, ctx->base.saved_dsa_state);
+      ctx->base.saved_dsa_state = INVALID_PTR;
+   }
+   if (ctx->base.saved_fs != INVALID_PTR) {
+      pipe->bind_fs_state(pipe, ctx->base.saved_fs);
+      ctx->base.saved_fs = INVALID_PTR;
+   }
+
    pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
    pipe->set_viewport_state(pipe, &ctx->base.saved_viewport);
    pipe->set_clip_state(pipe, &ctx->base.saved_clip);
 
-   /* restore the state objects which are required to be saved before copy/fill
-    */
    if (ctx->base.saved_fb_state.nr_cbufs != ~0) {
       pipe->set_framebuffer_state(pipe, &ctx->base.saved_fb_state);
       util_unreference_framebuffer_state(&ctx->base.saved_fb_state);