gallium: give pipe_stencil_ref its own cso_save/restore functions
authorRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 17:15:10 +0000 (18:15 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 11 Feb 2010 17:15:10 +0000 (18:15 +0100)
seems cleaner, and other dynamic state like viewport is handled that way too

src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/cso_cache/cso_context.h
src/mesa/state_tracker/st_cb_clear.c

index e110f051af4d56e798108dedfb83992e5d9f94fc..b5241fa64c60faba91cb99fd234b29298cb1c797 100644 (file)
@@ -746,7 +746,6 @@ void cso_save_depth_stencil_alpha(struct cso_context *ctx)
 {
    assert(!ctx->depth_stencil_saved);
    ctx->depth_stencil_saved = ctx->depth_stencil;
-   ctx->stencil_ref_saved = ctx->stencil_ref;
 }
 
 void cso_restore_depth_stencil_alpha(struct cso_context *ctx)
@@ -756,10 +755,6 @@ void cso_restore_depth_stencil_alpha(struct cso_context *ctx)
       ctx->pipe->bind_depth_stencil_alpha_state(ctx->pipe, ctx->depth_stencil_saved);
    }
    ctx->depth_stencil_saved = NULL;
-   if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved, sizeof(ctx->stencil_ref))) {
-      ctx->stencil_ref = ctx->stencil_ref_saved;
-      ctx->pipe->set_stencil_ref(ctx->pipe, &ctx->stencil_ref);
-   }
 }
 
 
@@ -1083,6 +1078,20 @@ enum pipe_error cso_set_stencil_ref(struct cso_context *ctx,
    return PIPE_OK;
 }
 
+void cso_save_stencil_ref(struct cso_context *ctx)
+{
+   ctx->stencil_ref_saved = ctx->stencil_ref;
+}
+
+
+void cso_restore_stencil_ref(struct cso_context *ctx)
+{
+   if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved, sizeof(ctx->stencil_ref))) {
+      ctx->stencil_ref = ctx->stencil_ref_saved;
+      ctx->pipe->set_stencil_ref(ctx->pipe, &ctx->stencil_ref);
+   }
+}
+
 enum pipe_error cso_set_geometry_shader_handle(struct cso_context *ctx,
                                                void *handle)
 {
index 3a6fff21e210302f8b3b891320a86a79752d0e59..707b3c2cee21734c95b66d63964b571115cfc9df 100644 (file)
@@ -176,6 +176,8 @@ enum pipe_error cso_set_blend_color(struct cso_context *cso,
 
 enum pipe_error cso_set_stencil_ref(struct cso_context *cso,
                                     const struct pipe_stencil_ref *sr);
+void cso_save_stencil_ref(struct cso_context *cso);
+void cso_restore_stencil_ref(struct cso_context *cso);
 
 
 #ifdef __cplusplus
index 74ec85107f446c377440fd2ce12eebd66054b737..898c32293d1fbc408c97108a845d4e1e4ae40d1a 100644 (file)
@@ -215,6 +215,7 @@ clear_with_quad(GLcontext *ctx,
    */
 
    cso_save_blend(st->cso_context);
+   cso_save_stencil_ref(st->cso_context);
    cso_save_depth_stencil_alpha(st->cso_context);
    cso_save_rasterizer(st->cso_context);
    cso_save_fragment_shader(st->cso_context);
@@ -280,6 +281,7 @@ clear_with_quad(GLcontext *ctx,
 
    /* Restore pipe state */
    cso_restore_blend(st->cso_context);
+   cso_restore_stencil_ref(st->cso_context);
    cso_restore_depth_stencil_alpha(st->cso_context);
    cso_restore_rasterizer(st->cso_context);
    cso_restore_fragment_shader(st->cso_context);