Y invert, clean-up
This commit is contained in:
@@ -198,79 +198,96 @@ 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 */
|
||||||
memset(&alpha_test, 0, sizeof(alpha_test));
|
{
|
||||||
st->pipe->set_alpha_test_state(st->pipe, &alpha_test);
|
struct pipe_alpha_test_state alpha_test;
|
||||||
|
memset(&alpha_test, 0, sizeof(alpha_test));
|
||||||
|
st->pipe->set_alpha_test_state(st->pipe, &alpha_test);
|
||||||
|
}
|
||||||
|
|
||||||
/* blend state: RGBA masking */
|
/* blend state: RGBA masking */
|
||||||
memset(&blend, 0, sizeof(blend));
|
{
|
||||||
if (color) {
|
struct pipe_blend_state blend;
|
||||||
if (ctx->Color.ColorMask[0])
|
memset(&blend, 0, sizeof(blend));
|
||||||
blend.colormask |= PIPE_MASK_R;
|
if (color) {
|
||||||
if (ctx->Color.ColorMask[1])
|
if (ctx->Color.ColorMask[0])
|
||||||
blend.colormask |= PIPE_MASK_G;
|
blend.colormask |= PIPE_MASK_R;
|
||||||
if (ctx->Color.ColorMask[2])
|
if (ctx->Color.ColorMask[1])
|
||||||
blend.colormask |= PIPE_MASK_B;
|
blend.colormask |= PIPE_MASK_G;
|
||||||
if (ctx->Color.ColorMask[3])
|
if (ctx->Color.ColorMask[2])
|
||||||
blend.colormask |= PIPE_MASK_A;
|
blend.colormask |= PIPE_MASK_B;
|
||||||
if (st->ctx->Color.DitherFlag)
|
if (ctx->Color.ColorMask[3])
|
||||||
blend.dither = 1;
|
blend.colormask |= PIPE_MASK_A;
|
||||||
|
if (st->ctx->Color.DitherFlag)
|
||||||
|
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 */
|
||||||
memset(&depth_test, 0, sizeof(depth_test));
|
{
|
||||||
if (depth) {
|
struct pipe_depth_state depth_test;
|
||||||
depth_test.enabled = 1;
|
memset(&depth_test, 0, sizeof(depth_test));
|
||||||
depth_test.writemask = 1;
|
if (depth) {
|
||||||
depth_test.func = PIPE_FUNC_ALWAYS;
|
depth_test.enabled = 1;
|
||||||
|
depth_test.writemask = 1;
|
||||||
|
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 */
|
||||||
memset(&setup, 0, sizeof(setup));
|
{
|
||||||
if (ctx->Scissor.Enabled)
|
struct pipe_setup_state setup;
|
||||||
setup.scissor = 1;
|
memset(&setup, 0, sizeof(setup));
|
||||||
st->pipe->set_setup_state(st->pipe, &setup);
|
if (ctx->Scissor.Enabled)
|
||||||
|
setup.scissor = 1;
|
||||||
|
st->pipe->set_setup_state(st->pipe, &setup);
|
||||||
|
}
|
||||||
|
|
||||||
/* stencil state: always set to ref value */
|
/* stencil state: always set to ref value */
|
||||||
memset(&stencil_test, 0, sizeof(stencil_test));
|
{
|
||||||
if (stencil) {
|
struct pipe_stencil_state stencil_test;
|
||||||
stencil_test.front_enabled = 1;
|
memset(&stencil_test, 0, sizeof(stencil_test));
|
||||||
stencil_test.front_func = PIPE_FUNC_ALWAYS;
|
if (stencil) {
|
||||||
stencil_test.front_fail_op = PIPE_STENCIL_OP_REPLACE;
|
stencil_test.front_enabled = 1;
|
||||||
stencil_test.front_zpass_op = PIPE_STENCIL_OP_REPLACE;
|
stencil_test.front_func = PIPE_FUNC_ALWAYS;
|
||||||
stencil_test.front_zfail_op = PIPE_STENCIL_OP_REPLACE;
|
stencil_test.front_fail_op = PIPE_STENCIL_OP_REPLACE;
|
||||||
stencil_test.ref_value[0] = ctx->Stencil.Clear;
|
stencil_test.front_zpass_op = PIPE_STENCIL_OP_REPLACE;
|
||||||
stencil_test.value_mask[0] = 0xff;
|
stencil_test.front_zfail_op = PIPE_STENCIL_OP_REPLACE;
|
||||||
stencil_test.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff;
|
stencil_test.ref_value[0] = ctx->Stencil.Clear;
|
||||||
|
stencil_test.value_mask[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 */
|
||||||
if (!stfp) {
|
{
|
||||||
stfp = make_color_shader(st);
|
static struct st_fragment_program *stfp = NULL;
|
||||||
|
struct pipe_fs_state fs;
|
||||||
|
if (!stfp) {
|
||||||
|
stfp = make_color_shader(st);
|
||||||
|
}
|
||||||
|
memset(&fs, 0, sizeof(fs));
|
||||||
|
fs.inputs_read = stfp->Base.Base.InputsRead;
|
||||||
|
fs.tokens = &stfp->tokens[0];
|
||||||
|
fs.constants = NULL;
|
||||||
|
st->pipe->set_fs_state(st->pipe, &fs);
|
||||||
}
|
}
|
||||||
memset(&fs, 0, sizeof(fs));
|
|
||||||
fs.inputs_read = stfp->Base.Base.InputsRead;
|
|
||||||
fs.tokens = &stfp->tokens[0];
|
|
||||||
fs.constants = NULL;
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user