Y invert, clean-up

This commit is contained in:
Brian
2007-08-10 16:25:21 -06:00
parent 717831ea71
commit 1c8bcc733d

View File

@@ -198,26 +198,29 @@ draw_quad(GLcontext *ctx,
/** /**
* Do glClear by drawing a quadrilateral. * Do glClear by drawing a quadrilateral.
* The vertices of the quad will be computed from the
* ctx->DrawBuffer->_X/Ymin/max fields.
*/ */
static void static void
clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0, clear_with_quad(GLcontext *ctx,
GLuint x1, GLuint y1,
GLboolean color, GLboolean depth, GLboolean stencil) GLboolean color, GLboolean depth, GLboolean stencil)
{ {
static struct st_fragment_program *stfp = NULL;
struct st_context *st = ctx->st; struct st_context *st = ctx->st;
struct pipe_alpha_test_state alpha_test; const GLfloat x0 = ctx->DrawBuffer->_Xmin;
struct pipe_blend_state blend; const GLfloat y0 = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax;
struct pipe_depth_state depth_test; const GLfloat x1 = ctx->DrawBuffer->_Xmax;
struct pipe_stencil_state stencil_test; const GLfloat y1 = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin;
struct pipe_setup_state setup;
struct pipe_fs_state fs;
/* alpha state: disabled */ /* alpha state: disabled */
{
struct pipe_alpha_test_state alpha_test;
memset(&alpha_test, 0, sizeof(alpha_test)); memset(&alpha_test, 0, sizeof(alpha_test));
st->pipe->set_alpha_test_state(st->pipe, &alpha_test); st->pipe->set_alpha_test_state(st->pipe, &alpha_test);
}
/* blend state: RGBA masking */ /* blend state: RGBA masking */
{
struct pipe_blend_state blend;
memset(&blend, 0, sizeof(blend)); memset(&blend, 0, sizeof(blend));
if (color) { if (color) {
if (ctx->Color.ColorMask[0]) if (ctx->Color.ColorMask[0])
@@ -232,8 +235,11 @@ clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0,
blend.dither = 1; blend.dither = 1;
} }
st->pipe->set_blend_state(st->pipe, &blend); st->pipe->set_blend_state(st->pipe, &blend);
}
/* depth state: always pass */ /* depth state: always pass */
{
struct pipe_depth_state depth_test;
memset(&depth_test, 0, sizeof(depth_test)); memset(&depth_test, 0, sizeof(depth_test));
if (depth) { if (depth) {
depth_test.enabled = 1; depth_test.enabled = 1;
@@ -241,14 +247,20 @@ clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0,
depth_test.func = PIPE_FUNC_ALWAYS; depth_test.func = PIPE_FUNC_ALWAYS;
} }
st->pipe->set_depth_state(st->pipe, &depth_test); st->pipe->set_depth_state(st->pipe, &depth_test);
}
/* setup state: nothing */ /* setup state: nothing */
{
struct pipe_setup_state setup;
memset(&setup, 0, sizeof(setup)); memset(&setup, 0, sizeof(setup));
if (ctx->Scissor.Enabled) if (ctx->Scissor.Enabled)
setup.scissor = 1; setup.scissor = 1;
st->pipe->set_setup_state(st->pipe, &setup); st->pipe->set_setup_state(st->pipe, &setup);
}
/* stencil state: always set to ref value */ /* stencil state: always set to ref value */
{
struct pipe_stencil_state stencil_test;
memset(&stencil_test, 0, sizeof(stencil_test)); memset(&stencil_test, 0, sizeof(stencil_test));
if (stencil) { if (stencil) {
stencil_test.front_enabled = 1; stencil_test.front_enabled = 1;
@@ -261,8 +273,12 @@ clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0,
stencil_test.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff; stencil_test.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff;
} }
st->pipe->set_stencil_state(st->pipe, &stencil_test); st->pipe->set_stencil_state(st->pipe, &stencil_test);
}
/* fragment shader state: color pass-through program */ /* fragment shader state: color pass-through program */
{
static struct st_fragment_program *stfp = NULL;
struct pipe_fs_state fs;
if (!stfp) { if (!stfp) {
stfp = make_color_shader(st); stfp = make_color_shader(st);
} }
@@ -271,6 +287,7 @@ clear_with_quad(GLcontext *ctx, GLuint x0, GLuint y0,
fs.tokens = &stfp->tokens[0]; fs.tokens = &stfp->tokens[0];
fs.constants = NULL; fs.constants = NULL;
st->pipe->set_fs_state(st->pipe, &fs); st->pipe->set_fs_state(st->pipe, &fs);
}
/* draw quad matching scissor rect (XXX verify coord round-off) */ /* draw quad matching scissor rect (XXX verify coord round-off) */
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor); draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
@@ -306,12 +323,7 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
} }
else { else {
/* masking or scissoring */ /* masking or scissoring */
clear_with_quad(ctx, clear_with_quad(ctx, GL_TRUE, GL_FALSE, GL_FALSE);
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmax,
ctx->DrawBuffer->_Ymax,
GL_TRUE, GL_FALSE, GL_FALSE);
} }
} }
@@ -333,12 +345,7 @@ clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
else { else {
/* scissoring */ /* scissoring */
/* XXX point framebuffer.cbufs[0] at the accum buffer */ /* XXX point framebuffer.cbufs[0] at the accum buffer */
clear_with_quad(ctx, clear_with_quad(ctx, GL_TRUE, GL_FALSE, GL_FALSE);
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmax,
ctx->DrawBuffer->_Ymax,
GL_TRUE, GL_FALSE, GL_FALSE);
} }
} }
@@ -356,12 +363,7 @@ clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
} }
else { else {
/* masking or scissoring or combined z/stencil buffer */ /* masking or scissoring or combined z/stencil buffer */
clear_with_quad(ctx, clear_with_quad(ctx, GL_FALSE, GL_TRUE, GL_FALSE);
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmax,
ctx->DrawBuffer->_Ymax,
GL_FALSE, GL_TRUE, GL_FALSE);
} }
} }
@@ -381,12 +383,7 @@ clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
} }
else { else {
/* masking or scissoring */ /* masking or scissoring */
clear_with_quad(ctx, clear_with_quad(ctx, GL_FALSE, GL_FALSE, GL_TRUE);
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmax,
ctx->DrawBuffer->_Ymax,
GL_FALSE, GL_FALSE, GL_TRUE);
} }
} }
@@ -421,12 +418,7 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
} }
else { else {
/* masking or scissoring */ /* masking or scissoring */
clear_with_quad(ctx, clear_with_quad(ctx, GL_FALSE, GL_TRUE, GL_TRUE);
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmin,
ctx->DrawBuffer->_Xmax,
ctx->DrawBuffer->_Ymax,
GL_FALSE, GL_TRUE, GL_TRUE);
} }
} }