summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_accum.c2
-rw-r--r--src/mesa/swrast/s_bitmap.c4
-rw-r--r--src/mesa/swrast/s_blit.c4
-rw-r--r--src/mesa/swrast/s_clear.c54
-rw-r--r--src/mesa/swrast/s_context.c28
-rw-r--r--src/mesa/swrast/s_copypix.c4
-rw-r--r--src/mesa/swrast/s_drawpix.c4
-rw-r--r--src/mesa/swrast/s_masking.c20
-rw-r--r--src/mesa/swrast/s_masking.h2
-rw-r--r--src/mesa/swrast/s_span.c10
-rw-r--r--src/mesa/swrast/s_triangle.c8
11 files changed, 80 insertions, 60 deletions
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index c6c7dbf5cf..2d8c361e5d 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -528,7 +528,7 @@ accum_return(GLcontext *ctx, GLfloat value,
for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) {
struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buffer];
if (masking) {
- _swrast_mask_rgba_span(ctx, rb, &span);
+ _swrast_mask_rgba_span(ctx, rb, &span, buffer);
}
rb->PutRow(ctx, rb, width, xpos, ypos + i, span.array->rgba, NULL);
}
diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c
index 3dbdf2a61a..46c63aa645 100644
--- a/src/mesa/swrast/s_bitmap.c
+++ b/src/mesa/swrast/s_bitmap.c
@@ -30,6 +30,7 @@
#include "main/glheader.h"
#include "main/bufferobj.h"
+#include "main/condrender.h"
#include "main/image.h"
#include "main/macros.h"
#include "main/pixel.h"
@@ -56,6 +57,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
ASSERT(ctx->RenderMode == GL_RENDER);
+ if (!_mesa_check_conditional_render(ctx))
+ return; /* don't draw */
+
bitmap = (const GLubyte *) _mesa_map_pbo_source(ctx, unpack, bitmap);
if (!bitmap)
return;
diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c
index 8303e4debc..f73ac78ae2 100644
--- a/src/mesa/swrast/s_blit.c
+++ b/src/mesa/swrast/s_blit.c
@@ -24,6 +24,7 @@
#include "main/glheader.h"
+#include "main/condrender.h"
#include "main/image.h"
#include "main/macros.h"
#include "s_context.h"
@@ -567,6 +568,9 @@ _swrast_BlitFramebuffer(GLcontext *ctx,
};
GLint i;
+ if (!_mesa_check_conditional_render(ctx))
+ return; /* don't clear */
+
if (!ctx->DrawBuffer->_NumColorDrawBuffers)
return;
diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c
index 002718ded8..21167a64b3 100644
--- a/src/mesa/swrast/s_clear.c
+++ b/src/mesa/swrast/s_clear.c
@@ -24,6 +24,7 @@
#include "main/glheader.h"
#include "main/colormac.h"
+#include "main/condrender.h"
#include "main/formats.h"
#include "main/macros.h"
#include "main/imports.h"
@@ -40,7 +41,8 @@
* Clear the color buffer when glColorMask is in effect.
*/
static void
-clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
+clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint buf)
{
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
@@ -95,7 +97,7 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
for (i = 0; i < height; i++) {
span.x = x;
span.y = y + i;
- _swrast_mask_rgba_span(ctx, rb, &span);
+ _swrast_mask_rgba_span(ctx, rb, &span, buf);
/* write masked row */
rb->PutRow(ctx, rb, width, x, y + i, span.array->rgba, NULL);
}
@@ -145,7 +147,7 @@ clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
* Clear an rgba color buffer without channel masking.
*/
static void
-clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint buf)
{
const GLint x = ctx->DrawBuffer->_Xmin;
const GLint y = ctx->DrawBuffer->_Ymin;
@@ -158,10 +160,10 @@ clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
ASSERT(ctx->Visual.rgbMode);
- ASSERT(ctx->Color.ColorMask[0] &&
- ctx->Color.ColorMask[1] &&
- ctx->Color.ColorMask[2] &&
- ctx->Color.ColorMask[3]);
+ ASSERT(ctx->Color.ColorMask[buf][0] &&
+ ctx->Color.ColorMask[buf][1] &&
+ ctx->Color.ColorMask[buf][2] &&
+ ctx->Color.ColorMask[buf][3]);
ASSERT(rb->PutMonoRow);
@@ -246,43 +248,24 @@ clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
static void
clear_color_buffers(GLcontext *ctx)
{
- GLboolean masking;
GLuint buf;
- if (ctx->Visual.rgbMode) {
- if (ctx->Color.ColorMask[0] &&
- ctx->Color.ColorMask[1] &&
- ctx->Color.ColorMask[2] &&
- ctx->Color.ColorMask[3]) {
- masking = GL_FALSE;
- }
- else {
- masking = GL_TRUE;
- }
- }
- else {
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
- const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1;
- if ((ctx->Color.IndexMask & indexMask) == indexMask) {
- masking = GL_FALSE;
- }
- else {
- masking = GL_TRUE;
- }
- }
-
for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf];
if (ctx->Visual.rgbMode) {
- if (masking) {
- clear_rgba_buffer_with_masking(ctx, rb);
+ if (ctx->Color.ColorMask[buf][0] == 0 ||
+ ctx->Color.ColorMask[buf][1] == 0 ||
+ ctx->Color.ColorMask[buf][2] == 0 ||
+ ctx->Color.ColorMask[buf][3] == 0) {
+ clear_rgba_buffer_with_masking(ctx, rb, buf);
}
else {
- clear_rgba_buffer(ctx, rb);
+ clear_rgba_buffer(ctx, rb, buf);
}
}
else {
- if (masking) {
+ const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1;
+ if ((ctx->Color.IndexMask & indexMask) != indexMask) {
clear_ci_buffer_with_masking(ctx, rb);
}
else {
@@ -318,6 +301,9 @@ _swrast_Clear(GLcontext *ctx, GLbitfield buffers)
}
#endif
+ if (!_mesa_check_conditional_render(ctx))
+ return; /* don't clear */
+
swrast_render_start(ctx);
/* do software clearing here */
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index abf0008565..f9092c215a 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -55,6 +55,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLbitfield rasterMask = 0;
+ GLuint i;
if (ctx->Color.AlphaEnabled) rasterMask |= ALPHATEST_BIT;
if (ctx->Color.BlendEnabled) rasterMask |= BLEND_BIT;
@@ -63,8 +64,15 @@ _swrast_update_rasterflags( GLcontext *ctx )
if (ctx->Scissor.Enabled) rasterMask |= CLIP_BIT;
if (ctx->Stencil._Enabled) rasterMask |= STENCIL_BIT;
if (ctx->Visual.rgbMode) {
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- if (colorMask != 0xffffffff) rasterMask |= MASKING_BIT;
+ for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+ if (!ctx->Color.ColorMask[i][0] ||
+ !ctx->Color.ColorMask[i][1] ||
+ !ctx->Color.ColorMask[i][2] ||
+ !ctx->Color.ColorMask[i][3]) {
+ rasterMask |= MASKING_BIT;
+ break;
+ }
+ }
if (ctx->Color._LogicOpEnabled) rasterMask |= LOGIC_OP_BIT;
if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT;
}
@@ -92,13 +100,23 @@ _swrast_update_rasterflags( GLcontext *ctx )
/* more than one color buffer designated for writing (or zero buffers) */
rasterMask |= MULTI_DRAW_BIT;
}
- else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) {
- rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
- }
else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) {
rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */
}
+ if (ctx->Visual.rgbMode) {
+ for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+ if (ctx->Color.ColorMask[i][0] +
+ ctx->Color.ColorMask[i][1] +
+ ctx->Color.ColorMask[i][2] +
+ ctx->Color.ColorMask[i][3] == 0) {
+ rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
+ break;
+ }
+ }
+ }
+
+
if (ctx->FragmentProgram._Current) {
rasterMask |= FRAGPROG_BIT;
}
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index 5ecfb1e90a..986b6aff4f 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -26,6 +26,7 @@
#include "main/glheader.h"
#include "main/context.h"
#include "main/colormac.h"
+#include "main/condrender.h"
#include "main/convolve.h"
#include "main/histogram.h"
#include "main/image.h"
@@ -901,6 +902,9 @@ _swrast_CopyPixels( GLcontext *ctx,
SWcontext *swrast = SWRAST_CONTEXT(ctx);
swrast_render_start(ctx);
+ if (!_mesa_check_conditional_render(ctx))
+ return; /* don't copy */
+
if (swrast->NewState)
_swrast_validate_derived( ctx );
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 6970b2e9cb..55a4c4c3c6 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -25,6 +25,7 @@
#include "main/glheader.h"
#include "main/bufferobj.h"
+#include "main/condrender.h"
#include "main/context.h"
#include "main/convolve.h"
#include "main/image.h"
@@ -831,6 +832,9 @@ _swrast_DrawPixels( GLcontext *ctx,
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLboolean save_vp_override = ctx->VertexProgram._Overriden;
+ if (!_mesa_check_conditional_render(ctx))
+ return; /* don't draw */
+
/* We are creating fragments directly, without going through vertex
* programs.
*
diff --git a/src/mesa/swrast/s_masking.c b/src/mesa/swrast/s_masking.c
index df779b0739..69c2feb6da 100644
--- a/src/mesa/swrast/s_masking.c
+++ b/src/mesa/swrast/s_masking.c
@@ -41,7 +41,7 @@
*/
void
_swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
- SWspan *span)
+ SWspan *span, GLuint buf)
{
const GLuint n = span->end;
void *rbPixels;
@@ -58,7 +58,7 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
*/
if (span->array->ChanType == GL_UNSIGNED_BYTE) {
/* treat 4xGLubyte as 1xGLuint */
- const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask);
+ const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask[buf]);
const GLuint dstMask = ~srcMask;
const GLuint *dst = (const GLuint *) rbPixels;
GLuint *src = (GLuint *) span->array->rgba8;
@@ -70,10 +70,10 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
/* 2-byte components */
/* XXX try to use 64-bit arithmetic someday */
- const GLushort rMask = ctx->Color.ColorMask[RCOMP] ? 0xffff : 0x0;
- const GLushort gMask = ctx->Color.ColorMask[GCOMP] ? 0xffff : 0x0;
- const GLushort bMask = ctx->Color.ColorMask[BCOMP] ? 0xffff : 0x0;
- const GLushort aMask = ctx->Color.ColorMask[ACOMP] ? 0xffff : 0x0;
+ const GLushort rMask = ctx->Color.ColorMask[buf][RCOMP] ? 0xffff : 0x0;
+ const GLushort gMask = ctx->Color.ColorMask[buf][GCOMP] ? 0xffff : 0x0;
+ const GLushort bMask = ctx->Color.ColorMask[buf][BCOMP] ? 0xffff : 0x0;
+ const GLushort aMask = ctx->Color.ColorMask[buf][ACOMP] ? 0xffff : 0x0;
const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
GLushort (*src)[4] = span->array->rgba16;
GLuint i;
@@ -86,10 +86,10 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
}
else {
/* 4-byte components */
- const GLuint rMask = ctx->Color.ColorMask[RCOMP] ? ~0x0 : 0x0;
- const GLuint gMask = ctx->Color.ColorMask[GCOMP] ? ~0x0 : 0x0;
- const GLuint bMask = ctx->Color.ColorMask[BCOMP] ? ~0x0 : 0x0;
- const GLuint aMask = ctx->Color.ColorMask[ACOMP] ? ~0x0 : 0x0;
+ const GLuint rMask = ctx->Color.ColorMask[buf][RCOMP] ? ~0x0 : 0x0;
+ const GLuint gMask = ctx->Color.ColorMask[buf][GCOMP] ? ~0x0 : 0x0;
+ const GLuint bMask = ctx->Color.ColorMask[buf][BCOMP] ? ~0x0 : 0x0;
+ const GLuint aMask = ctx->Color.ColorMask[buf][ACOMP] ? ~0x0 : 0x0;
const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[FRAG_ATTRIB_COL0];
GLuint i;
diff --git a/src/mesa/swrast/s_masking.h b/src/mesa/swrast/s_masking.h
index 3260ca34e3..fed47f8cfb 100644
--- a/src/mesa/swrast/s_masking.h
+++ b/src/mesa/swrast/s_masking.h
@@ -32,7 +32,7 @@
extern void
_swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
- SWspan *span);
+ SWspan *span, GLuint buf);
extern void
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 1a51d4f045..4ea9547cd9 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1278,7 +1278,7 @@ void
_swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
+ const GLuint *colorMask = (GLuint *) ctx->Color.ColorMask;
const GLbitfield origInterpMask = span->interpMask;
const GLbitfield origArrayMask = span->arrayMask;
const GLbitfield origArrayAttribs = span->arrayAttribs;
@@ -1389,7 +1389,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
/* We had to wait until now to check for glColorMask(0,0,0,0) because of
* the occlusion test.
*/
- if (colorMask == 0x0) {
+ if (fb->_NumColorDrawBuffers == 1 && colorMask[0] == 0x0) {
/* no colors to write */
goto end;
}
@@ -1479,12 +1479,12 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
if (ctx->Color._LogicOpEnabled) {
_swrast_logicop_rgba_span(ctx, rb, span);
}
- else if (ctx->Color.BlendEnabled) {
+ else if ((ctx->Color.BlendEnabled >> buf) & 1) {
_swrast_blend_span(ctx, rb, span);
}
- if (colorMask != 0xffffffff) {
- _swrast_mask_rgba_span(ctx, rb, span);
+ if (colorMask[buf] != 0xffffffff) {
+ _swrast_mask_rgba_span(ctx, rb, span, buf);
}
if (span->arrayMask & SPAN_XY) {
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 5bec606696..11184b72ce 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1030,10 +1030,10 @@ _swrast_choose_triangle( GLcontext *ctx )
ctx->Depth.Func == GL_LESS &&
!ctx->Stencil._Enabled) {
if ((rgbmode &&
- ctx->Color.ColorMask[0] == 0 &&
- ctx->Color.ColorMask[1] == 0 &&
- ctx->Color.ColorMask[2] == 0 &&
- ctx->Color.ColorMask[3] == 0)
+ ctx->Color.ColorMask[0][0] == 0 &&
+ ctx->Color.ColorMask[0][1] == 0 &&
+ ctx->Color.ColorMask[0][2] == 0 &&
+ ctx->Color.ColorMask[0][3] == 0)
||
(!rgbmode && ctx->Color.IndexMask == 0)) {
USE(occlusion_zless_triangle);