mesa: implement per-buffer color masking
This is part of the GL_EXT_draw_buffers2 extension and part of GL 3.0. The ctx->Color.ColorMask field is now a 2-D array. Until drivers are modified to support per-buffer color masking, they can just look at the 0th color mask. The new _mesa_ColorMaskIndexed() function will be called by glColorMaskIndexedEXT() or glColorMaski().
This commit is contained in:
@@ -264,11 +264,23 @@ _mesa_init_driver_state(GLcontext *ctx)
|
||||
ctx->Color.BlendDstRGB,
|
||||
ctx->Color.BlendSrcA, ctx->Color.BlendDstA);
|
||||
|
||||
ctx->Driver.ColorMask(ctx,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP]);
|
||||
if (ctx->Driver.ColorMaskIndexed) {
|
||||
GLuint i;
|
||||
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
|
||||
ctx->Driver.ColorMaskIndexed(ctx, i,
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ctx->Driver.ColorMask(ctx,
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP]);
|
||||
}
|
||||
|
||||
ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode);
|
||||
ctx->Driver.DepthFunc(ctx, ctx->Depth.Func);
|
||||
|
@@ -111,7 +111,7 @@ struct save_state
|
||||
GLboolean ColorLogicOpEnabled;
|
||||
|
||||
/** META_COLOR_MASK */
|
||||
GLubyte ColorMask[4];
|
||||
GLubyte ColorMask[MAX_DRAW_BUFFERS][4];
|
||||
|
||||
/** META_DEPTH_TEST */
|
||||
struct gl_depthbuffer_attrib Depth;
|
||||
@@ -347,11 +347,12 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
|
||||
}
|
||||
|
||||
if (state & META_COLOR_MASK) {
|
||||
COPY_4V(save->ColorMask, ctx->Color.ColorMask);
|
||||
if (!ctx->Color.ColorMask[0] ||
|
||||
!ctx->Color.ColorMask[1] ||
|
||||
!ctx->Color.ColorMask[2] ||
|
||||
!ctx->Color.ColorMask[3])
|
||||
memcpy(save->ColorMask, ctx->Color.ColorMask,
|
||||
sizeof(ctx->Color.ColorMask));
|
||||
if (!ctx->Color.ColorMask[0][0] ||
|
||||
!ctx->Color.ColorMask[0][1] ||
|
||||
!ctx->Color.ColorMask[0][2] ||
|
||||
!ctx->Color.ColorMask[0][3])
|
||||
_mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
}
|
||||
|
||||
@@ -581,9 +582,22 @@ _mesa_meta_end(GLcontext *ctx)
|
||||
}
|
||||
|
||||
if (state & META_COLOR_MASK) {
|
||||
if (!TEST_EQ_4V(ctx->Color.ColorMask, save->ColorMask))
|
||||
_mesa_ColorMask(save->ColorMask[0], save->ColorMask[1],
|
||||
save->ColorMask[2], save->ColorMask[3]);
|
||||
GLuint i;
|
||||
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
|
||||
if (!TEST_EQ_4V(ctx->Color.ColorMask[i], save->ColorMask[i])) {
|
||||
if (i == 0) {
|
||||
_mesa_ColorMask(save->ColorMask[i][0], save->ColorMask[i][1],
|
||||
save->ColorMask[i][2], save->ColorMask[i][3]);
|
||||
}
|
||||
else {
|
||||
_mesa_ColorMaskIndexed(i,
|
||||
save->ColorMask[i][0],
|
||||
save->ColorMask[i][1],
|
||||
save->ColorMask[i][2],
|
||||
save->ColorMask[i][3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state & META_DEPTH_TEST) {
|
||||
|
@@ -407,10 +407,10 @@ dfbClear( GLcontext *ctx, GLbitfield mask )
|
||||
#define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \
|
||||
BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT )
|
||||
if (mask & BUFFER_BIT_MASK &&
|
||||
ctx->Color.ColorMask[0] &&
|
||||
ctx->Color.ColorMask[1] &&
|
||||
ctx->Color.ColorMask[2] &&
|
||||
ctx->Color.ColorMask[3])
|
||||
ctx->Color.ColorMask[0][0] &&
|
||||
ctx->Color.ColorMask[0][1] &&
|
||||
ctx->Color.ColorMask[0][2] &&
|
||||
ctx->Color.ColorMask[0][3])
|
||||
{
|
||||
DFBRegion clip;
|
||||
GLubyte a, r, g, b;
|
||||
|
@@ -813,10 +813,10 @@ static void gammaUpdateMasks( GLcontext *ctx )
|
||||
|
||||
|
||||
GLuint mask = gammaPackColor( gmesa->gammaScreen->cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP] );
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP] );
|
||||
|
||||
if (gmesa->gammaScreen->cpp == 2) mask |= mask << 16;
|
||||
|
||||
|
@@ -575,7 +575,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
|
||||
key.draw_offset = 0;
|
||||
}
|
||||
/* _NEW_COLOR */
|
||||
memcpy(key.color_mask, ctx->Color.ColorMask,
|
||||
memcpy(key.color_mask, ctx->Color.ColorMask[0],
|
||||
sizeof(key.color_mask));
|
||||
|
||||
/* As mentioned above, disable writes to the alpha component when the
|
||||
|
@@ -68,7 +68,7 @@ static void
|
||||
intelClear(GLcontext *ctx, GLbitfield mask)
|
||||
{
|
||||
struct intel_context *intel = intel_context(ctx);
|
||||
const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
|
||||
const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask[0]);
|
||||
GLbitfield tri_mask = 0;
|
||||
GLbitfield blit_mask = 0;
|
||||
GLbitfield swrast_mask = 0;
|
||||
|
@@ -88,10 +88,10 @@ intel_check_blit_fragment_ops(GLcontext * ctx, GLboolean src_alpha_is_one)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!(ctx->Color.ColorMask[0] &&
|
||||
ctx->Color.ColorMask[1] &&
|
||||
ctx->Color.ColorMask[2] &&
|
||||
ctx->Color.ColorMask[3])) {
|
||||
if (!(ctx->Color.ColorMask[0][0] &&
|
||||
ctx->Color.ColorMask[0][1] &&
|
||||
ctx->Color.ColorMask[0][2] &&
|
||||
ctx->Color.ColorMask[0][3])) {
|
||||
DBG("fallback due to color masking\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
@@ -83,10 +83,10 @@ intel_check_copypixel_blit_fragment_ops(GLcontext * ctx)
|
||||
ctx->Depth.Test ||
|
||||
ctx->Fog.Enabled ||
|
||||
ctx->Stencil._Enabled ||
|
||||
!ctx->Color.ColorMask[0] ||
|
||||
!ctx->Color.ColorMask[1] ||
|
||||
!ctx->Color.ColorMask[2] ||
|
||||
!ctx->Color.ColorMask[3] ||
|
||||
!ctx->Color.ColorMask[0][0] ||
|
||||
!ctx->Color.ColorMask[0][1] ||
|
||||
!ctx->Color.ColorMask[0][2] ||
|
||||
!ctx->Color.ColorMask[0][3] ||
|
||||
ctx->Texture._EnabledUnits ||
|
||||
ctx->FragmentProgram._Enabled ||
|
||||
ctx->Color.BlendEnabled);
|
||||
|
@@ -527,10 +527,10 @@ static void mach64UpdateMasks( GLcontext *ctx )
|
||||
/* mach64 can't color mask with alpha blending enabled */
|
||||
if ( !ctx->Color.BlendEnabled ) {
|
||||
mask = mach64PackColor( mmesa->mach64Screen->cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP] );
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP] );
|
||||
}
|
||||
|
||||
if ( mmesa->setup.dp_write_mask != mask ) {
|
||||
|
@@ -134,10 +134,10 @@ check_color_per_fragment_ops( const GLcontext *ctx )
|
||||
ctx->Fog.Enabled ||
|
||||
ctx->Scissor.Enabled ||
|
||||
ctx->Stencil._Enabled ||
|
||||
!ctx->Color.ColorMask[0] ||
|
||||
!ctx->Color.ColorMask[1] ||
|
||||
!ctx->Color.ColorMask[2] ||
|
||||
!ctx->Color.ColorMask[3] ||
|
||||
!ctx->Color.ColorMask[0][0] ||
|
||||
!ctx->Color.ColorMask[0][1] ||
|
||||
!ctx->Color.ColorMask[0][2] ||
|
||||
!ctx->Color.ColorMask[0][3] ||
|
||||
ctx->Color.ColorLogicOpEnabled ||
|
||||
ctx->Texture._EnabledUnits
|
||||
) &&
|
||||
@@ -150,10 +150,10 @@ static GLboolean
|
||||
check_depth_per_fragment_ops( const GLcontext *ctx )
|
||||
{
|
||||
return ( ctx->Current.RasterPosValid &&
|
||||
ctx->Color.ColorMask[RCOMP] == 0 &&
|
||||
ctx->Color.ColorMask[BCOMP] == 0 &&
|
||||
ctx->Color.ColorMask[GCOMP] == 0 &&
|
||||
ctx->Color.ColorMask[ACOMP] == 0 &&
|
||||
ctx->Color.ColorMask[0][RCOMP] == 0 &&
|
||||
ctx->Color.ColorMask[0][BCOMP] == 0 &&
|
||||
ctx->Color.ColorMask[0][GCOMP] == 0 &&
|
||||
ctx->Color.ColorMask[0][ACOMP] == 0 &&
|
||||
ctx->Pixel.ZoomX == 1.0F &&
|
||||
( ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F ) );
|
||||
}
|
||||
@@ -525,10 +525,10 @@ mgaTryDrawPixels( GLcontext *ctx,
|
||||
mmesa->mgaScreen->backOffset);
|
||||
|
||||
planemask = mgaPackColor(cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP]);
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP]);
|
||||
|
||||
if (cpp == 2)
|
||||
planemask |= planemask << 16;
|
||||
|
@@ -374,13 +374,11 @@ static void mgaDDColorMask(GLcontext *ctx,
|
||||
{
|
||||
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
|
||||
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
|
||||
|
||||
|
||||
GLuint mask = mgaPackColor(mgaScreen->cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP]);
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP]);
|
||||
|
||||
if (mgaScreen->cpp == 2)
|
||||
mask = mask | (mask << 16);
|
||||
|
@@ -702,10 +702,10 @@ static void r128UpdateMasks( GLcontext *ctx )
|
||||
r128ContextPtr rmesa = R128_CONTEXT(ctx);
|
||||
|
||||
GLuint mask = r128PackColor( rmesa->r128Screen->cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP] );
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP] );
|
||||
|
||||
if ( rmesa->setup.plane_3d_mask_c != mask ) {
|
||||
rmesa->setup.plane_3d_mask_c = mask;
|
||||
|
@@ -88,10 +88,10 @@ check_color_per_fragment_ops( const GLcontext *ctx )
|
||||
ctx->Fog.Enabled ||
|
||||
ctx->Scissor.Enabled ||
|
||||
ctx->Stencil._Enabled ||
|
||||
!ctx->Color.ColorMask[0] ||
|
||||
!ctx->Color.ColorMask[1] ||
|
||||
!ctx->Color.ColorMask[2] ||
|
||||
!ctx->Color.ColorMask[3] ||
|
||||
!ctx->Color.ColorMask[0][0] ||
|
||||
!ctx->Color.ColorMask[0][1] ||
|
||||
!ctx->Color.ColorMask[0][2] ||
|
||||
!ctx->Color.ColorMask[0][3] ||
|
||||
ctx->Color.ColorLogicOpEnabled ||
|
||||
ctx->Texture._EnabledUnits
|
||||
) &&
|
||||
@@ -400,10 +400,10 @@ r200TryDrawPixels( GLcontext *ctx,
|
||||
case GL_RGBA:
|
||||
case GL_BGRA:
|
||||
planemask = radeonPackColor(cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP]);
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP]);
|
||||
|
||||
if (cpp == 2)
|
||||
planemask |= planemask << 16;
|
||||
|
@@ -721,10 +721,10 @@ static void r200ColorMask( GLcontext *ctx,
|
||||
if (!rrb)
|
||||
return;
|
||||
mask = radeonPackColor( rrb->cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP] );
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP] );
|
||||
|
||||
|
||||
if (!(r && g && b && a))
|
||||
|
@@ -1768,9 +1768,10 @@ static void r300ResetHwState(r300ContextPtr r300)
|
||||
radeon_firevertices(&r300->radeon);
|
||||
|
||||
r300ColorMask(ctx,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP], ctx->Color.ColorMask[ACOMP]);
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP]);
|
||||
|
||||
r300Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
|
||||
r300DepthMask(ctx, ctx->Depth.Mask);
|
||||
|
@@ -50,7 +50,7 @@ void r700Clear(GLcontext * ctx, GLbitfield mask)
|
||||
{
|
||||
context_t *context = R700_CONTEXT(ctx);
|
||||
__DRIdrawablePrivate *dPriv = radeon_get_drawable(&context->radeon);
|
||||
const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
|
||||
const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask[0]);
|
||||
GLbitfield swrast_mask = 0, tri_mask = 0;
|
||||
int i;
|
||||
struct gl_framebuffer *fb = ctx->DrawBuffer;
|
||||
|
@@ -1724,10 +1724,10 @@ void r700InitState(GLcontext * ctx) //-------------------
|
||||
r700InitSQConfig(ctx);
|
||||
|
||||
r700ColorMask(ctx,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP]);
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP]);
|
||||
|
||||
r700Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
|
||||
r700DepthMask(ctx, ctx->Depth.Mask);
|
||||
|
@@ -521,10 +521,10 @@ static void radeonColorMask( GLcontext *ctx,
|
||||
return;
|
||||
|
||||
mask = radeonPackColor( rrb->cpp,
|
||||
ctx->Color.ColorMask[RCOMP],
|
||||
ctx->Color.ColorMask[GCOMP],
|
||||
ctx->Color.ColorMask[BCOMP],
|
||||
ctx->Color.ColorMask[ACOMP] );
|
||||
ctx->Color.ColorMask[0][RCOMP],
|
||||
ctx->Color.ColorMask[0][GCOMP],
|
||||
ctx->Color.ColorMask[0][BCOMP],
|
||||
ctx->Color.ColorMask[0][ACOMP] );
|
||||
|
||||
if ( rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] != mask ) {
|
||||
RADEON_STATECHANGE( rmesa, msk );
|
||||
|
@@ -360,15 +360,15 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask )
|
||||
depthMask = 0;
|
||||
switch (imesa->savageScreen->cpp) {
|
||||
case 2:
|
||||
colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0],
|
||||
ctx->Color.ColorMask[1],
|
||||
ctx->Color.ColorMask[2]);
|
||||
colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0][0],
|
||||
ctx->Color.ColorMask[0][1],
|
||||
ctx->Color.ColorMask[0][2]);
|
||||
break;
|
||||
case 4:
|
||||
colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[3],
|
||||
ctx->Color.ColorMask[2],
|
||||
ctx->Color.ColorMask[1],
|
||||
ctx->Color.ColorMask[0]);
|
||||
colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[0][3],
|
||||
ctx->Color.ColorMask[0][2],
|
||||
ctx->Color.ColorMask[0][1],
|
||||
ctx->Color.ColorMask[0][0]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -611,10 +611,10 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
|
||||
ctx->Fog.Enabled ||
|
||||
ctx->Scissor.Enabled ||
|
||||
ctx->Stencil._Enabled ||
|
||||
!ctx->Color.ColorMask[0] ||
|
||||
!ctx->Color.ColorMask[1] ||
|
||||
!ctx->Color.ColorMask[2] ||
|
||||
!ctx->Color.ColorMask[3] ||
|
||||
!ctx->Color.ColorMask[0][0] ||
|
||||
!ctx->Color.ColorMask[0][1] ||
|
||||
!ctx->Color.ColorMask[0][2] ||
|
||||
!ctx->Color.ColorMask[0][3] ||
|
||||
ctx->Color.ColorLogicOpEnabled ||
|
||||
ctx->Texture._EnabledUnits ||
|
||||
fxMesa->Fallback)
|
||||
|
@@ -76,8 +76,8 @@ static void tdfxClear( GLcontext *ctx, GLbitfield mask )
|
||||
|
||||
if (fxMesa->glCtx->Visual.redBits != 8) {
|
||||
/* can only do color masking if running in 24/32bpp on Napalm */
|
||||
if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] ||
|
||||
ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) {
|
||||
if (ctx->Color.ColorMask[0][RCOMP] != ctx->Color.ColorMask[0][GCOMP] ||
|
||||
ctx->Color.ColorMask[0][GCOMP] != ctx->Color.ColorMask[0][BCOMP]) {
|
||||
softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT));
|
||||
mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
|
||||
}
|
||||
@@ -721,7 +721,7 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
|
||||
fxMesa->Glide.grColorMask( fxMesa->Color.ColorMask[RCOMP] ||
|
||||
fxMesa->Color.ColorMask[GCOMP] ||
|
||||
fxMesa->Color.ColorMask[BCOMP],
|
||||
/*fxMesa->Color.ColorMask[ACOMP]*/GL_FALSE/*[dBorca] no-no*/ );
|
||||
/*fxMesa->Color.ColorMask[0][ACOMP]*/GL_FALSE/*[dBorca] no-no*/ );
|
||||
}
|
||||
fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_MASK;
|
||||
}
|
||||
|
@@ -1238,12 +1238,12 @@ static void viaChooseColorState(GLcontext *ctx)
|
||||
else
|
||||
vmesa->regHROP = HC_HROP_P;
|
||||
|
||||
vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0],
|
||||
ctx->Color.ColorMask[1],
|
||||
ctx->Color.ColorMask[2]);
|
||||
vmesa->regHROP |= ctx->Color.ColorMask[3];
|
||||
vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0][0],
|
||||
ctx->Color.ColorMask[0][1],
|
||||
ctx->Color.ColorMask[0][2]);
|
||||
vmesa->regHROP |= ctx->Color.ColorMask[0][3];
|
||||
|
||||
if (ctx->Color.ColorMask[3])
|
||||
if (ctx->Color.ColorMask[0][3])
|
||||
vmesa->regEnable |= HC_HenAW_MASK;
|
||||
else
|
||||
vmesa->regEnable &= ~HC_HenAW_MASK;
|
||||
|
@@ -301,10 +301,10 @@ static void clear(GLcontext *ctx, GLbitfield mask)
|
||||
|
||||
/* Let swrast do all the work if the masks are not set to
|
||||
* clear all channels. */
|
||||
if (ctx->Color.ColorMask[0] != 0xff ||
|
||||
ctx->Color.ColorMask[1] != 0xff ||
|
||||
ctx->Color.ColorMask[2] != 0xff ||
|
||||
ctx->Color.ColorMask[3] != 0xff) {
|
||||
if (!ctx->Color.ColorMask[0][0] ||
|
||||
!ctx->Color.ColorMask[0][1] ||
|
||||
!ctx->Color.ColorMask[0][2] ||
|
||||
!ctx->Color.ColorMask[0][3]) {
|
||||
_swrast_Clear(ctx, mask);
|
||||
return;
|
||||
}
|
||||
|
@@ -269,7 +269,7 @@ void gld_Clear_DX7(
|
||||
D3DRECT d3dClearRect;
|
||||
|
||||
// TODO: Colourmask
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
|
||||
|
||||
if (!gld->pDev)
|
||||
return;
|
||||
@@ -427,10 +427,10 @@ void gld_NEW_COLOR(
|
||||
|
||||
/*
|
||||
// Color mask - unsupported by DX7
|
||||
if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
|
||||
if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
|
||||
if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
|
||||
if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
|
||||
if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
|
||||
if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
|
||||
if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
|
||||
if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
|
||||
_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_COLORWRITEENABLE, dwFlags));
|
||||
*/
|
||||
}
|
||||
|
@@ -269,7 +269,7 @@ void gld_Clear_DX8(
|
||||
D3DRECT d3dClearRect;
|
||||
|
||||
// TODO: Colourmask
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
|
||||
|
||||
if (!gld->pDev)
|
||||
return;
|
||||
@@ -426,10 +426,10 @@ void gld_NEW_COLOR(
|
||||
_GLD_DX8_DEV(SetRenderState(gld->pDev, D3DRS_DESTBLEND, dest));
|
||||
|
||||
// Color mask
|
||||
if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
|
||||
if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
|
||||
if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
|
||||
if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
|
||||
if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
|
||||
if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
|
||||
if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
|
||||
if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
|
||||
_GLD_DX8_DEV(SetRenderState(gld->pDev, D3DRS_COLORWRITEENABLE, dwFlags));
|
||||
}
|
||||
|
||||
|
@@ -269,7 +269,7 @@ void gld_Clear_DX9(
|
||||
D3DRECT d3dClearRect;
|
||||
|
||||
// TODO: Colourmask
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
|
||||
|
||||
if (!gld->pDev)
|
||||
return;
|
||||
@@ -424,10 +424,10 @@ void gld_NEW_COLOR(
|
||||
_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_DESTBLEND, dest));
|
||||
|
||||
// Color mask
|
||||
if (ctx->Color.ColorMask[0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
|
||||
if (ctx->Color.ColorMask[1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
|
||||
if (ctx->Color.ColorMask[2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
|
||||
if (ctx->Color.ColorMask[3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
|
||||
if (ctx->Color.ColorMask[0][0]) dwFlags |= D3DCOLORWRITEENABLE_RED;
|
||||
if (ctx->Color.ColorMask[0][1]) dwFlags |= D3DCOLORWRITEENABLE_GREEN;
|
||||
if (ctx->Color.ColorMask[0][2]) dwFlags |= D3DCOLORWRITEENABLE_BLUE;
|
||||
if (ctx->Color.ColorMask[0][3]) dwFlags |= D3DCOLORWRITEENABLE_ALPHA;
|
||||
_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_COLORWRITEENABLE, dwFlags));
|
||||
}
|
||||
|
||||
|
@@ -381,7 +381,7 @@ clear_buffers(GLcontext *ctx, GLbitfield buffers)
|
||||
{
|
||||
if (ctx->DrawBuffer->Name == 0) {
|
||||
/* this is a window system framebuffer */
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
|
||||
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask[0];
|
||||
XMesaBuffer b = XMESA_BUFFER(ctx->DrawBuffer);
|
||||
const GLint x = ctx->DrawBuffer->_Xmin;
|
||||
const GLint y = ctx->DrawBuffer->_Ymin;
|
||||
|
@@ -919,10 +919,22 @@ _mesa_PopAttrib(void)
|
||||
color->ClearColor[2],
|
||||
color->ClearColor[3]);
|
||||
_mesa_IndexMask(color->IndexMask);
|
||||
_mesa_ColorMask((GLboolean) (color->ColorMask[0] != 0),
|
||||
(GLboolean) (color->ColorMask[1] != 0),
|
||||
(GLboolean) (color->ColorMask[2] != 0),
|
||||
(GLboolean) (color->ColorMask[3] != 0));
|
||||
if (1/*ctx->Extensions.EXT_draw_buffers2*/) {
|
||||
_mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0),
|
||||
(GLboolean) (color->ColorMask[0][1] != 0),
|
||||
(GLboolean) (color->ColorMask[0][2] != 0),
|
||||
(GLboolean) (color->ColorMask[0][3] != 0));
|
||||
}
|
||||
else {
|
||||
GLuint i;
|
||||
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
|
||||
_mesa_ColorMaskIndexed(i,
|
||||
(GLboolean) (color->ColorMask[i][0] != 0),
|
||||
(GLboolean) (color->ColorMask[i][1] != 0),
|
||||
(GLboolean) (color->ColorMask[i][2] != 0),
|
||||
(GLboolean) (color->ColorMask[i][3] != 0));
|
||||
}
|
||||
}
|
||||
{
|
||||
/* Need to determine if more than one color output is
|
||||
* specified. If so, call glDrawBuffersARB, else call
|
||||
|
@@ -484,6 +484,8 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLubyte tmp[4];
|
||||
GLuint i;
|
||||
GLboolean flushed;
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
if (MESA_VERBOSE & VERBOSE_API)
|
||||
@@ -497,17 +499,61 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
|
||||
tmp[BCOMP] = blue ? 0xff : 0x0;
|
||||
tmp[ACOMP] = alpha ? 0xff : 0x0;
|
||||
|
||||
if (TEST_EQ_4UBV(tmp, ctx->Color.ColorMask))
|
||||
return;
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_COLOR);
|
||||
COPY_4UBV(ctx->Color.ColorMask, tmp);
|
||||
flushed = GL_FALSE;
|
||||
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
|
||||
if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask[i])) {
|
||||
if (!flushed) {
|
||||
FLUSH_VERTICES(ctx, _NEW_COLOR);
|
||||
}
|
||||
flushed = GL_TRUE;
|
||||
COPY_4UBV(ctx->Color.ColorMask[i], tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->Driver.ColorMask)
|
||||
ctx->Driver.ColorMask( ctx, red, green, blue, alpha );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For GL_EXT_draw_buffers2 and GL3
|
||||
*/
|
||||
void GLAPIENTRY
|
||||
_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green,
|
||||
GLboolean blue, GLboolean alpha )
|
||||
{
|
||||
GLubyte tmp[4];
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
if (MESA_VERBOSE & VERBOSE_API)
|
||||
_mesa_debug(ctx, "glColorMaskIndexed %u %d %d %d %d\n",
|
||||
buf, red, green, blue, alpha);
|
||||
|
||||
if (buf >= ctx->Const.MaxDrawBuffers) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glColorMaskIndexed(buf=%u)", buf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Shouldn't have any information about channel depth in core mesa
|
||||
* -- should probably store these as the native booleans:
|
||||
*/
|
||||
tmp[RCOMP] = red ? 0xff : 0x0;
|
||||
tmp[GCOMP] = green ? 0xff : 0x0;
|
||||
tmp[BCOMP] = blue ? 0xff : 0x0;
|
||||
tmp[ACOMP] = alpha ? 0xff : 0x0;
|
||||
|
||||
if (TEST_EQ_4V(tmp, ctx->Color.ColorMask[buf]))
|
||||
return;
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_COLOR);
|
||||
COPY_4UBV(ctx->Color.ColorMask[buf], tmp);
|
||||
|
||||
if (ctx->Driver.ColorMaskIndexed)
|
||||
ctx->Driver.ColorMaskIndexed(ctx, buf, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
|
||||
extern void GLAPIENTRY
|
||||
_mesa_ClampColorARB(GLenum target, GLenum clamp)
|
||||
{
|
||||
@@ -555,10 +601,7 @@ void _mesa_init_color( GLcontext * ctx )
|
||||
{
|
||||
/* Color buffer group */
|
||||
ctx->Color.IndexMask = ~0u;
|
||||
ctx->Color.ColorMask[0] = 0xff;
|
||||
ctx->Color.ColorMask[1] = 0xff;
|
||||
ctx->Color.ColorMask[2] = 0xff;
|
||||
ctx->Color.ColorMask[3] = 0xff;
|
||||
memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask));
|
||||
ctx->Color.ClearIndex = 0;
|
||||
ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 );
|
||||
ctx->Color.AlphaEnabled = GL_FALSE;
|
||||
|
@@ -72,6 +72,10 @@ extern void GLAPIENTRY
|
||||
_mesa_ColorMask( GLboolean red, GLboolean green,
|
||||
GLboolean blue, GLboolean alpha );
|
||||
|
||||
extern void GLAPIENTRY
|
||||
_mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green,
|
||||
GLboolean blue, GLboolean alpha );
|
||||
|
||||
|
||||
extern void GLAPIENTRY
|
||||
_mesa_ClampColorARB(GLenum target, GLenum clamp);
|
||||
|
@@ -625,6 +625,8 @@ struct dd_function_table {
|
||||
/** Enable and disable writing of frame buffer color components */
|
||||
void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
|
||||
GLboolean bmask, GLboolean amask );
|
||||
void (*ColorMaskIndexed)(GLcontext *ctx, GLuint buf, GLboolean rmask,
|
||||
GLboolean gmask, GLboolean bmask, GLboolean amask);
|
||||
/** Cause a material color to track the current color */
|
||||
void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode);
|
||||
/** Specify whether front- or back-facing facets can be culled */
|
||||
|
@@ -210,10 +210,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
||||
params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialMode);
|
||||
break;
|
||||
case GL_COLOR_WRITEMASK:
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[RCOMP] ? 1 : 0);
|
||||
params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[GCOMP] ? 1 : 0);
|
||||
params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[BCOMP] ? 1 : 0);
|
||||
params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[ACOMP] ? 1 : 0);
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0);
|
||||
params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0);
|
||||
params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0);
|
||||
params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0);
|
||||
break;
|
||||
case GL_CULL_FACE:
|
||||
params[0] = ctx->Polygon.CullFlag;
|
||||
@@ -2045,10 +2045,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
||||
params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialMode);
|
||||
break;
|
||||
case GL_COLOR_WRITEMASK:
|
||||
params[0] = (GLfloat)(ctx->Color.ColorMask[RCOMP] ? 1 : 0);
|
||||
params[1] = (GLfloat)(ctx->Color.ColorMask[GCOMP] ? 1 : 0);
|
||||
params[2] = (GLfloat)(ctx->Color.ColorMask[BCOMP] ? 1 : 0);
|
||||
params[3] = (GLfloat)(ctx->Color.ColorMask[ACOMP] ? 1 : 0);
|
||||
params[0] = (GLfloat)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0);
|
||||
params[1] = (GLfloat)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0);
|
||||
params[2] = (GLfloat)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0);
|
||||
params[3] = (GLfloat)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0);
|
||||
break;
|
||||
case GL_CULL_FACE:
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.CullFlag);
|
||||
@@ -3880,10 +3880,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
||||
params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialMode);
|
||||
break;
|
||||
case GL_COLOR_WRITEMASK:
|
||||
params[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0;
|
||||
params[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0;
|
||||
params[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0;
|
||||
params[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0;
|
||||
params[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0;
|
||||
params[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0;
|
||||
params[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0;
|
||||
params[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0;
|
||||
break;
|
||||
case GL_CULL_FACE:
|
||||
params[0] = BOOLEAN_TO_INT(ctx->Polygon.CullFlag);
|
||||
@@ -5716,10 +5716,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
|
||||
params[0] = ENUM_TO_INT64(ctx->Light.ColorMaterialMode);
|
||||
break;
|
||||
case GL_COLOR_WRITEMASK:
|
||||
params[0] = (GLint64)(ctx->Color.ColorMask[RCOMP] ? 1 : 0);
|
||||
params[1] = (GLint64)(ctx->Color.ColorMask[GCOMP] ? 1 : 0);
|
||||
params[2] = (GLint64)(ctx->Color.ColorMask[BCOMP] ? 1 : 0);
|
||||
params[3] = (GLint64)(ctx->Color.ColorMask[ACOMP] ? 1 : 0);
|
||||
params[0] = (GLint64)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0);
|
||||
params[1] = (GLint64)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0);
|
||||
params[2] = (GLint64)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0);
|
||||
params[3] = (GLint64)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0);
|
||||
break;
|
||||
case GL_CULL_FACE:
|
||||
params[0] = BOOLEAN_TO_INT64(ctx->Polygon.CullFlag);
|
||||
@@ -7448,11 +7448,20 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
|
||||
|
||||
switch (pname) {
|
||||
case GL_BLEND:
|
||||
if (index >= MAX_DRAW_BUFFERS) {
|
||||
if (index >= ctx->Const.MaxDrawBuffers) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
|
||||
}
|
||||
params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1));
|
||||
break;
|
||||
case GL_COLOR_WRITEMASK:
|
||||
if (index >= ctx->Const.MaxDrawBuffers) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
|
||||
}
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0);
|
||||
params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0);
|
||||
params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
|
||||
params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname);
|
||||
}
|
||||
@@ -7472,11 +7481,20 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
|
||||
|
||||
switch (pname) {
|
||||
case GL_BLEND:
|
||||
if (index >= MAX_DRAW_BUFFERS) {
|
||||
if (index >= ctx->Const.MaxDrawBuffers) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
|
||||
}
|
||||
params[0] = ((ctx->Color.BlendEnabled >> index) & 1);
|
||||
break;
|
||||
case GL_COLOR_WRITEMASK:
|
||||
if (index >= ctx->Const.MaxDrawBuffers) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
|
||||
}
|
||||
params[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0;
|
||||
params[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0;
|
||||
params[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0;
|
||||
params[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname);
|
||||
}
|
||||
@@ -7497,11 +7515,20 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
|
||||
|
||||
switch (pname) {
|
||||
case GL_BLEND:
|
||||
if (index >= MAX_DRAW_BUFFERS) {
|
||||
if (index >= ctx->Const.MaxDrawBuffers) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
|
||||
}
|
||||
params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1));
|
||||
break;
|
||||
case GL_COLOR_WRITEMASK:
|
||||
if (index >= ctx->Const.MaxDrawBuffers) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
|
||||
}
|
||||
params[0] = (GLint64)(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0);
|
||||
params[1] = (GLint64)(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0);
|
||||
params[2] = (GLint64)(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
|
||||
params[3] = (GLint64)(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname);
|
||||
}
|
||||
|
@@ -126,10 +126,10 @@ StateVars = [
|
||||
( "GL_COLOR_MATERIAL_PARAMETER", GLenum,
|
||||
["ctx->Light.ColorMaterialMode"], "", None ),
|
||||
( "GL_COLOR_WRITEMASK", GLint,
|
||||
[ "ctx->Color.ColorMask[RCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[GCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[BCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ),
|
||||
[ "ctx->Color.ColorMask[0][RCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[0][GCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[0][BCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[0][ACOMP] ? 1 : 0" ], "", None ),
|
||||
( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ),
|
||||
( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ),
|
||||
( "GL_CURRENT_COLOR", GLfloatN,
|
||||
@@ -1035,7 +1035,14 @@ StateVars = [
|
||||
|
||||
# These are queried via glGetIntegetIndexdvEXT() or glGetIntegeri_v()
|
||||
IndexedStateVars = [
|
||||
( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"], "MAX_DRAW_BUFFERS", None ),
|
||||
( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"],
|
||||
"ctx->Const.MaxDrawBuffers", None ),
|
||||
( "GL_COLOR_WRITEMASK", GLint,
|
||||
[ "ctx->Color.ColorMask[index][RCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[index][GCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[index][BCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ],
|
||||
"ctx->Const.MaxDrawBuffers", None ),
|
||||
# XXX more to come...
|
||||
]
|
||||
|
||||
|
@@ -564,7 +564,7 @@ struct gl_colorbuffer_attrib
|
||||
GLclampf ClearColor[4]; /**< Color to use for glClear */
|
||||
|
||||
GLuint IndexMask; /**< Color index write mask */
|
||||
GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
|
||||
GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */
|
||||
|
||||
GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
|
||||
|
||||
|
@@ -200,13 +200,13 @@ update_blend( struct st_context *st )
|
||||
}
|
||||
|
||||
/* Colormask - maybe reverse these bits? */
|
||||
if (st->ctx->Color.ColorMask[0])
|
||||
if (st->ctx->Color.ColorMask[0][0])
|
||||
blend->colormask |= PIPE_MASK_R;
|
||||
if (st->ctx->Color.ColorMask[1])
|
||||
if (st->ctx->Color.ColorMask[0][1])
|
||||
blend->colormask |= PIPE_MASK_G;
|
||||
if (st->ctx->Color.ColorMask[2])
|
||||
if (st->ctx->Color.ColorMask[0][2])
|
||||
blend->colormask |= PIPE_MASK_B;
|
||||
if (st->ctx->Color.ColorMask[3])
|
||||
if (st->ctx->Color.ColorMask[0][3])
|
||||
blend->colormask |= PIPE_MASK_A;
|
||||
|
||||
if (st->ctx->Color.DitherFlag)
|
||||
|
@@ -229,7 +229,7 @@ accum_return(GLcontext *ctx, GLfloat value,
|
||||
{
|
||||
struct pipe_context *pipe = ctx->st->pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
const GLubyte *colormask = ctx->Color.ColorMask;
|
||||
const GLubyte *colormask = ctx->Color.ColorMask[0];
|
||||
enum pipe_transfer_usage usage;
|
||||
struct pipe_transfer *color_trans;
|
||||
size_t stride = acc_strb->stride;
|
||||
|
@@ -232,13 +232,13 @@ clear_with_quad(GLcontext *ctx,
|
||||
blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
|
||||
blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
|
||||
if (color) {
|
||||
if (ctx->Color.ColorMask[0])
|
||||
if (ctx->Color.ColorMask[0][0])
|
||||
blend.colormask |= PIPE_MASK_R;
|
||||
if (ctx->Color.ColorMask[1])
|
||||
if (ctx->Color.ColorMask[0][1])
|
||||
blend.colormask |= PIPE_MASK_G;
|
||||
if (ctx->Color.ColorMask[2])
|
||||
if (ctx->Color.ColorMask[0][2])
|
||||
blend.colormask |= PIPE_MASK_B;
|
||||
if (ctx->Color.ColorMask[3])
|
||||
if (ctx->Color.ColorMask[0][3])
|
||||
blend.colormask |= PIPE_MASK_A;
|
||||
if (st->ctx->Color.DitherFlag)
|
||||
blend.dither = 1;
|
||||
@@ -300,10 +300,10 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
|
||||
ctx->Scissor.Height < rb->Height))
|
||||
return TRUE;
|
||||
|
||||
if (!ctx->Color.ColorMask[0] ||
|
||||
!ctx->Color.ColorMask[1] ||
|
||||
!ctx->Color.ColorMask[2] ||
|
||||
!ctx->Color.ColorMask[3])
|
||||
if (!ctx->Color.ColorMask[0][0] ||
|
||||
!ctx->Color.ColorMask[0][1] ||
|
||||
!ctx->Color.ColorMask[0][2] ||
|
||||
!ctx->Color.ColorMask[0][3])
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -40,7 +40,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 +96,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 +146,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 +159,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 +247,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 {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -32,7 +32,7 @@
|
||||
|
||||
extern void
|
||||
_swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
SWspan *span);
|
||||
SWspan *span, GLuint buf);
|
||||
|
||||
|
||||
extern void
|
||||
|
@@ -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;
|
||||
}
|
||||
@@ -1483,8 +1483,8 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
|
||||
_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) {
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user