diff options
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_accum.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_bitmap.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_blit.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_clear.c | 54 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 28 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_masking.c | 20 | ||||
-rw-r--r-- | src/mesa/swrast/s_masking.h | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfilter.c | 38 | ||||
-rw-r--r-- | src/mesa/swrast/s_triangle.c | 8 | ||||
-rw-r--r-- | src/mesa/swrast/swrast.h | 6 |
13 files changed, 103 insertions, 89 deletions
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index 6accdc53af..cf53f01b7c 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -435,10 +435,6 @@ accum_return(GLcontext *ctx, GLfloat value, struct gl_renderbuffer *accumRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer; const GLboolean directAccess = (accumRb->GetPointer(ctx, accumRb, 0, 0) != NULL); - const GLboolean masking = (!ctx->Color.ColorMask[RCOMP] || - !ctx->Color.ColorMask[GCOMP] || - !ctx->Color.ColorMask[BCOMP] || - !ctx->Color.ColorMask[ACOMP]); static GLchan multTable[32768]; static GLfloat prevMult = 0.0; @@ -526,8 +522,12 @@ accum_return(GLcontext *ctx, GLfloat value, /* store colors */ for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) { struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buffer]; + const GLboolean masking = (!ctx->Color.ColorMask[buffer][RCOMP] || + !ctx->Color.ColorMask[buffer][GCOMP] || + !ctx->Color.ColorMask[buffer][BCOMP] || + !ctx->Color.ColorMask[buffer][ACOMP]); 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 57a42b3f5d..59e26e9ea3 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" @@ -55,6 +56,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 da98730c38..e881d1be30 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/image.h" #include "main/macros.h" @@ -899,6 +900,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 59dfd65488..248d6cc1c0 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" @@ -830,6 +831,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 07248c71af..874a37b224 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; @@ -1396,7 +1396,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; } @@ -1486,12 +1486,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_texfilter.c b/src/mesa/swrast/s_texfilter.c index 0bb988e3ef..76b65cc755 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -747,28 +747,28 @@ get_border_color(const struct gl_texture_object *tObj, { switch (img->_BaseFormat) { case GL_RGB: - rgba[0] = tObj->BorderColor[0]; - rgba[1] = tObj->BorderColor[1]; - rgba[2] = tObj->BorderColor[2]; + rgba[0] = tObj->BorderColor.f[0]; + rgba[1] = tObj->BorderColor.f[1]; + rgba[2] = tObj->BorderColor.f[2]; rgba[3] = 1.0F; break; case GL_ALPHA: rgba[0] = rgba[1] = rgba[2] = 0.0; - rgba[3] = tObj->BorderColor[3]; + rgba[3] = tObj->BorderColor.f[3]; break; case GL_LUMINANCE: - rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor[0]; + rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor.f[0]; rgba[3] = 1.0; break; case GL_LUMINANCE_ALPHA: - rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor[0]; - rgba[3] = tObj->BorderColor[3]; + rgba[0] = rgba[1] = rgba[2] = tObj->BorderColor.f[0]; + rgba[3] = tObj->BorderColor.f[3]; break; case GL_INTENSITY: - rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->BorderColor[0]; + rgba[0] = rgba[1] = rgba[2] = rgba[3] = tObj->BorderColor.f[0]; break; default: - COPY_4V(rgba, tObj->BorderColor); + COPY_4V(rgba, tObj->BorderColor.f); } } @@ -2331,7 +2331,7 @@ sample_2d_array_linear(GLcontext *ctx, array = clamp_rect_coord_nearest(tObj->WrapR, texcoord[2], depth); if (array < 0 || array >= depth) { - COPY_4V(rgba, tObj->BorderColor); + COPY_4V(rgba, tObj->BorderColor.f); } else { if (img->Border) { @@ -3002,7 +3002,7 @@ sample_depth_texture( GLcontext *ctx, img->FetchTexelf(img, col, row, slice, &depthSample); } else { - depthSample = tObj->BorderColor[0]; + depthSample = tObj->BorderColor.f[0]; } result = shadow_compare(function, texcoords[i][compare_coord], @@ -3053,21 +3053,21 @@ sample_depth_texture( GLcontext *ctx, } if (slice < 0 || slice >= (GLint) depth) { - depth00 = tObj->BorderColor[0]; - depth01 = tObj->BorderColor[0]; - depth10 = tObj->BorderColor[0]; - depth11 = tObj->BorderColor[0]; + depth00 = tObj->BorderColor.f[0]; + depth01 = tObj->BorderColor.f[0]; + depth10 = tObj->BorderColor.f[0]; + depth11 = tObj->BorderColor.f[0]; } else { /* get four depth samples from the texture */ if (useBorderTexel & (I0BIT | J0BIT)) { - depth00 = tObj->BorderColor[0]; + depth00 = tObj->BorderColor.f[0]; } else { img->FetchTexelf(img, i0, j0, slice, &depth00); } if (useBorderTexel & (I1BIT | J0BIT)) { - depth10 = tObj->BorderColor[0]; + depth10 = tObj->BorderColor.f[0]; } else { img->FetchTexelf(img, i1, j0, slice, &depth10); @@ -3075,13 +3075,13 @@ sample_depth_texture( GLcontext *ctx, if (tObj->Target != GL_TEXTURE_1D_ARRAY_EXT) { if (useBorderTexel & (I0BIT | J1BIT)) { - depth01 = tObj->BorderColor[0]; + depth01 = tObj->BorderColor.f[0]; } else { img->FetchTexelf(img, i0, j1, slice, &depth01); } if (useBorderTexel & (I1BIT | J1BIT)) { - depth11 = tObj->BorderColor[0]; + depth11 = tObj->BorderColor.f[0]; } else { img->FetchTexelf(img, i1, j1, slice, &depth11); 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); diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index c183b315b6..c01cf7d1f0 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -75,12 +75,6 @@ typedef struct { } SWvertex; -/** - * Fixed point data type. - */ -typedef int GLfixed; - - #define FRAG_ATTRIB_CI FRAG_ATTRIB_COL0 |