From 2420b283b783751d4def3a3a2a0ed8bf7bb7b6a8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 28 Jul 2009 18:45:22 +0100 Subject: mesa/st: recognize no-op scissor state when checking clear_with_quads Some apps enable scissor but set the rectangle to the dimensions of the window. Don't let this force us onto a slower clear path. --- src/mesa/state_tracker/st_cb_clear.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 668acbccb8..8a8c99f7e1 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -280,7 +280,11 @@ clear_with_quad(GLcontext *ctx, static INLINE GLboolean check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) { - if (ctx->Scissor.Enabled) + if (ctx->Scissor.Enabled && + (ctx->Scissor.X != 0 || + ctx->Scissor.Y != 0 || + ctx->Scissor.Width < rb->Width || + ctx->Scissor.Height < rb->Height)) return TRUE; if (!ctx->Color.ColorMask[0] || @@ -300,7 +304,11 @@ check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) GLboolean maskStencil = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax; - if (ctx->Scissor.Enabled) + if (ctx->Scissor.Enabled && + (ctx->Scissor.X != 0 || + ctx->Scissor.Y != 0 || + ctx->Scissor.Width < rb->Width || + ctx->Scissor.Height < rb->Height)) return TRUE; if (maskStencil) @@ -319,7 +327,11 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) const struct st_renderbuffer *strb = st_renderbuffer(rb); const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format); - if (ctx->Scissor.Enabled) + if (ctx->Scissor.Enabled && + (ctx->Scissor.X != 0 || + ctx->Scissor.Y != 0 || + ctx->Scissor.Width < rb->Width || + ctx->Scissor.Height < rb->Height)) return TRUE; if (isDS && @@ -345,7 +357,11 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) if (maskStencil) return TRUE; - if (ctx->Scissor.Enabled) + if (ctx->Scissor.Enabled && + (ctx->Scissor.X != 0 || + ctx->Scissor.Y != 0 || + ctx->Scissor.Width < rb->Width || + ctx->Scissor.Height < rb->Height)) return TRUE; /* This is correct, but it is necessary to look at the depth clear -- cgit v1.2.3 From 684282953937a37541f26c6e51ceec4134c62dfb Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 29 Jul 2009 12:47:23 +0100 Subject: mesa/st: short-circuit glFinish calls on WIN32 only Windows opengl32.dll calls glFinish prior to every swapbuffers, which makes it pretty hard to get decent performance... Work around by mapping finish to flush on PIPE_OS_WINDOWS. This is conformant, though it might confuse poorly-written benchmarks which attempt to measure a single event rather than figuring out the rate of continuous processing. --- src/mesa/state_tracker/st_cb_flush.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index fbaffd154f..f7de4e7a4d 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -152,4 +152,16 @@ void st_init_flush_functions(struct dd_function_table *functions) { functions->Flush = st_glFlush; functions->Finish = st_glFinish; + + /* Windows opengl32.dll calls glFinish prior to every swapbuffers. + * This is unnecessary and degrades performance. Luckily we have some + * scope to work around this, as the externally-visible behaviour of + * Finish() is identical to Flush() in all cases - no differences in + * rendering or ReadPixels are visible if we opt not to wait here. + * + * Only set this up on windows to avoid suprise elsewhere. + */ +#ifdef PIPE_OS_WINDOWS + functions->Finish = st_glFlush; +#endif } -- cgit v1.2.3