summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2010-02-11 04:06:01 +0100
committerRoland Scheidegger <sroland@vmware.com>2010-02-11 04:06:01 +0100
commitb75adabc89e34083ac302ac9bafc8d80b62ac14c (patch)
tree046265b87fbf22a3c00dec26f4edaec683ee3479
parent9381a2777c1a36c1b88de9edf04141c485569259 (diff)
gallium: also save/restore stencil_ref in cso_save/restore_depth_stencil_alpha
makes life of state trackers easier
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c9
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c19
2 files changed, 8 insertions, 20 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 47867e888a..e110f051af 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -93,7 +93,7 @@ struct cso_context {
struct pipe_framebuffer_state fb, fb_saved;
struct pipe_viewport_state vp, vp_saved;
struct pipe_blend_color blend_color;
- struct pipe_stencil_ref stencil_ref;
+ struct pipe_stencil_ref stencil_ref, stencil_ref_saved;
};
@@ -746,6 +746,7 @@ 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)
@@ -755,6 +756,10 @@ 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);
+ }
}
@@ -1058,8 +1063,6 @@ void cso_restore_viewport(struct cso_context *ctx)
}
-
-
enum pipe_error cso_set_blend_color(struct cso_context *ctx,
const struct pipe_blend_color *bc)
{
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index ed92e3928e..74ec85107f 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -192,7 +192,6 @@ clear_with_quad(GLcontext *ctx,
GLboolean color, GLboolean depth, GLboolean stencil)
{
struct st_context *st = ctx->st;
- struct pipe_stencil_ref stencil_ref;
const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin;
const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax;
GLfloat y0, y1;
@@ -248,7 +247,6 @@ clear_with_quad(GLcontext *ctx,
{
struct pipe_depth_stencil_alpha_state depth_stencil;
memset(&depth_stencil, 0, sizeof(depth_stencil));
- memset(&stencil_ref, 0, sizeof(stencil_ref));
if (depth) {
depth_stencil.depth.enabled = 1;
depth_stencil.depth.writemask = 1;
@@ -256,6 +254,8 @@ clear_with_quad(GLcontext *ctx,
}
if (stencil) {
+ struct pipe_stencil_ref stencil_ref;
+ memset(&stencil_ref, 0, sizeof(stencil_ref));
depth_stencil.stencil[0].enabled = 1;
depth_stencil.stencil[0].func = PIPE_FUNC_ALWAYS;
depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
@@ -285,21 +285,6 @@ clear_with_quad(GLcontext *ctx,
cso_restore_fragment_shader(st->cso_context);
cso_restore_vertex_shader(st->cso_context);
- /* cannot restore stencil ref. Try to reconstruct? */
- if (stencil) {
- if (ctx->Stencil.Enabled && ctx->DrawBuffer->Visual.stencilBits > 0) {
- stencil_ref.ref_value[0] = ctx->Stencil.Ref[0] & 0xff;
- if (ctx->Stencil._TestTwoSide) {
- const GLuint back = ctx->Stencil._BackFace;
- stencil_ref.ref_value[1] = ctx->Stencil.Ref[back] & 0xff;
- }
- else {
- stencil_ref.ref_value[1] = stencil_ref.ref_value[0];
- }
- }
- cso_set_stencil_ref(st->cso_context, &stencil_ref);
- }
-
}