summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-01-31 03:03:25 +0100
committerMarek Olšák <[email protected]>2018-02-04 01:50:10 +0100
commitaf3685d14936844f79e6f372b4b258e29375f21b (patch)
tree84c3ab4b661bceaf4364be3e7c9501cb6b50537e /src/mesa/swrast
parent83e60ce927142752c57163fcb8b30eca2370d014 (diff)
mesa: change ctx->Color.ColorMask into a 32-bit bitmask
4 bits per draw buffer, 8 draw buffers in total --> 32 bits. This is easier to work with. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_clear.c8
-rw-r--r--src/mesa/swrast/s_context.c10
-rw-r--r--src/mesa/swrast/s_masking.c24
-rw-r--r--src/mesa/swrast/s_span.c6
-rw-r--r--src/mesa/swrast/s_triangle.c8
5 files changed, 31 insertions, 25 deletions
diff --git a/src/mesa/swrast/s_clear.c b/src/mesa/swrast/s_clear.c
index c26b4be0d9e..ddafb67c98f 100644
--- a/src/mesa/swrast/s_clear.c
+++ b/src/mesa/swrast/s_clear.c
@@ -187,7 +187,13 @@ clear_color_buffers(struct gl_context *ctx)
if (rb == NULL)
continue;
- clear_rgba_buffer(ctx, rb, ctx->Color.ColorMask[buf]);
+ const GLubyte colormask[4] = {
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 0) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 1) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 2) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 3) ? 0xff : 0,
+ };
+ clear_rgba_buffer(ctx, rb, colormask);
}
}
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 9f3d21f91d1..f7f08b19dd9 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -65,10 +65,7 @@ _swrast_update_rasterflags( struct gl_context *ctx )
if (ctx->Scissor.EnableFlags) rasterMask |= CLIP_BIT;
if (_mesa_stencil_is_enabled(ctx)) rasterMask |= STENCIL_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]) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, i) != 0xf) {
rasterMask |= MASKING_BIT;
break;
}
@@ -96,10 +93,7 @@ _swrast_update_rasterflags( struct gl_context *ctx )
}
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) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, i) == 0) {
rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
break;
}
diff --git a/src/mesa/swrast/s_masking.c b/src/mesa/swrast/s_masking.c
index c10bf1ac251..8941375a999 100644
--- a/src/mesa/swrast/s_masking.c
+++ b/src/mesa/swrast/s_masking.c
@@ -56,8 +56,14 @@ _swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
* Note that we're not using span->array->mask[] here. We could...
*/
if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ const GLubyte colormask[4] = {
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 0) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 1) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 2) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 3) ? 0xff : 0,
+ };
GLuint srcMask;
- memcpy(&srcMask, ctx->Color.ColorMask[buf], sizeof(srcMask));
+ memcpy(&srcMask, colormask, sizeof(srcMask));
const GLuint dstMask = ~srcMask;
const GLuint *dst = (const GLuint *) rbPixels;
GLuint *src = (GLuint *) span->array->rgba8;
@@ -69,10 +75,10 @@ _swrast_mask_rgba_span(struct gl_context *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[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 rMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 0) ? 0xffff : 0x0;
+ const GLushort gMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 1) ? 0xffff : 0x0;
+ const GLushort bMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 2) ? 0xffff : 0x0;
+ const GLushort aMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 3) ? 0xffff : 0x0;
const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
GLushort (*src)[4] = span->array->rgba16;
GLuint i;
@@ -85,10 +91,10 @@ _swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb,
}
else {
/* 4-byte components */
- 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 rMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 0) ? ~0x0 : 0x0;
+ const GLuint gMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 1) ? ~0x0 : 0x0;
+ const GLuint bMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 2) ? ~0x0 : 0x0;
+ const GLuint aMask = GET_COLORMASK_BIT(ctx->Color.ColorMask, buf, 3) ? ~0x0 : 0x0;
const GLuint (*dst)[4] = (const GLuint (*)[4]) rbPixels;
GLuint (*src)[4] = (GLuint (*)[4]) span->array->attribs[VARYING_SLOT_COL0];
GLuint i;
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 47a73e99f3d..9bc1f227fe1 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1133,7 +1133,6 @@ void
_swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
- const GLuint *colorMask = (GLuint *) ctx->Color.ColorMask;
const GLbitfield origInterpMask = span->interpMask;
const GLbitfield origArrayMask = span->arrayMask;
const GLbitfield64 origArrayAttribs = span->arrayAttribs;
@@ -1251,7 +1250,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
/* We had to wait until now to check for glColorMask(0,0,0,0) because of
* the occlusion test.
*/
- if (fb->_NumColorDrawBuffers == 1 && colorMask[0] == 0x0) {
+ if (fb->_NumColorDrawBuffers == 1 &&
+ !GET_COLORMASK(ctx->Color.ColorMask, 0)) {
/* no colors to write */
goto end;
}
@@ -1368,7 +1368,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
_swrast_blend_span(ctx, rb, span);
}
- if (colorMask[buf] != 0xffffffff) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, buf) != 0xf) {
_swrast_mask_rgba_span(ctx, rb, span, buf);
}
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index a4113e5582b..c84cfec93d3 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1027,10 +1027,10 @@ _swrast_choose_triangle( struct gl_context *ctx )
!_mesa_stencil_is_enabled(ctx) &&
depthRb &&
depthRb->Format == MESA_FORMAT_Z_UNORM16) {
- if (ctx->Color.ColorMask[0][0] == 0 &&
- ctx->Color.ColorMask[0][1] == 0 &&
- ctx->Color.ColorMask[0][2] == 0 &&
- ctx->Color.ColorMask[0][3] == 0) {
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0) == 0 &&
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1) == 0 &&
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2) == 0 &&
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) == 0) {
USE(occlusion_zless_16_triangle);
return;
}