gallium: also save/restore stencil_ref in cso_save/restore_depth_stencil_alpha

makes life of state trackers easier
This commit is contained in:
Roland Scheidegger
2010-02-11 04:06:01 +01:00
parent 9381a2777c
commit b75adabc89
2 changed files with 8 additions and 20 deletions

View File

@@ -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);
}
}