summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/common/driverfuncs.c8
-rw-r--r--src/mesa/drivers/common/meta.c41
-rw-r--r--src/mesa/drivers/common/meta.h2
-rw-r--r--src/mesa/drivers/dri/i915/intel_clear.c5
-rw-r--r--src/mesa/drivers/dri/i915/intel_pixel.c5
-rw-r--r--src/mesa/drivers/dri/i915/intel_pixel_copy.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_blorp.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c8
-rw-r--r--src/mesa/drivers/dri/i965/genX_state_upload.c13
-rw-r--r--src/mesa/drivers/dri/i965/intel_pixel.c5
-rw-r--r--src/mesa/drivers/dri/i965/intel_pixel_copy.c5
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_driver.c8
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_context.c5
-rw-r--r--src/mesa/drivers/dri/nouveau/nv04_state_raster.c8
-rw-r--r--src/mesa/drivers/dri/nouveau/nv10_state_raster.c8
-rw-r--r--src/mesa/drivers/dri/nouveau/nv20_context.c8
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.c8
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state.c8
-rw-r--r--src/mesa/drivers/x11/xm_dd.c4
19 files changed, 70 insertions, 93 deletions
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 99c1520d2ad..8f2e3e075c8 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -232,10 +232,10 @@ _mesa_init_driver_state(struct gl_context *ctx)
ctx->Color.Blend[0].DstA);
ctx->Driver.ColorMask(ctx,
- ctx->Color.ColorMask[0][RCOMP],
- ctx->Color.ColorMask[0][GCOMP],
- ctx->Color.ColorMask[0][BCOMP],
- ctx->Color.ColorMask[0][ACOMP]);
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3));
ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode);
ctx->Driver.DepthFunc(ctx, ctx->Depth.Func);
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index a48f7000269..a7dd139500f 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -515,10 +515,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
_mesa_set_enable(ctx, GL_DITHER, GL_TRUE);
}
- if (state & MESA_META_COLOR_MASK) {
- memcpy(save->ColorMask, ctx->Color.ColorMask,
- sizeof(ctx->Color.ColorMask));
- }
+ if (state & MESA_META_COLOR_MASK)
+ save->ColorMask = ctx->Color.ColorMask;
if (state & MESA_META_DEPTH_TEST) {
save->Depth = ctx->Depth; /* struct copy */
@@ -880,17 +878,20 @@ _mesa_meta_end(struct gl_context *ctx)
if (state & MESA_META_COLOR_MASK) {
GLuint i;
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
- if (!TEST_EQ_4V(ctx->Color.ColorMask[i], save->ColorMask[i])) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, i) !=
+ GET_COLORMASK(save->ColorMask, i)) {
if (i == 0) {
- _mesa_ColorMask(save->ColorMask[i][0], save->ColorMask[i][1],
- save->ColorMask[i][2], save->ColorMask[i][3]);
+ _mesa_ColorMask(GET_COLORMASK_BIT(save->ColorMask, i, 0),
+ GET_COLORMASK_BIT(save->ColorMask, i, 1),
+ GET_COLORMASK_BIT(save->ColorMask, i, 2),
+ GET_COLORMASK_BIT(save->ColorMask, i, 3));
}
else {
_mesa_ColorMaski(i,
- save->ColorMask[i][0],
- save->ColorMask[i][1],
- save->ColorMask[i][2],
- save->ColorMask[i][3]);
+ GET_COLORMASK_BIT(save->ColorMask, i, 0),
+ GET_COLORMASK_BIT(save->ColorMask, i, 1),
+ GET_COLORMASK_BIT(save->ColorMask, i, 2),
+ GET_COLORMASK_BIT(save->ColorMask, i, 3));
}
}
}
@@ -1631,18 +1632,6 @@ _mesa_meta_drawbuffers_from_bitfield(GLbitfield bits)
}
/**
- * Return if all of the color channels are masked.
- */
-static inline GLboolean
-is_color_disabled(struct gl_context *ctx, int i)
-{
- return !ctx->Color.ColorMask[i][0] &&
- !ctx->Color.ColorMask[i][1] &&
- !ctx->Color.ColorMask[i][2] &&
- !ctx->Color.ColorMask[i][3];
-}
-
-/**
* Given a bitfield of BUFFER_BIT_x draw buffers, call glDrawBuffers to
* set GL to only draw to those buffers. Also, update color masks to
* reflect the new draw buffer ordering.
@@ -1666,7 +1655,8 @@ _mesa_meta_drawbuffers_and_colormask(struct gl_context *ctx, GLbitfield mask)
gl_buffer_index b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
int colormask_idx = ctx->Extensions.EXT_draw_buffers2 ? i : 0;
- if (b < 0 || !(mask & (1 << b)) || is_color_disabled(ctx, colormask_idx))
+ if (b < 0 || !(mask & (1 << b)) ||
+ GET_COLORMASK(ctx->Color.ColorMask, colormask_idx) == 0)
continue;
switch (b) {
@@ -1689,7 +1679,8 @@ _mesa_meta_drawbuffers_and_colormask(struct gl_context *ctx, GLbitfield mask)
}
for (int k = 0; k < 4; k++)
- colormask[num_bufs][k] = ctx->Color.ColorMask[colormask_idx][k];
+ colormask[num_bufs][k] = GET_COLORMASK_BIT(ctx->Color.ColorMask,
+ colormask_idx, k);
num_bufs++;
}
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 3d9c2917d2d..1c35ea3e0bf 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -90,7 +90,7 @@ struct save_state
GLboolean DitherFlag;
/** MESA_META_COLOR_MASK */
- GLubyte ColorMask[MAX_DRAW_BUFFERS][4];
+ GLbitfield ColorMask;
/** MESA_META_DEPTH_TEST */
struct gl_depthbuffer_attrib Depth;
diff --git a/src/mesa/drivers/dri/i915/intel_clear.c b/src/mesa/drivers/dri/i915/intel_clear.c
index f8df2e08d37..c9722cbe405 100644
--- a/src/mesa/drivers/dri/i915/intel_clear.c
+++ b/src/mesa/drivers/dri/i915/intel_clear.c
@@ -81,7 +81,6 @@ static void
intelClear(struct gl_context *ctx, GLbitfield mask)
{
struct intel_context *intel = intel_context(ctx);
- GLuint colorMask;
GLbitfield tri_mask = 0;
GLbitfield blit_mask = 0;
GLbitfield swrast_mask = 0;
@@ -89,8 +88,6 @@ intelClear(struct gl_context *ctx, GLbitfield mask)
struct intel_renderbuffer *irb;
int i;
- memcpy(&colorMask, &ctx->Color.ColorMask[0], sizeof(colorMask));
-
if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT)) {
intel->front_buffer_dirty = true;
}
@@ -115,7 +112,7 @@ intelClear(struct gl_context *ctx, GLbitfield mask)
}
/* HW color buffers (front, back, aux, generic FBO, etc) */
- if (colorMask == ~0) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, 0) == 0xf) {
/* clear all R,G,B,A */
blit_mask |= (mask & BUFFER_BITS_COLOR);
}
diff --git a/src/mesa/drivers/dri/i915/intel_pixel.c b/src/mesa/drivers/dri/i915/intel_pixel.c
index 084b5636b48..eaca8e30978 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel.c
@@ -83,10 +83,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
return false;
}
- if (!(ctx->Color.ColorMask[0][0] &&
- ctx->Color.ColorMask[0][1] &&
- ctx->Color.ColorMask[0][2] &&
- ctx->Color.ColorMask[0][3])) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, 0) != 0xf) {
DBG("fallback due to color masking\n");
return false;
}
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
index 0dea8f9c796..1b1993ea728 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
@@ -130,10 +130,7 @@ do_blit_copypixels(struct gl_context * ctx,
return false;
}
- if (!ctx->Color.ColorMask[0][0] ||
- !ctx->Color.ColorMask[0][1] ||
- !ctx->Color.ColorMask[0][2] ||
- !ctx->Color.ColorMask[0][3]) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, 0) != 0xf) {
perf_debug("glCopyPixels(): Unsupported color mask state\n");
return false;
}
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c
index 82d9de1ead5..30120df9a50 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.c
+++ b/src/mesa/drivers/dri/i965/brw_blorp.c
@@ -1117,7 +1117,7 @@ err:
static bool
set_write_disables(const struct intel_renderbuffer *irb,
- const GLubyte *color_mask, bool *color_write_disable)
+ const unsigned color_mask, bool *color_write_disable)
{
/* Format information in the renderbuffer represents the requirements
* given by the client. There are cases where the backing miptree uses,
@@ -1131,8 +1131,8 @@ set_write_disables(const struct intel_renderbuffer *irb,
assert(components > 0);
for (int i = 0; i < components; i++) {
- color_write_disable[i] = !color_mask[i];
- disables = disables || !color_mask[i];
+ color_write_disable[i] = !(color_mask & (1 << i));
+ disables = disables || color_write_disable[i];
}
return disables;
@@ -1169,7 +1169,8 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,
bool can_fast_clear = !partial_clear;
bool color_write_disable[4] = { false, false, false, false };
- if (set_write_disables(irb, ctx->Color.ColorMask[buf], color_write_disable))
+ if (set_write_disables(irb, GET_COLORMASK(ctx->Color.ColorMask, buf),
+ color_write_disable))
can_fast_clear = false;
/* We store clear colors as floats or uints as needed. If there are
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 611e85024d8..92ac1e45a3a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -919,18 +919,18 @@ gen4_update_renderbuffer_surface(struct brw_context *brw,
(ctx->Color.BlendEnabled & (1 << unit)))
surf[0] |= BRW_SURFACE_BLEND_ENABLED;
- if (!ctx->Color.ColorMask[unit][0])
+ if (!GET_COLORMASK_BIT(ctx->Color.ColorMask, unit, 0))
surf[0] |= 1 << BRW_SURFACE_WRITEDISABLE_R_SHIFT;
- if (!ctx->Color.ColorMask[unit][1])
+ if (!GET_COLORMASK_BIT(ctx->Color.ColorMask, unit, 1))
surf[0] |= 1 << BRW_SURFACE_WRITEDISABLE_G_SHIFT;
- if (!ctx->Color.ColorMask[unit][2])
+ if (!GET_COLORMASK_BIT(ctx->Color.ColorMask, unit, 2))
surf[0] |= 1 << BRW_SURFACE_WRITEDISABLE_B_SHIFT;
/* As mentioned above, disable writes to the alpha component when the
* renderbuffer is XRGB.
*/
if (ctx->DrawBuffer->Visual.alphaBits == 0 ||
- !ctx->Color.ColorMask[unit][3]) {
+ !GET_COLORMASK_BIT(ctx->Color.ColorMask, unit, 3)) {
surf[0] |= 1 << BRW_SURFACE_WRITEDISABLE_A_SHIFT;
}
}
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 45636fe69df..e607852c7ac 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -1751,10 +1751,7 @@ brw_color_buffer_write_enabled(struct brw_context *brw)
/* _NEW_COLOR */
if (rb && (outputs_written & BITFIELD64_BIT(FRAG_RESULT_COLOR) ||
outputs_written & BITFIELD64_BIT(FRAG_RESULT_DATA0 + i)) &&
- (ctx->Color.ColorMask[i][0] ||
- ctx->Color.ColorMask[i][1] ||
- ctx->Color.ColorMask[i][2] ||
- ctx->Color.ColorMask[i][3])) {
+ GET_COLORMASK(ctx->Color.ColorMask, i)) {
return true;
}
}
@@ -2993,10 +2990,10 @@ genX(upload_blend_state)(struct brw_context *brw)
entry.PostBlendColorClampEnable = true;
entry.ColorClampRange = COLORCLAMP_RTFORMAT;
- entry.WriteDisableRed = !ctx->Color.ColorMask[i][0];
- entry.WriteDisableGreen = !ctx->Color.ColorMask[i][1];
- entry.WriteDisableBlue = !ctx->Color.ColorMask[i][2];
- entry.WriteDisableAlpha = !ctx->Color.ColorMask[i][3];
+ entry.WriteDisableRed = !GET_COLORMASK_BIT(ctx->Color.ColorMask, i, 0);
+ entry.WriteDisableGreen = !GET_COLORMASK_BIT(ctx->Color.ColorMask, i, 1);
+ entry.WriteDisableBlue = !GET_COLORMASK_BIT(ctx->Color.ColorMask, i, 2);
+ entry.WriteDisableAlpha = !GET_COLORMASK_BIT(ctx->Color.ColorMask, i, 3);
#if GEN_GEN >= 8
GENX(BLEND_STATE_ENTRY_pack)(NULL, &blend_map[1 + i * 2], &entry);
diff --git a/src/mesa/drivers/dri/i965/intel_pixel.c b/src/mesa/drivers/dri/i965/intel_pixel.c
index c69c3cc7dce..0cbb572838c 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel.c
@@ -80,10 +80,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
return false;
}
- if (!(ctx->Color.ColorMask[0][0] &&
- ctx->Color.ColorMask[0][1] &&
- ctx->Color.ColorMask[0][2] &&
- ctx->Color.ColorMask[0][3])) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, 0) != 0xf) {
DBG("fallback due to color masking\n");
return false;
}
diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
index a23c5b18ac6..8029ffbeddc 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
@@ -134,10 +134,7 @@ do_blit_copypixels(struct gl_context * ctx,
return false;
}
- if (!ctx->Color.ColorMask[0][0] ||
- !ctx->Color.ColorMask[0][1] ||
- !ctx->Color.ColorMask[0][2] ||
- !ctx->Color.ColorMask[0][3]) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, 0) != 0xf) {
perf_debug("glCopyPixels(): Unsupported color mask state\n");
return false;
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
index 998e751fc3c..1698df6ab19 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
@@ -132,7 +132,13 @@ nouveau_clear(struct gl_context *ctx, GLbitfield buffers)
else
value = pack_rgba_clamp_f(s->format, color);
- mask = pack_rgba_i(s->format, ctx->Color.ColorMask[0]);
+ const uint8_t colormask[4] = {
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2) ? 0xff : 0,
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) ? 0xff : 0,
+ };
+ mask = pack_rgba_i(s->format, colormask);
if (mask)
context_drv(ctx)->surface_fill(
diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c
index 3cc219beab4..4dbb950e9ab 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_context.c
@@ -57,10 +57,7 @@ nv04_context_engine(struct gl_context *ctx)
texunit_needs_combiners(&ctx->Texture.Unit[0])) ||
ctx->Texture.Unit[1]._Current ||
ctx->Stencil.Enabled ||
- !(ctx->Color.ColorMask[0][RCOMP] &&
- ctx->Color.ColorMask[0][GCOMP] &&
- ctx->Color.ColorMask[0][BCOMP] &&
- ctx->Color.ColorMask[0][ACOMP]))
+ GET_COLORMASK(ctx->Color.ColorMask, 0) != 0xf)
fahrenheit = hw->eng3dm;
else
fahrenheit = hw->eng3d;
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c
index 69664fb40ad..a2b0ab921de 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c
@@ -162,13 +162,13 @@ nv04_emit_control(struct gl_context *ctx, int emit)
FLOAT_TO_UBYTE(ctx->Color.AlphaRef);
/* Color mask. */
- if (ctx->Color.ColorMask[0][RCOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_RED_WRITE;
- if (ctx->Color.ColorMask[0][GCOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_GREEN_WRITE;
- if (ctx->Color.ColorMask[0][BCOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_BLUE_WRITE;
- if (ctx->Color.ColorMask[0][ACOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3))
nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_WRITE;
/* Stencil test. */
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c
index 047f539dbc5..3f4ff73cef5 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c
@@ -87,10 +87,10 @@ nv10_emit_color_mask(struct gl_context *ctx, int emit)
struct nouveau_pushbuf *push = context_push(ctx);
BEGIN_NV04(push, NV10_3D(COLOR_MASK), 1);
- PUSH_DATA (push, ((ctx->Color.ColorMask[0][3] ? 1 << 24 : 0) |
- (ctx->Color.ColorMask[0][0] ? 1 << 16 : 0) |
- (ctx->Color.ColorMask[0][1] ? 1 << 8 : 0) |
- (ctx->Color.ColorMask[0][2] ? 1 << 0 : 0)));
+ PUSH_DATA (push, ((GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) ? 1 << 24 : 0) |
+ (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0) ? 1 << 16 : 0) |
+ (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1) ? 1 << 8 : 0) |
+ (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2) ? 1 << 0 : 0)));
}
void
diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c
index 0ab2db0b086..887aa5f483f 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_context.c
@@ -55,13 +55,13 @@ nv20_clear(struct gl_context *ctx, GLbitfield buffers)
struct nouveau_surface *s = &to_nouveau_renderbuffer(
fb->_ColorDrawBuffers[0])->surface;
- if (ctx->Color.ColorMask[0][RCOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_R;
- if (ctx->Color.ColorMask[0][GCOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_G;
- if (ctx->Color.ColorMask[0][BCOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_B;
- if (ctx->Color.ColorMask[0][ACOMP])
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3))
clear |= NV20_3D_CLEAR_BUFFERS_COLOR_A;
BEGIN_NV04(push, NV20_3D(CLEAR_VALUE), 1);
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index 62a089ea750..33b696347a3 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -688,10 +688,10 @@ static void r200ColorMask( struct gl_context *ctx,
if (!rrb)
return;
mask = radeonPackColor( rrb->cpp,
- ctx->Color.ColorMask[0][RCOMP],
- ctx->Color.ColorMask[0][GCOMP],
- ctx->Color.ColorMask[0][BCOMP],
- ctx->Color.ColorMask[0][ACOMP] );
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) );
if (!(r && g && b && a))
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index a5c7be32230..e413df3542e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -504,10 +504,10 @@ static void radeonColorMask( struct gl_context *ctx,
return;
mask = radeonPackColor( rrb->cpp,
- ctx->Color.ColorMask[0][RCOMP],
- ctx->Color.ColorMask[0][GCOMP],
- ctx->Color.ColorMask[0][BCOMP],
- ctx->Color.ColorMask[0][ACOMP] );
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2),
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) );
if ( rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] != mask ) {
RADEON_STATECHANGE( rmesa, msk );
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 3e61342512d..3c576c7cd8b 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -245,7 +245,6 @@ clear_buffers(struct gl_context *ctx, GLbitfield buffers)
{
if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
/* this is a window system framebuffer */
- const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
const XMesaContext xmesa = XMESA_CONTEXT(ctx);
XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer);
const GLint x = ctx->DrawBuffer->_Xmin;
@@ -264,7 +263,8 @@ clear_buffers(struct gl_context *ctx, GLbitfield buffers)
XMesaSetForeground(xmesa->display, b->cleargc, xmesa->clearpixel);
/* we can't handle color or index masking */
- if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
+ if (GET_COLORMASK(ctx->Color.ColorMask, 0) == 0xf &&
+ ctx->Color.IndexMask == 0xffffffff) {
if (buffers & BUFFER_BIT_FRONT_LEFT) {
/* clear front color buffer */
struct gl_renderbuffer *frontRb