mesa: begin implementation of GL_ARB_draw_buffers_blend

This commit is contained in:
Brian Paul
2011-01-11 15:07:38 -07:00
parent 3dab2b1795
commit 74713e2d29
31 changed files with 615 additions and 368 deletions

View File

@@ -231,13 +231,14 @@ _mesa_init_driver_state(struct gl_context *ctx)
ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor); ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor);
ctx->Driver.BlendEquationSeparate(ctx, ctx->Driver.BlendEquationSeparate(ctx,
ctx->Color.BlendEquationRGB, ctx->Color.Blend[0].EquationRGB,
ctx->Color.BlendEquationA); ctx->Color.Blend[0].EquationA);
ctx->Driver.BlendFuncSeparate(ctx, ctx->Driver.BlendFuncSeparate(ctx,
ctx->Color.BlendSrcRGB, ctx->Color.Blend[0].SrcRGB,
ctx->Color.BlendDstRGB, ctx->Color.Blend[0].DstRGB,
ctx->Color.BlendSrcA, ctx->Color.BlendDstA); ctx->Color.Blend[0].SrcA,
ctx->Color.Blend[0].DstA);
if (ctx->Driver.ColorMaskIndexed) { if (ctx->Driver.ColorMaskIndexed) {
GLuint i; GLuint i;

View File

@@ -95,7 +95,7 @@ static void i810BlendFuncSeparate( struct gl_context *ctx, GLenum sfactorRGB,
GLuint a = SDM_UPDATE_SRC_BLEND | SDM_UPDATE_DST_BLEND; GLuint a = SDM_UPDATE_SRC_BLEND | SDM_UPDATE_DST_BLEND;
GLboolean fallback = GL_FALSE; GLboolean fallback = GL_FALSE;
switch (ctx->Color.BlendSrcRGB) { switch (ctx->Color.Blend[0].SrcRGB) {
case GL_ZERO: a |= SDM_SRC_ZERO; break; case GL_ZERO: a |= SDM_SRC_ZERO; break;
case GL_ONE: a |= SDM_SRC_ONE; break; case GL_ONE: a |= SDM_SRC_ONE; break;
case GL_SRC_COLOR: a |= SDM_SRC_SRC_COLOR; break; case GL_SRC_COLOR: a |= SDM_SRC_SRC_COLOR; break;
@@ -124,7 +124,7 @@ static void i810BlendFuncSeparate( struct gl_context *ctx, GLenum sfactorRGB,
return; return;
} }
switch (ctx->Color.BlendDstRGB) { switch (ctx->Color.Blend[0].DstRGB) {
case GL_ZERO: a |= SDM_DST_ZERO; break; case GL_ZERO: a |= SDM_DST_ZERO; break;
case GL_ONE: a |= SDM_DST_ONE; break; case GL_ONE: a |= SDM_DST_ONE; break;
case GL_SRC_COLOR: a |= SDM_DST_SRC_COLOR; break; case GL_SRC_COLOR: a |= SDM_DST_SRC_COLOR; break;

View File

@@ -291,10 +291,10 @@ i830_set_blend_state(struct gl_context * ctx)
funcRGB = funcRGB =
SRC_BLND_FACT(intel_translate_blend_factor(ctx->Color.BlendSrcRGB)) SRC_BLND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].SrcRGB))
| DST_BLND_FACT(intel_translate_blend_factor(ctx->Color.BlendDstRGB)); | DST_BLND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].DstRGB));
switch (ctx->Color.BlendEquationRGB) { switch (ctx->Color.Blend[0].EquationRGB) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqnRGB = BLENDFUNC_ADD; eqnRGB = BLENDFUNC_ADD;
break; break;
@@ -314,15 +314,15 @@ i830_set_blend_state(struct gl_context * ctx)
break; break;
default: default:
fprintf(stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n", fprintf(stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationRGB);
return; return;
} }
funcA = SRC_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.BlendSrcA)) funcA = SRC_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].SrcA))
| DST_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.BlendDstA)); | DST_ABLEND_FACT(intel_translate_blend_factor(ctx->Color.Blend[0].DstA));
switch (ctx->Color.BlendEquationA) { switch (ctx->Color.Blend[0].EquationA) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqnA = BLENDFUNC_ADD; eqnA = BLENDFUNC_ADD;
break; break;
@@ -342,7 +342,7 @@ i830_set_blend_state(struct gl_context * ctx)
break; break;
default: default:
fprintf(stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n", fprintf(stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationA); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationA);
return; return;
} }

View File

@@ -267,12 +267,12 @@ i915UpdateBlendState(struct gl_context * ctx)
~(S6_CBUF_SRC_BLEND_FACT_MASK | ~(S6_CBUF_SRC_BLEND_FACT_MASK |
S6_CBUF_DST_BLEND_FACT_MASK | S6_CBUF_BLEND_FUNC_MASK)); S6_CBUF_DST_BLEND_FACT_MASK | S6_CBUF_BLEND_FUNC_MASK));
GLuint eqRGB = ctx->Color.BlendEquationRGB; GLuint eqRGB = ctx->Color.Blend[0].EquationRGB;
GLuint eqA = ctx->Color.BlendEquationA; GLuint eqA = ctx->Color.Blend[0].EquationA;
GLuint srcRGB = ctx->Color.BlendSrcRGB; GLuint srcRGB = ctx->Color.Blend[0].SrcRGB;
GLuint dstRGB = ctx->Color.BlendDstRGB; GLuint dstRGB = ctx->Color.Blend[0].DstRGB;
GLuint srcA = ctx->Color.BlendSrcA; GLuint srcA = ctx->Color.Blend[0].SrcA;
GLuint dstA = ctx->Color.BlendDstA; GLuint dstA = ctx->Color.Blend[0].DstA;
if (eqRGB == GL_MIN || eqRGB == GL_MAX) { if (eqRGB == GL_MIN || eqRGB == GL_MAX) {
srcRGB = dstRGB = GL_ONE; srcRGB = dstRGB = GL_ONE;

View File

@@ -141,12 +141,12 @@ static void upload_cc_unit(struct brw_context *brw)
cc.cc2.logicop_enable = 1; cc.cc2.logicop_enable = 1;
cc.cc5.logicop_func = intel_translate_logic_op(ctx->Color.LogicOp); cc.cc5.logicop_func = intel_translate_logic_op(ctx->Color.LogicOp);
} else if (ctx->Color.BlendEnabled) { } else if (ctx->Color.BlendEnabled) {
GLenum eqRGB = ctx->Color.BlendEquationRGB; GLenum eqRGB = ctx->Color.Blend[0].EquationRGB;
GLenum eqA = ctx->Color.BlendEquationA; GLenum eqA = ctx->Color.Blend[0].EquationA;
GLenum srcRGB = ctx->Color.BlendSrcRGB; GLenum srcRGB = ctx->Color.Blend[0].SrcRGB;
GLenum dstRGB = ctx->Color.BlendDstRGB; GLenum dstRGB = ctx->Color.Blend[0].DstRGB;
GLenum srcA = ctx->Color.BlendSrcA; GLenum srcA = ctx->Color.Blend[0].SrcA;
GLenum dstA = ctx->Color.BlendDstA; GLenum dstA = ctx->Color.Blend[0].DstA;
/* If the renderbuffer is XRGB, we have to frob the blend function to /* If the renderbuffer is XRGB, we have to frob the blend function to
* force the destination alpha to 1.0. This means replacing GL_DST_ALPHA * force the destination alpha to 1.0. This means replacing GL_DST_ALPHA

View File

@@ -66,12 +66,12 @@ blend_state_populate_key(struct brw_context *brw,
/* _NEW_COLOR */ /* _NEW_COLOR */
key->color_blend = ctx->Color.BlendEnabled; key->color_blend = ctx->Color.BlendEnabled;
if (key->color_blend) { if (key->color_blend) {
key->blend_eq_rgb = ctx->Color.BlendEquationRGB; key->blend_eq_rgb = ctx->Color.Blend[0].EquationRGB;
key->blend_eq_a = ctx->Color.BlendEquationA; key->blend_eq_a = ctx->Color.Blend[0].EquationA;
key->blend_src_rgb = ctx->Color.BlendSrcRGB; key->blend_src_rgb = ctx->Color.Blend[0].SrcRGB;
key->blend_dst_rgb = ctx->Color.BlendDstRGB; key->blend_dst_rgb = ctx->Color.Blend[0].DstRGB;
key->blend_src_a = ctx->Color.BlendSrcA; key->blend_src_a = ctx->Color.Blend[0].SrcA;
key->blend_dst_a = ctx->Color.BlendDstA; key->blend_dst_a = ctx->Color.Blend[0].DstA;
} }
/* _NEW_COLOR */ /* _NEW_COLOR */

View File

@@ -66,12 +66,12 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, GLboolean src_alpha_is_on
} }
if (ctx->Color.BlendEnabled && if (ctx->Color.BlendEnabled &&
(effective_func(ctx->Color.BlendSrcRGB, src_alpha_is_one) != GL_ONE || (effective_func(ctx->Color.Blend[0].SrcRGB, src_alpha_is_one) != GL_ONE ||
effective_func(ctx->Color.BlendDstRGB, src_alpha_is_one) != GL_ZERO || effective_func(ctx->Color.Blend[0].DstRGB, src_alpha_is_one) != GL_ZERO ||
ctx->Color.BlendEquationRGB != GL_FUNC_ADD || ctx->Color.Blend[0].EquationRGB != GL_FUNC_ADD ||
effective_func(ctx->Color.BlendSrcA, src_alpha_is_one) != GL_ONE || effective_func(ctx->Color.Blend[0].SrcA, src_alpha_is_one) != GL_ONE ||
effective_func(ctx->Color.BlendDstA, src_alpha_is_one) != GL_ZERO || effective_func(ctx->Color.Blend[0].DstA, src_alpha_is_one) != GL_ZERO ||
ctx->Color.BlendEquationA != GL_FUNC_ADD)) { ctx->Color.Blend[0].EquationA != GL_FUNC_ADD)) {
DBG("fallback due to blend\n"); DBG("fallback due to blend\n");
return GL_FALSE; return GL_FALSE;
} }

View File

@@ -102,7 +102,7 @@ static void mach64UpdateAlphaMode( struct gl_context *ctx )
MACH64_ALPHA_BLEND_DST_MASK | MACH64_ALPHA_BLEND_DST_MASK |
MACH64_ALPHA_BLEND_SAT); MACH64_ALPHA_BLEND_SAT);
switch ( ctx->Color.BlendSrcRGB ) { switch ( ctx->Color.Blend[0].SrcRGB ) {
case GL_ZERO: case GL_ZERO:
s |= MACH64_ALPHA_BLEND_SRC_ZERO; s |= MACH64_ALPHA_BLEND_SRC_ZERO;
break; break;
@@ -135,7 +135,7 @@ static void mach64UpdateAlphaMode( struct gl_context *ctx )
FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_TRUE ); FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_TRUE );
} }
switch ( ctx->Color.BlendDstRGB ) { switch ( ctx->Color.Blend[0].DstRGB ) {
case GL_ZERO: case GL_ZERO:
s |= MACH64_ALPHA_BLEND_DST_ZERO; s |= MACH64_ALPHA_BLEND_DST_ZERO;
break; break;

View File

@@ -141,7 +141,7 @@ static void mgaDDBlendFuncSeparate( struct gl_context *ctx, GLenum sfactorRGB,
GLuint src; GLuint src;
GLuint dst; GLuint dst;
switch (ctx->Color.BlendSrcRGB) { switch (ctx->Color.Blend[0].SrcRGB) {
case GL_ZERO: case GL_ZERO:
src = AC_src_zero; break; src = AC_src_zero; break;
case GL_SRC_ALPHA: case GL_SRC_ALPHA:
@@ -169,7 +169,7 @@ static void mgaDDBlendFuncSeparate( struct gl_context *ctx, GLenum sfactorRGB,
break; break;
} }
switch (ctx->Color.BlendDstRGB) { switch (ctx->Color.Blend[0].DstRGB) {
case GL_SRC_ALPHA: case GL_SRC_ALPHA:
dst = AC_dst_src_alpha; break; dst = AC_dst_src_alpha; break;
case GL_ONE_MINUS_SRC_ALPHA: case GL_ONE_MINUS_SRC_ALPHA:

View File

@@ -264,8 +264,8 @@ nv04_emit_blend(struct gl_context *ctx, int emit)
NV04_MULTITEX_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE; NV04_MULTITEX_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE;
/* Alpha blending. */ /* Alpha blending. */
blend |= get_blend_func(ctx->Color.BlendDstRGB) << 28 | blend |= get_blend_func(ctx->Color.Blend[0].DstRGB) << 28 |
get_blend_func(ctx->Color.BlendSrcRGB) << 24; get_blend_func(ctx->Color.Blend[0].SrcRGB) << 24;
if (ctx->Color.BlendEnabled) if (ctx->Color.BlendEnabled)
blend |= NV04_MULTITEX_TRIANGLE_BLEND_BLEND_ENABLE; blend |= NV04_MULTITEX_TRIANGLE_BLEND_BLEND_ENABLE;
@@ -296,8 +296,8 @@ nv04_emit_blend(struct gl_context *ctx, int emit)
NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE; NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE;
/* Alpha blending. */ /* Alpha blending. */
blend |= get_blend_func(ctx->Color.BlendDstRGB) << 28 | blend |= get_blend_func(ctx->Color.Blend[0].DstRGB) << 28 |
get_blend_func(ctx->Color.BlendSrcRGB) << 24; get_blend_func(ctx->Color.Blend[0].SrcRGB) << 24;
if (ctx->Color.BlendEnabled) if (ctx->Color.BlendEnabled)
blend |= NV04_TEXTURED_TRIANGLE_BLEND_BLEND_ENABLE; blend |= NV04_TEXTURED_TRIANGLE_BLEND_BLEND_ENABLE;

View File

@@ -68,7 +68,7 @@ nv10_emit_blend_equation(struct gl_context *ctx, int emit)
OUT_RINGb(chan, ctx->Color.BlendEnabled); OUT_RINGb(chan, ctx->Color.BlendEnabled);
BEGIN_RING(chan, celsius, NV10_3D_BLEND_EQUATION, 1); BEGIN_RING(chan, celsius, NV10_3D_BLEND_EQUATION, 1);
OUT_RING(chan, nvgl_blend_eqn(ctx->Color.BlendEquationRGB)); OUT_RING(chan, nvgl_blend_eqn(ctx->Color.Blend[0].EquationRGB));
} }
void void
@@ -78,8 +78,8 @@ nv10_emit_blend_func(struct gl_context *ctx, int emit)
struct nouveau_grobj *celsius = context_eng3d(ctx); struct nouveau_grobj *celsius = context_eng3d(ctx);
BEGIN_RING(chan, celsius, NV10_3D_BLEND_FUNC_SRC, 2); BEGIN_RING(chan, celsius, NV10_3D_BLEND_FUNC_SRC, 2);
OUT_RING(chan, nvgl_blend_func(ctx->Color.BlendSrcRGB)); OUT_RING(chan, nvgl_blend_func(ctx->Color.Blend[0].SrcRGB));
OUT_RING(chan, nvgl_blend_func(ctx->Color.BlendDstRGB)); OUT_RING(chan, nvgl_blend_func(ctx->Color.Blend[0].DstRGB));
} }
void void

View File

@@ -178,12 +178,12 @@ static void r128UpdateAlphaMode( struct gl_context *ctx )
(R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_DST_SHIFT) (R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_DST_SHIFT)
| R128_ALPHA_COMB_FCN_MASK); | R128_ALPHA_COMB_FCN_MASK);
a |= blend_factor( rmesa, ctx->Color.BlendSrcRGB, GL_TRUE ) a |= blend_factor( rmesa, ctx->Color.Blend[0].SrcRGB, GL_TRUE )
<< R128_ALPHA_BLEND_SRC_SHIFT; << R128_ALPHA_BLEND_SRC_SHIFT;
a |= blend_factor( rmesa, ctx->Color.BlendDstRGB, GL_FALSE ) a |= blend_factor( rmesa, ctx->Color.Blend[0].DstRGB, GL_FALSE )
<< R128_ALPHA_BLEND_DST_SHIFT; << R128_ALPHA_BLEND_DST_SHIFT;
switch (ctx->Color.BlendEquationRGB) { switch (ctx->Color.Blend[0].EquationRGB) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
a |= R128_ALPHA_COMB_ADD_CLAMP; a |= R128_ALPHA_COMB_ADD_CLAMP;
break; break;

View File

@@ -245,10 +245,10 @@ static void r200_set_blend_state( struct gl_context * ctx )
} }
} }
func = (blend_factor( ctx->Color.BlendSrcRGB, GL_TRUE ) << R200_SRC_BLEND_SHIFT) | func = (blend_factor( ctx->Color.Blend[0].SrcRGB, GL_TRUE ) << R200_SRC_BLEND_SHIFT) |
(blend_factor( ctx->Color.BlendDstRGB, GL_FALSE ) << R200_DST_BLEND_SHIFT); (blend_factor( ctx->Color.Blend[0].DstRGB, GL_FALSE ) << R200_DST_BLEND_SHIFT);
switch(ctx->Color.BlendEquationRGB) { switch(ctx->Color.Blend[0].EquationRGB) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqn = R200_COMB_FCN_ADD_CLAMP; eqn = R200_COMB_FCN_ADD_CLAMP;
break; break;
@@ -275,7 +275,7 @@ static void r200_set_blend_state( struct gl_context * ctx )
default: default:
fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n", fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB ); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationRGB );
return; return;
} }
@@ -284,10 +284,10 @@ static void r200_set_blend_state( struct gl_context * ctx )
return; return;
} }
funcA = (blend_factor( ctx->Color.BlendSrcA, GL_TRUE ) << R200_SRC_BLEND_SHIFT) | funcA = (blend_factor( ctx->Color.Blend[0].SrcA, GL_TRUE ) << R200_SRC_BLEND_SHIFT) |
(blend_factor( ctx->Color.BlendDstA, GL_FALSE ) << R200_DST_BLEND_SHIFT); (blend_factor( ctx->Color.Blend[0].DstA, GL_FALSE ) << R200_DST_BLEND_SHIFT);
switch(ctx->Color.BlendEquationA) { switch(ctx->Color.Blend[0].EquationA) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqnA = R200_COMB_FCN_ADD_CLAMP; eqnA = R200_COMB_FCN_ADD_CLAMP;
break; break;
@@ -314,7 +314,7 @@ static void r200_set_blend_state( struct gl_context * ctx )
default: default:
fprintf( stderr, "[%s:%u] Invalid A blend equation (0x%04x).\n", fprintf( stderr, "[%s:%u] Invalid A blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationA ); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationA );
return; return;
} }

View File

@@ -220,12 +220,12 @@ static void r300SetBlendState(struct gl_context * ctx)
} }
func = func =
(blend_factor(ctx->Color.BlendSrcRGB, GL_TRUE) << (blend_factor(ctx->Color.Blend[0].SrcRGB, GL_TRUE) <<
R300_SRC_BLEND_SHIFT) | (blend_factor(ctx->Color.BlendDstRGB, R300_SRC_BLEND_SHIFT) | (blend_factor(ctx->Color.Blend[0].DstRGB,
GL_FALSE) << GL_FALSE) <<
R300_DST_BLEND_SHIFT); R300_DST_BLEND_SHIFT);
switch (ctx->Color.BlendEquationRGB) { switch (ctx->Color.Blend[0].EquationRGB) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqn = R300_COMB_FCN_ADD_CLAMP; eqn = R300_COMB_FCN_ADD_CLAMP;
break; break;
@@ -253,17 +253,17 @@ static void r300SetBlendState(struct gl_context * ctx)
default: default:
fprintf(stderr, fprintf(stderr,
"[%s:%u] Invalid RGB blend equation (0x%04x).\n", "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationRGB);
return; return;
} }
funcA = funcA =
(blend_factor(ctx->Color.BlendSrcA, GL_TRUE) << (blend_factor(ctx->Color.Blend[0].SrcA, GL_TRUE) <<
R300_SRC_BLEND_SHIFT) | (blend_factor(ctx->Color.BlendDstA, R300_SRC_BLEND_SHIFT) | (blend_factor(ctx->Color.Blend[0].DstA,
GL_FALSE) << GL_FALSE) <<
R300_DST_BLEND_SHIFT); R300_DST_BLEND_SHIFT);
switch (ctx->Color.BlendEquationA) { switch (ctx->Color.Blend[0].EquationA) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqnA = R300_COMB_FCN_ADD_CLAMP; eqnA = R300_COMB_FCN_ADD_CLAMP;
break; break;
@@ -291,7 +291,7 @@ static void r300SetBlendState(struct gl_context * ctx)
default: default:
fprintf(stderr, fprintf(stderr,
"[%s:%u] Invalid A blend equation (0x%04x).\n", "[%s:%u] Invalid A blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationA); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationA);
return; return;
} }

View File

@@ -363,13 +363,13 @@ static void evergreenSetBlendState(struct gl_context * ctx) //diff : CB_COLOR_CO
} }
SETfield(blend_reg, SETfield(blend_reg,
evergreenblend_factor(ctx->Color.BlendSrcRGB, GL_TRUE), evergreenblend_factor(ctx->Color.Blend[0].SrcRGB, GL_TRUE),
COLOR_SRCBLEND_shift, COLOR_SRCBLEND_mask); COLOR_SRCBLEND_shift, COLOR_SRCBLEND_mask);
SETfield(blend_reg, SETfield(blend_reg,
evergreenblend_factor(ctx->Color.BlendDstRGB, GL_FALSE), evergreenblend_factor(ctx->Color.Blend[0].DstRGB, GL_FALSE),
COLOR_DESTBLEND_shift, COLOR_DESTBLEND_mask); COLOR_DESTBLEND_shift, COLOR_DESTBLEND_mask);
switch (ctx->Color.BlendEquationRGB) { switch (ctx->Color.Blend[0].EquationRGB) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqn = COMB_DST_PLUS_SRC; eqn = COMB_DST_PLUS_SRC;
break; break;
@@ -401,20 +401,20 @@ static void evergreenSetBlendState(struct gl_context * ctx) //diff : CB_COLOR_CO
default: default:
fprintf(stderr, fprintf(stderr,
"[%s:%u] Invalid RGB blend equation (0x%04x).\n", "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationRGB);
return; return;
} }
SETfield(blend_reg, SETfield(blend_reg,
eqn, COLOR_COMB_FCN_shift, COLOR_COMB_FCN_mask); eqn, COLOR_COMB_FCN_shift, COLOR_COMB_FCN_mask);
SETfield(blend_reg, SETfield(blend_reg,
evergreenblend_factor(ctx->Color.BlendSrcA, GL_TRUE), evergreenblend_factor(ctx->Color.Blend[0].SrcA, GL_TRUE),
ALPHA_SRCBLEND_shift, ALPHA_SRCBLEND_mask); ALPHA_SRCBLEND_shift, ALPHA_SRCBLEND_mask);
SETfield(blend_reg, SETfield(blend_reg,
evergreenblend_factor(ctx->Color.BlendDstA, GL_FALSE), evergreenblend_factor(ctx->Color.Blend[0].DstA, GL_FALSE),
ALPHA_DESTBLEND_shift, ALPHA_DESTBLEND_mask); ALPHA_DESTBLEND_shift, ALPHA_DESTBLEND_mask);
switch (ctx->Color.BlendEquationA) { switch (ctx->Color.Blend[0].EquationA) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqnA = COMB_DST_PLUS_SRC; eqnA = COMB_DST_PLUS_SRC;
break; break;
@@ -445,7 +445,7 @@ static void evergreenSetBlendState(struct gl_context * ctx) //diff : CB_COLOR_CO
default: default:
fprintf(stderr, fprintf(stderr,
"[%s:%u] Invalid A blend equation (0x%04x).\n", "[%s:%u] Invalid A blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationA); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationA);
return; return;
} }

View File

@@ -474,13 +474,13 @@ static void r700SetBlendState(struct gl_context * ctx)
} }
SETfield(blend_reg, SETfield(blend_reg,
blend_factor(ctx->Color.BlendSrcRGB, GL_TRUE), blend_factor(ctx->Color.Blend[0].SrcRGB, GL_TRUE),
COLOR_SRCBLEND_shift, COLOR_SRCBLEND_mask); COLOR_SRCBLEND_shift, COLOR_SRCBLEND_mask);
SETfield(blend_reg, SETfield(blend_reg,
blend_factor(ctx->Color.BlendDstRGB, GL_FALSE), blend_factor(ctx->Color.Blend[0].DstRGB, GL_FALSE),
COLOR_DESTBLEND_shift, COLOR_DESTBLEND_mask); COLOR_DESTBLEND_shift, COLOR_DESTBLEND_mask);
switch (ctx->Color.BlendEquationRGB) { switch (ctx->Color.Blend[0].EquationRGB) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqn = COMB_DST_PLUS_SRC; eqn = COMB_DST_PLUS_SRC;
break; break;
@@ -512,20 +512,20 @@ static void r700SetBlendState(struct gl_context * ctx)
default: default:
fprintf(stderr, fprintf(stderr,
"[%s:%u] Invalid RGB blend equation (0x%04x).\n", "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationRGB);
return; return;
} }
SETfield(blend_reg, SETfield(blend_reg,
eqn, COLOR_COMB_FCN_shift, COLOR_COMB_FCN_mask); eqn, COLOR_COMB_FCN_shift, COLOR_COMB_FCN_mask);
SETfield(blend_reg, SETfield(blend_reg,
blend_factor(ctx->Color.BlendSrcA, GL_TRUE), blend_factor(ctx->Color.Blend[0].SrcA, GL_TRUE),
ALPHA_SRCBLEND_shift, ALPHA_SRCBLEND_mask); ALPHA_SRCBLEND_shift, ALPHA_SRCBLEND_mask);
SETfield(blend_reg, SETfield(blend_reg,
blend_factor(ctx->Color.BlendDstA, GL_FALSE), blend_factor(ctx->Color.Blend[0].DstA, GL_FALSE),
ALPHA_DESTBLEND_shift, ALPHA_DESTBLEND_mask); ALPHA_DESTBLEND_shift, ALPHA_DESTBLEND_mask);
switch (ctx->Color.BlendEquationA) { switch (ctx->Color.Blend[0].EquationA) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
eqnA = COMB_DST_PLUS_SRC; eqnA = COMB_DST_PLUS_SRC;
break; break;
@@ -556,7 +556,7 @@ static void r700SetBlendState(struct gl_context * ctx)
default: default:
fprintf(stderr, fprintf(stderr,
"[%s:%u] Invalid A blend equation (0x%04x).\n", "[%s:%u] Invalid A blend equation (0x%04x).\n",
__FUNCTION__, __LINE__, ctx->Color.BlendEquationA); __FUNCTION__, __LINE__, ctx->Color.Blend[0].EquationA);
return; return;
} }

View File

@@ -136,7 +136,7 @@ static void radeonBlendEquationSeparate( struct gl_context *ctx,
RADEON_STATECHANGE( rmesa, ctx ); RADEON_STATECHANGE( rmesa, ctx );
rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = b; rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = b;
if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled
&& ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) ) { && ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) ) {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
} else { } else {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
@@ -153,7 +153,7 @@ static void radeonBlendFuncSeparate( struct gl_context *ctx,
~(RADEON_SRC_BLEND_MASK | RADEON_DST_BLEND_MASK); ~(RADEON_SRC_BLEND_MASK | RADEON_DST_BLEND_MASK);
GLboolean fallback = GL_FALSE; GLboolean fallback = GL_FALSE;
switch ( ctx->Color.BlendSrcRGB ) { switch ( ctx->Color.Blend[0].SrcRGB ) {
case GL_ZERO: case GL_ZERO:
b |= RADEON_SRC_BLEND_GL_ZERO; b |= RADEON_SRC_BLEND_GL_ZERO;
break; break;
@@ -200,7 +200,7 @@ static void radeonBlendFuncSeparate( struct gl_context *ctx,
break; break;
} }
switch ( ctx->Color.BlendDstRGB ) { switch ( ctx->Color.Blend[0].DstRGB ) {
case GL_ZERO: case GL_ZERO:
b |= RADEON_DST_BLEND_GL_ZERO; b |= RADEON_DST_BLEND_GL_ZERO;
break; break;
@@ -1602,7 +1602,7 @@ static void radeonEnable( struct gl_context *ctx, GLenum cap, GLboolean state )
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ALPHA_BLEND_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ALPHA_BLEND_ENABLE;
} }
if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled
&& ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) ) { && ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) ) {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
} else { } else {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
@@ -1612,12 +1612,12 @@ static void radeonEnable( struct gl_context *ctx, GLenum cap, GLboolean state )
*/ */
if (state) { if (state) {
ctx->Driver.BlendEquationSeparate( ctx, ctx->Driver.BlendEquationSeparate( ctx,
ctx->Color.BlendEquationRGB, ctx->Color.Blend[0].EquationRGB,
ctx->Color.BlendEquationA ); ctx->Color.Blend[0].EquationA );
ctx->Driver.BlendFuncSeparate( ctx, ctx->Color.BlendSrcRGB, ctx->Driver.BlendFuncSeparate( ctx, ctx->Color.Blend[0].SrcRGB,
ctx->Color.BlendDstRGB, ctx->Color.Blend[0].DstRGB,
ctx->Color.BlendSrcA, ctx->Color.Blend[0].SrcA,
ctx->Color.BlendDstA ); ctx->Color.Blend[0].DstA );
} }
else { else {
FALLBACK( rmesa, RADEON_FALLBACK_BLEND_FUNC, GL_FALSE ); FALLBACK( rmesa, RADEON_FALLBACK_BLEND_FUNC, GL_FALSE );
@@ -1741,7 +1741,7 @@ static void radeonEnable( struct gl_context *ctx, GLenum cap, GLboolean state )
case GL_COLOR_LOGIC_OP: case GL_COLOR_LOGIC_OP:
RADEON_STATECHANGE( rmesa, ctx ); RADEON_STATECHANGE( rmesa, ctx );
if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled if ( (ctx->Color.ColorLogicOpEnabled || (ctx->Color.BlendEnabled
&& ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) ) { && ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) ) {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
} else { } else {
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE; rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;

View File

@@ -136,7 +136,7 @@ static void savageBlendFunc_s4(struct gl_context *ctx)
* blend modes * blend modes
*/ */
if(ctx->Color.BlendEnabled){ if(ctx->Color.BlendEnabled){
switch (ctx->Color.BlendDstRGB) switch (ctx->Color.Blend[0].DstRGB)
{ {
case GL_ZERO: case GL_ZERO:
imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero; imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero;
@@ -192,7 +192,7 @@ static void savageBlendFunc_s4(struct gl_context *ctx)
break; break;
} }
switch (ctx->Color.BlendSrcRGB) switch (ctx->Color.Blend[0].SrcRGB)
{ {
case GL_ZERO: case GL_ZERO:
imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_Zero; imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_Zero;
@@ -310,7 +310,7 @@ static void savageBlendFunc_s3d(struct gl_context *ctx)
* blend modes * blend modes
*/ */
if(ctx->Color.BlendEnabled){ if(ctx->Color.BlendEnabled){
switch (ctx->Color.BlendDstRGB) switch (ctx->Color.Blend[0].DstRGB)
{ {
case GL_ZERO: case GL_ZERO:
imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero; imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero;
@@ -366,7 +366,7 @@ static void savageBlendFunc_s3d(struct gl_context *ctx)
break; break;
} }
switch (ctx->Color.BlendSrcRGB) switch (ctx->Color.Blend[0].SrcRGB)
{ {
case GL_ZERO: case GL_ZERO:
imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_Zero; imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_Zero;

View File

@@ -84,7 +84,7 @@ static void tdfxUpdateAlphaMode( struct gl_context *ctx )
if ( ctx->Color.BlendEnabled if ( ctx->Color.BlendEnabled
&& (fxMesa->Fallback & TDFX_FALLBACK_BLEND) == 0 ) { && (fxMesa->Fallback & TDFX_FALLBACK_BLEND) == 0 ) {
switch ( ctx->Color.BlendSrcRGB ) { switch ( ctx->Color.Blend[0].SrcRGB ) {
case GL_ZERO: case GL_ZERO:
srcRGB = GR_BLEND_ZERO; srcRGB = GR_BLEND_ZERO;
break; break;
@@ -126,7 +126,7 @@ static void tdfxUpdateAlphaMode( struct gl_context *ctx )
srcRGB = GR_BLEND_ONE; srcRGB = GR_BLEND_ONE;
} }
switch ( ctx->Color.BlendSrcA ) { switch ( ctx->Color.Blend[0].SrcA ) {
case GL_ZERO: case GL_ZERO:
srcA = GR_BLEND_ZERO; srcA = GR_BLEND_ZERO;
break; break;
@@ -156,7 +156,7 @@ static void tdfxUpdateAlphaMode( struct gl_context *ctx )
srcA = GR_BLEND_ONE; srcA = GR_BLEND_ONE;
} }
switch ( ctx->Color.BlendDstRGB ) { switch ( ctx->Color.Blend[0].DstRGB ) {
case GL_ZERO: case GL_ZERO:
dstRGB = GR_BLEND_ZERO; dstRGB = GR_BLEND_ZERO;
break; break;
@@ -195,7 +195,7 @@ static void tdfxUpdateAlphaMode( struct gl_context *ctx )
dstRGB = GR_BLEND_ZERO; dstRGB = GR_BLEND_ZERO;
} }
switch ( ctx->Color.BlendDstA ) { switch ( ctx->Color.Blend[0].DstA ) {
case GL_ZERO: case GL_ZERO:
dstA = GR_BLEND_ZERO; dstA = GR_BLEND_ZERO;
break; break;
@@ -222,7 +222,7 @@ static void tdfxUpdateAlphaMode( struct gl_context *ctx )
dstA = GR_BLEND_ZERO; dstA = GR_BLEND_ZERO;
} }
switch ( ctx->Color.BlendEquationRGB ) { switch ( ctx->Color.Blend[0].EquationRGB ) {
case GL_FUNC_SUBTRACT: case GL_FUNC_SUBTRACT:
eqRGB = GR_BLEND_OP_SUB; eqRGB = GR_BLEND_OP_SUB;
break; break;
@@ -235,7 +235,7 @@ static void tdfxUpdateAlphaMode( struct gl_context *ctx )
break; break;
} }
switch ( ctx->Color.BlendEquationA ) { switch ( ctx->Color.Blend[0].EquationA ) {
case GL_FUNC_SUBTRACT: case GL_FUNC_SUBTRACT:
eqA = GR_BLEND_OP_SUB; eqA = GR_BLEND_OP_SUB;
break; break;

View File

@@ -552,7 +552,7 @@ static void viaBlendFunc(struct gl_context *ctx, GLenum sfactor, GLenum dfactor)
if (VIA_DEBUG & DEBUG_STATE) if (VIA_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s in\n", __FUNCTION__); fprintf(stderr, "%s in\n", __FUNCTION__);
switch (ctx->Color.BlendSrcRGB) { switch (ctx->Color.Blend[0].SrcRGB) {
case GL_SRC_ALPHA_SATURATE: case GL_SRC_ALPHA_SATURATE:
case GL_CONSTANT_COLOR: case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR: case GL_ONE_MINUS_CONSTANT_COLOR:
@@ -564,7 +564,7 @@ static void viaBlendFunc(struct gl_context *ctx, GLenum sfactor, GLenum dfactor)
break; break;
} }
switch (ctx->Color.BlendDstRGB) { switch (ctx->Color.Blend[0].DstRGB) {
case GL_CONSTANT_COLOR: case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR: case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA: case GL_CONSTANT_ALPHA:
@@ -757,14 +757,14 @@ void viaInitState(struct gl_context *ctx)
*/ */
ctx->Driver.BlendEquationSeparate( ctx, ctx->Driver.BlendEquationSeparate( ctx,
ctx->Color.BlendEquationRGB, ctx->Color.Blend[0].EquationRGB,
ctx->Color.BlendEquationA); ctx->Color.Blend[0].EquationA);
ctx->Driver.BlendFuncSeparate( ctx, ctx->Driver.BlendFuncSeparate( ctx,
ctx->Color.BlendSrcRGB, ctx->Color.Blend[0].SrcRGB,
ctx->Color.BlendDstRGB, ctx->Color.Blend[0].DstRGB,
ctx->Color.BlendSrcA, ctx->Color.Blend[0].SrcA,
ctx->Color.BlendDstA); ctx->Color.Blend[0].DstA);
ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y, ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
ctx->Scissor.Width, ctx->Scissor.Height ); ctx->Scissor.Width, ctx->Scissor.Height );
@@ -953,8 +953,8 @@ static GLboolean viaChooseTextureState(struct gl_context *ctx)
static void viaChooseColorState(struct gl_context *ctx) static void viaChooseColorState(struct gl_context *ctx)
{ {
struct via_context *vmesa = VIA_CONTEXT(ctx); struct via_context *vmesa = VIA_CONTEXT(ctx);
GLenum s = ctx->Color.BlendSrcRGB; GLenum s = ctx->Color.Blend[0].SrcRGB;
GLenum d = ctx->Color.BlendDstRGB; GLenum d = ctx->Color.Blend[0].DstRGB;
/* The HW's blending equation is: /* The HW's blending equation is:
* (Ca * FCa + Cbias + Cb * FCb) << Cshift * (Ca * FCa + Cbias + Cb * FCb) << Cshift

View File

@@ -954,19 +954,38 @@ _mesa_PopAttrib(void)
_mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1)); _mesa_set_enable(ctx, GL_BLEND, (color->BlendEnabled & 1));
} }
} }
_mesa_BlendFuncSeparateEXT(color->BlendSrcRGB, if (ctx->Color._BlendFuncPerBuffer ||
color->BlendDstRGB, ctx->Color._BlendEquationPerBuffer) {
color->BlendSrcA, /* set blend per buffer */
color->BlendDstA); GLuint buf;
for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
_mesa_BlendFuncSeparatei(buf, color->Blend[buf].SrcRGB,
color->Blend[buf].DstRGB,
color->Blend[buf].SrcA,
color->Blend[buf].DstA);
_mesa_BlendEquationSeparatei(buf,
color->Blend[buf].EquationRGB,
color->Blend[buf].EquationA);
}
}
else {
/* set same blend modes for all buffers */
_mesa_BlendFuncSeparateEXT(color->Blend[0].SrcRGB,
color->Blend[0].DstRGB,
color->Blend[0].SrcA,
color->Blend[0].DstA);
/* This special case is because glBlendEquationSeparateEXT /* This special case is because glBlendEquationSeparateEXT
* cannot take GL_LOGIC_OP as a parameter. * cannot take GL_LOGIC_OP as a parameter.
*/ */
if ( color->BlendEquationRGB == color->BlendEquationA ) { if (color->Blend[0].EquationRGB ==
_mesa_BlendEquation(color->BlendEquationRGB); color->Blend[0].EquationA) {
_mesa_BlendEquation(color->Blend[0].EquationRGB);
} }
else { else {
_mesa_BlendEquationSeparateEXT(color->BlendEquationRGB, _mesa_BlendEquationSeparateEXT(
color->BlendEquationA); color->Blend[0].EquationRGB,
color->Blend[0].EquationA);
}
} }
_mesa_BlendColor(color->BlendColor[0], _mesa_BlendColor(color->BlendColor[0],
color->BlendColor[1], color->BlendColor[1],

View File

@@ -37,6 +37,110 @@
#include "mtypes.h" #include "mtypes.h"
/**
* Check if given blend source factor is legal.
* \return GL_TRUE if legal, GL_FALSE otherwise.
*/
static GLboolean
legal_src_factor(const struct gl_context *ctx, GLenum factor)
{
switch (factor) {
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
return ctx->Extensions.NV_blend_square;
case GL_ZERO:
case GL_ONE:
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_SRC_ALPHA_SATURATE:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
return GL_TRUE;
default:
return GL_FALSE;
}
}
/**
* Check if given blend destination factor is legal.
* \return GL_TRUE if legal, GL_FALSE otherwise.
*/
static GLboolean
legal_dst_factor(const struct gl_context *ctx, GLenum factor)
{
switch (factor) {
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
return ctx->Extensions.NV_blend_square;
case GL_ZERO:
case GL_ONE:
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
return GL_TRUE;
default:
return GL_FALSE;
}
}
/**
* Check if src/dest RGB/A blend factors are legal. If not generate
* a GL error.
* \return GL_TRUE if factors are legal, GL_FALSE otherwise.
*/
static GLboolean
validate_blend_factors(struct gl_context *ctx, const char *func,
GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA)
{
if (!legal_src_factor(ctx, sfactorRGB)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(sfactorRGB = %s)", func,
_mesa_lookup_enum_by_nr(sfactorRGB));
return GL_FALSE;
}
if (!legal_dst_factor(ctx, dfactorRGB)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(dfactorRGB = %s)", func,
_mesa_lookup_enum_by_nr(dfactorRGB));
return GL_FALSE;
}
if (sfactorA != sfactorRGB && !legal_src_factor(ctx, sfactorA)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(sfactorA = %s)", func,
_mesa_lookup_enum_by_nr(sfactorA));
return GL_FALSE;
}
if (dfactorA != dfactorRGB && !legal_dst_factor(ctx, dfactorA)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"%s(dfactorA = %s)", func,
_mesa_lookup_enum_by_nr(dfactorA));
return GL_FALSE;
}
return GL_TRUE;
}
/** /**
* Specify the blending operation. * Specify the blending operation.
* *
@@ -53,21 +157,19 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
/** /**
* Process GL_EXT_blend_func_separate(). * Set the separate blend source/dest factors for all draw buffers.
* *
* \param sfactorRGB RGB source factor operator. * \param sfactorRGB RGB source factor operator.
* \param dfactorRGB RGB destination factor operator. * \param dfactorRGB RGB destination factor operator.
* \param sfactorA alpha source factor operator. * \param sfactorA alpha source factor operator.
* \param dfactorA alpha destination factor operator. * \param dfactorA alpha destination factor operator.
*
* Verifies the parameters and updates gl_colorbuffer_attrib.
* On a change, flush the vertices and notify the driver via
* dd_function_table::BlendFuncSeparate.
*/ */
void GLAPIENTRY void GLAPIENTRY
_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA ) GLenum sfactorA, GLenum dfactorA )
{ {
GLuint buf, numBuffers;
GLboolean changed;
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -78,127 +180,40 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
_mesa_lookup_enum_by_nr(sfactorA), _mesa_lookup_enum_by_nr(sfactorA),
_mesa_lookup_enum_by_nr(dfactorA)); _mesa_lookup_enum_by_nr(dfactorA));
switch (sfactorRGB) { if (!validate_blend_factors(ctx, "glBlendFuncSeparate",
case GL_SRC_COLOR: sfactorRGB, dfactorRGB,
case GL_ONE_MINUS_SRC_COLOR: sfactorA, dfactorA)) {
if (!ctx->Extensions.NV_blend_square) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)");
return;
}
/* fall-through */
case GL_ZERO:
case GL_ONE:
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_SRC_ALPHA_SATURATE:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)");
return; return;
} }
switch (dfactorRGB) { numBuffers = ctx->Extensions.ARB_draw_buffers_blend
case GL_DST_COLOR: ? ctx->Const.MaxDrawBuffers : 1;
case GL_ONE_MINUS_DST_COLOR:
if (!ctx->Extensions.NV_blend_square) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)");
return;
}
/* fall-through */
case GL_ZERO:
case GL_ONE:
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)");
return;
}
switch (sfactorA) { changed = GL_FALSE;
case GL_SRC_COLOR: for (buf = 0; buf < numBuffers; buf++) {
case GL_ONE_MINUS_SRC_COLOR: if (ctx->Color.Blend[buf].SrcRGB != sfactorRGB ||
if (!ctx->Extensions.NV_blend_square) { ctx->Color.Blend[buf].DstRGB != dfactorRGB ||
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)"); ctx->Color.Blend[buf].SrcA != sfactorA ||
return; ctx->Color.Blend[buf].DstA != dfactorA) {
} changed = GL_TRUE;
/* fall-through */
case GL_ZERO:
case GL_ONE:
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_SRC_ALPHA_SATURATE:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
break; break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)");
return;
} }
switch (dfactorA) {
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
if (!ctx->Extensions.NV_blend_square) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)");
return;
} }
/* fall-through */ if (!changed)
case GL_ZERO:
case GL_ONE:
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
case GL_CONSTANT_COLOR:
case GL_ONE_MINUS_CONSTANT_COLOR:
case GL_CONSTANT_ALPHA:
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)" );
return;
}
if (ctx->Color.BlendSrcRGB == sfactorRGB &&
ctx->Color.BlendDstRGB == dfactorRGB &&
ctx->Color.BlendSrcA == sfactorA &&
ctx->Color.BlendDstA == dfactorA)
return; return;
FLUSH_VERTICES(ctx, _NEW_COLOR); FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.BlendSrcRGB = sfactorRGB; for (buf = 0; buf < numBuffers; buf++) {
ctx->Color.BlendDstRGB = dfactorRGB; ctx->Color.Blend[buf].SrcRGB = sfactorRGB;
ctx->Color.BlendSrcA = sfactorA; ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.BlendDstA = dfactorA; ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
}
ctx->Color._BlendFuncPerBuffer = GL_FALSE;
if (ctx->Driver.BlendFuncSeparate) { if (ctx->Driver.BlendFuncSeparate) {
(*ctx->Driver.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB, ctx->Driver.BlendFuncSeparate(ctx, sfactorRGB, dfactorRGB,
sfactorA, dfactorA); sfactorA, dfactorA);
} }
} }
@@ -206,37 +221,89 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
#if _HAVE_FULL_GL #if _HAVE_FULL_GL
/**
* Set blend source/dest factors for one color buffer/target.
*/
void GLAPIENTRY
_mesa_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
{
_mesa_BlendFuncSeparatei(buf, sfactor, dfactor, sfactor, dfactor);
}
/**
* Set separate blend source/dest factors for one color buffer/target.
*/
void GLAPIENTRY
_mesa_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (!ctx->Extensions.ARB_draw_buffers_blend) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glBlendFunc[Separate]i()");
return;
}
if (buf >= ctx->Const.MaxDrawBuffers) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBlendFuncSeparatei(buffer=%u)",
buf);
return;
}
if (!validate_blend_factors(ctx, "glBlendFuncSeparatei",
sfactorRGB, dfactorRGB,
sfactorA, dfactorA)) {
return;
}
if (ctx->Color.Blend[buf].SrcRGB == sfactorRGB &&
ctx->Color.Blend[buf].DstRGB == dfactorRGB &&
ctx->Color.Blend[buf].SrcA == sfactorA &&
ctx->Color.Blend[buf].DstA == dfactorA)
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.Blend[buf].SrcRGB = sfactorRGB;
ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
ctx->Color._BlendFuncPerBuffer = GL_TRUE;
if (ctx->Driver.BlendFuncSeparatei) {
ctx->Driver.BlendFuncSeparatei(ctx, buf, sfactorRGB, dfactorRGB,
sfactorA, dfactorA);
}
}
/**
* Check if given blend equation is legal.
* \return GL_TRUE if legal, GL_FALSE otherwise.
*/
static GLboolean static GLboolean
_mesa_validate_blend_equation( struct gl_context *ctx, legal_blend_equation(const struct gl_context *ctx,
GLenum mode, GLboolean is_separate) GLenum mode, GLboolean is_separate)
{ {
switch (mode) { switch (mode) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
break; return GL_TRUE;
case GL_MIN: case GL_MIN:
case GL_MAX: case GL_MAX:
if (!ctx->Extensions.EXT_blend_minmax) { return ctx->Extensions.EXT_blend_minmax;
return GL_FALSE; case GL_LOGIC_OP:
}
break;
/* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter. /* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter.
*/ */
case GL_LOGIC_OP: return ctx->Extensions.EXT_blend_logic_op && !is_separate;
if (!ctx->Extensions.EXT_blend_logic_op || is_separate) {
return GL_FALSE;
}
break;
case GL_FUNC_SUBTRACT: case GL_FUNC_SUBTRACT:
case GL_FUNC_REVERSE_SUBTRACT: case GL_FUNC_REVERSE_SUBTRACT:
if (!ctx->Extensions.EXT_blend_subtract) { return ctx->Extensions.EXT_blend_subtract;
return GL_FALSE;
}
break;
default: default:
return GL_FALSE; return GL_FALSE;
} }
return GL_TRUE;
} }
@@ -244,6 +311,8 @@ _mesa_validate_blend_equation( struct gl_context *ctx,
void GLAPIENTRY void GLAPIENTRY
_mesa_BlendEquation( GLenum mode ) _mesa_BlendEquation( GLenum mode )
{ {
GLuint buf, numBuffers;
GLboolean changed;
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -251,27 +320,80 @@ _mesa_BlendEquation( GLenum mode )
_mesa_debug(ctx, "glBlendEquation %s\n", _mesa_debug(ctx, "glBlendEquation %s\n",
_mesa_lookup_enum_by_nr(mode)); _mesa_lookup_enum_by_nr(mode));
if ( ! _mesa_validate_blend_equation( ctx, mode, GL_FALSE ) ) { if (!legal_blend_equation(ctx, mode, GL_FALSE)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation"); _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
return; return;
} }
if ( (ctx->Color.BlendEquationRGB == mode) && numBuffers = ctx->Extensions.ARB_draw_buffers_blend
(ctx->Color.BlendEquationA == mode) ) ? ctx->Const.MaxDrawBuffers : 1;
changed = GL_FALSE;
for (buf = 0; buf < numBuffers; buf++) {
if (ctx->Color.Blend[buf].EquationRGB != mode ||
ctx->Color.Blend[buf].EquationA != mode) {
changed = GL_TRUE;
break;
}
}
if (!changed)
return; return;
FLUSH_VERTICES(ctx, _NEW_COLOR); FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.BlendEquationRGB = mode; for (buf = 0; buf < numBuffers; buf++) {
ctx->Color.BlendEquationA = mode; ctx->Color.Blend[buf].EquationRGB = mode;
ctx->Color.Blend[buf].EquationA = mode;
}
ctx->Color._BlendEquationPerBuffer = GL_FALSE;
if (ctx->Driver.BlendEquationSeparate) if (ctx->Driver.BlendEquationSeparate)
(*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode ); (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode );
} }
/**
* Set blend equation for one color buffer/target.
*/
void GLAPIENTRY
_mesa_BlendEquationi(GLuint buf, GLenum mode)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glBlendEquationi(%u, %s)\n",
buf, _mesa_lookup_enum_by_nr(mode));
if (buf >= ctx->Const.MaxDrawBuffers) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBlendFuncSeparatei(buffer=%u)",
buf);
return;
}
if (!legal_blend_equation(ctx, mode, GL_FALSE)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationi");
return;
}
if (ctx->Color.Blend[buf].EquationRGB == mode &&
ctx->Color.Blend[buf].EquationA == mode)
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.Blend[buf].EquationRGB = mode;
ctx->Color.Blend[buf].EquationA = mode;
ctx->Color._BlendEquationPerBuffer = GL_TRUE;
if (ctx->Driver.BlendEquationSeparatei)
ctx->Driver.BlendEquationSeparatei(ctx, buf, mode, mode);
}
void GLAPIENTRY void GLAPIENTRY
_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ) _mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA )
{ {
GLuint buf, numBuffers;
GLboolean changed;
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -286,29 +408,88 @@ _mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA )
return; return;
} }
if ( ! _mesa_validate_blend_equation( ctx, modeRGB, GL_TRUE ) ) { if (!legal_blend_equation(ctx, modeRGB, GL_TRUE)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)"); _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)");
return; return;
} }
if ( ! _mesa_validate_blend_equation( ctx, modeA, GL_TRUE ) ) { if (!legal_blend_equation(ctx, modeA, GL_TRUE)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)"); _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)");
return; return;
} }
numBuffers = ctx->Extensions.ARB_draw_buffers_blend
? ctx->Const.MaxDrawBuffers : 1;
if ( (ctx->Color.BlendEquationRGB == modeRGB) && changed = GL_FALSE;
(ctx->Color.BlendEquationA == modeA) ) for (buf = 0; buf < numBuffers; buf++) {
if (ctx->Color.Blend[buf].EquationRGB != modeRGB ||
ctx->Color.Blend[buf].EquationA != modeA) {
changed = GL_TRUE;
break;
}
}
if (!changed)
return; return;
FLUSH_VERTICES(ctx, _NEW_COLOR); FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.BlendEquationRGB = modeRGB; for (buf = 0; buf < numBuffers; buf++) {
ctx->Color.BlendEquationA = modeA; ctx->Color.Blend[buf].EquationRGB = modeRGB;
ctx->Color.Blend[buf].EquationA = modeA;
}
ctx->Color._BlendEquationPerBuffer = GL_FALSE;
if (ctx->Driver.BlendEquationSeparate) if (ctx->Driver.BlendEquationSeparate)
(*ctx->Driver.BlendEquationSeparate)( ctx, modeRGB, modeA ); ctx->Driver.BlendEquationSeparate(ctx, modeRGB, modeA);
} }
#endif
/**
* Set separate blend equations for one color buffer/target.
*/
void
_mesa_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA)
{
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glBlendEquationSeparatei %u, %s %s\n", buf,
_mesa_lookup_enum_by_nr(modeRGB),
_mesa_lookup_enum_by_nr(modeA));
if (buf >= ctx->Const.MaxDrawBuffers) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBlendEquationSeparatei(buffer=%u)",
buf);
return;
}
if (!legal_blend_equation(ctx, modeRGB, GL_TRUE)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeRGB)");
return;
}
if (!legal_blend_equation(ctx, modeA, GL_TRUE)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeA)");
return;
}
if (ctx->Color.Blend[buf].EquationRGB == modeRGB &&
ctx->Color.Blend[buf].EquationA == modeA)
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.Blend[buf].EquationRGB = modeRGB;
ctx->Color.Blend[buf].EquationA = modeA;
ctx->Color._BlendEquationPerBuffer = GL_TRUE;
if (ctx->Driver.BlendEquationSeparatei)
ctx->Driver.BlendEquationSeparatei(ctx, buf, modeRGB, modeA);
}
#endif /* _HAVE_FULL_GL */
/** /**
@@ -593,6 +774,8 @@ _mesa_ClampColorARB(GLenum target, GLenum clamp)
*/ */
void _mesa_init_color( struct gl_context * ctx ) void _mesa_init_color( struct gl_context * ctx )
{ {
GLuint i;
/* Color buffer group */ /* Color buffer group */
ctx->Color.IndexMask = ~0u; ctx->Color.IndexMask = ~0u;
memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask)); memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask));
@@ -602,12 +785,14 @@ void _mesa_init_color( struct gl_context * ctx )
ctx->Color.AlphaFunc = GL_ALWAYS; ctx->Color.AlphaFunc = GL_ALWAYS;
ctx->Color.AlphaRef = 0; ctx->Color.AlphaRef = 0;
ctx->Color.BlendEnabled = 0x0; ctx->Color.BlendEnabled = 0x0;
ctx->Color.BlendSrcRGB = GL_ONE; for (i = 0; i < Elements(ctx->Color.Blend); i++) {
ctx->Color.BlendDstRGB = GL_ZERO; ctx->Color.Blend[i].SrcRGB = GL_ONE;
ctx->Color.BlendSrcA = GL_ONE; ctx->Color.Blend[i].DstRGB = GL_ZERO;
ctx->Color.BlendDstA = GL_ZERO; ctx->Color.Blend[i].SrcA = GL_ONE;
ctx->Color.BlendEquationRGB = GL_FUNC_ADD; ctx->Color.Blend[i].DstA = GL_ZERO;
ctx->Color.BlendEquationA = GL_FUNC_ADD; ctx->Color.Blend[i].EquationRGB = GL_FUNC_ADD;
ctx->Color.Blend[i].EquationA = GL_FUNC_ADD;
}
ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
ctx->Color.IndexLogicOpEnabled = GL_FALSE; ctx->Color.IndexLogicOpEnabled = GL_FALSE;
ctx->Color.ColorLogicOpEnabled = GL_FALSE; ctx->Color.ColorLogicOpEnabled = GL_FALSE;

View File

@@ -47,14 +47,31 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA ); GLenum sfactorA, GLenum dfactorA );
extern void GLAPIENTRY
_mesa_BlendFunci(GLuint buf, GLenum sfactor, GLenum dfactor);
extern void GLAPIENTRY
_mesa_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA);
extern void GLAPIENTRY extern void GLAPIENTRY
_mesa_BlendEquation( GLenum mode ); _mesa_BlendEquation( GLenum mode );
extern void GLAPIENTRY
_mesa_BlendEquationi(GLuint buf, GLenum mode);
extern void GLAPIENTRY extern void GLAPIENTRY
_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ); _mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA );
extern void
_mesa_BlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeA);
extern void GLAPIENTRY extern void GLAPIENTRY
_mesa_BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); _mesa_BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);

View File

@@ -320,7 +320,7 @@ do { \
*/ */
#define RGBA_LOGICOP_ENABLED(CTX) \ #define RGBA_LOGICOP_ENABLED(CTX) \
((CTX)->Color.ColorLogicOpEnabled || \ ((CTX)->Color.ColorLogicOpEnabled || \
((CTX)->Color.BlendEnabled && (CTX)->Color.BlendEquationRGB == GL_LOGIC_OP)) ((CTX)->Color.BlendEnabled && (CTX)->Color.Blend[0].EquationRGB == GL_LOGIC_OP))
#endif /* CONTEXT_H */ #endif /* CONTEXT_H */

View File

@@ -635,10 +635,15 @@ struct dd_function_table {
void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]); void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]);
/** Set the blend equation */ /** Set the blend equation */
void (*BlendEquationSeparate)(struct gl_context *ctx, GLenum modeRGB, GLenum modeA); void (*BlendEquationSeparate)(struct gl_context *ctx, GLenum modeRGB, GLenum modeA);
void (*BlendEquationSeparatei)(struct gl_context *ctx, GLuint buffer,
GLenum modeRGB, GLenum modeA);
/** Specify pixel arithmetic */ /** Specify pixel arithmetic */
void (*BlendFuncSeparate)(struct gl_context *ctx, void (*BlendFuncSeparate)(struct gl_context *ctx,
GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA); GLenum sfactorA, GLenum dfactorA);
void (*BlendFuncSeparatei)(struct gl_context *ctx, GLuint buffer,
GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA);
/** Specify clear values for the color buffers */ /** Specify clear values for the color buffers */
void (*ClearColor)(struct gl_context *ctx, const GLfloat color[4]); void (*ClearColor)(struct gl_context *ctx, const GLfloat color[4]);
/** Specify the clear value for the depth buffer */ /** Specify the clear value for the depth buffer */

View File

@@ -80,6 +80,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL }, { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL },
{ "GL_ARB_depth_texture", o(ARB_depth_texture), GL }, { "GL_ARB_depth_texture", o(ARB_depth_texture), GL },
{ "GL_ARB_draw_buffers", o(ARB_draw_buffers), GL }, { "GL_ARB_draw_buffers", o(ARB_draw_buffers), GL },
{ "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL },
{ "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL }, { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL },
{ "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL }, { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL },
{ "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL }, { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL },

View File

@@ -372,7 +372,7 @@ static const struct value_desc values[] = {
API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA}, API_OPENGL_BIT | API_OPENGLES_BIT | API_OPENGLES2_BIT, NO_EXTRA},
{ GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers }, { GL_ALPHA_BITS, BUFFER_INT(Visual.alphaBits), extra_new_buffers },
{ GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA }, { GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA },
{ GL_BLEND_SRC, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA }, { GL_BLEND_SRC, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA },
{ GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers }, { GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers },
{ GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA }, { GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA },
{ GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA }, { GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
@@ -435,15 +435,15 @@ static const struct value_desc values[] = {
extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */ extra_ARB_texture_cube_map }, /* XXX: OES_texture_cube_map */
/* XXX: OES_blend_subtract */ /* XXX: OES_blend_subtract */
{ GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA }, { GL_BLEND_SRC_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA },
{ GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA }, { GL_BLEND_DST_RGB_EXT, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA },
{ GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.BlendSrcA), NO_EXTRA }, { GL_BLEND_SRC_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].SrcA), NO_EXTRA },
{ GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.BlendDstA), NO_EXTRA }, { GL_BLEND_DST_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].DstA), NO_EXTRA },
/* GL_BLEND_EQUATION_RGB, which is what we're really after, is /* GL_BLEND_EQUATION_RGB, which is what we're really after, is
* defined identically to GL_BLEND_EQUATION. */ * defined identically to GL_BLEND_EQUATION. */
{ GL_BLEND_EQUATION, CONTEXT_ENUM(Color.BlendEquationRGB), NO_EXTRA }, { GL_BLEND_EQUATION, CONTEXT_ENUM(Color.Blend[0].EquationRGB), NO_EXTRA },
{ GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.BlendEquationA), NO_EXTRA }, { GL_BLEND_EQUATION_ALPHA_EXT, CONTEXT_ENUM(Color.Blend[0].EquationA), NO_EXTRA },
/* GL_ARB_texture_compression */ /* GL_ARB_texture_compression */
{ GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA }, { GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA },
@@ -512,7 +512,7 @@ static const struct value_desc values[] = {
{ GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA }, { GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA },
{ GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA }, { GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA },
{ GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN), NO_EXTRA }, { GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN), NO_EXTRA },
{ GL_BLEND_DST, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA }, { GL_BLEND_DST, CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA },
{ GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA }, { GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA },
{ GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA }, { GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA },
{ GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA }, { GL_CLIP_PLANE2, CONTEXT_BIT2(Transform.ClipPlanesEnabled), NO_EXTRA },

View File

@@ -719,13 +719,20 @@ struct gl_colorbuffer_attrib
*/ */
/*@{*/ /*@{*/
GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */ GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */
GLenum BlendSrcRGB; /**< Blending source operator */
GLenum BlendDstRGB; /**< Blending destination operator */
GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
GLenum BlendEquationRGB; /**< Blending equation */
GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
GLfloat BlendColor[4]; /**< Blending color */ GLfloat BlendColor[4]; /**< Blending color */
struct
{
GLenum SrcRGB; /**< RGB blend source term */
GLenum DstRGB; /**< RGB blend dest term */
GLenum SrcA; /**< Alpha blend source term */
GLenum DstA; /**< Alpha blend dest term */
GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
} Blend[MAX_DRAW_BUFFERS];
/** Are the blend func terms currently different for each buffer/target? */
GLboolean _BlendFuncPerBuffer;
/** Are the blend equations currently different for each buffer/target? */
GLboolean _BlendEquationPerBuffer;
/*@}*/ /*@}*/
/** /**
@@ -2679,6 +2686,7 @@ struct gl_extensions
GLboolean ARB_depth_clamp; GLboolean ARB_depth_clamp;
GLboolean ARB_depth_texture; GLboolean ARB_depth_texture;
GLboolean ARB_draw_buffers; GLboolean ARB_draw_buffers;
GLboolean ARB_draw_buffers_blend;
GLboolean ARB_draw_elements_base_vertex; GLboolean ARB_draw_elements_base_vertex;
GLboolean ARB_draw_instanced; GLboolean ARB_draw_instanced;
GLboolean ARB_fragment_coord_conventions; GLboolean ARB_fragment_coord_conventions;

View File

@@ -169,13 +169,18 @@ colormask_per_rt(struct gl_context *ctx)
} }
/** /**
* Figure out if blend enables are different per rt. * Figure out if blend enables/state are different per rt.
*/ */
static GLboolean static GLboolean
blend_per_rt(struct gl_context *ctx) blend_per_rt(struct gl_context *ctx)
{ {
if (ctx->Color.BlendEnabled && if (ctx->Color.BlendEnabled &&
(ctx->Color.BlendEnabled != ((1 << ctx->Const.MaxDrawBuffers) - 1))) { (ctx->Color.BlendEnabled != ((1 << ctx->Const.MaxDrawBuffers) - 1))) {
/* This can only happen if GL_EXT_draw_buffers2 is enabled */
return GL_TRUE;
}
if (ctx->Color._BlendFuncPerBuffer || ctx->Color._BlendEquationPerBuffer) {
/* this can only happen if GL_ARB_draw_buffers_blend is enabled */
return GL_TRUE; return GL_TRUE;
} }
return GL_FALSE; return GL_FALSE;
@@ -202,7 +207,7 @@ update_blend( struct st_context *st )
don't happen. */ don't happen. */
if (st->ctx->Color.ColorLogicOpEnabled || if (st->ctx->Color.ColorLogicOpEnabled ||
(st->ctx->Color.BlendEnabled && (st->ctx->Color.BlendEnabled &&
st->ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) { st->ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) {
/* logicop enabled */ /* logicop enabled */
blend->logicop_enable = 1; blend->logicop_enable = 1;
blend->logicop_func = translate_logicop(st->ctx->Color.LogicOp); blend->logicop_func = translate_logicop(st->ctx->Color.LogicOp);
@@ -213,28 +218,36 @@ update_blend( struct st_context *st )
blend->rt[i].blend_enable = (st->ctx->Color.BlendEnabled >> i) & 0x1; blend->rt[i].blend_enable = (st->ctx->Color.BlendEnabled >> i) & 0x1;
blend->rt[i].rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); blend->rt[i].rgb_func =
if (st->ctx->Color.BlendEquationRGB == GL_MIN || translate_blend(st->ctx->Color.Blend[i].EquationRGB);
st->ctx->Color.BlendEquationRGB == GL_MAX) {
if (st->ctx->Color.Blend[i].EquationRGB == GL_MIN ||
st->ctx->Color.Blend[i].EquationRGB == GL_MAX) {
/* Min/max are special */ /* Min/max are special */
blend->rt[i].rgb_src_factor = PIPE_BLENDFACTOR_ONE; blend->rt[i].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
blend->rt[i].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; blend->rt[i].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
} }
else { else {
blend->rt[i].rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); blend->rt[i].rgb_src_factor =
blend->rt[i].rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); translate_blend(st->ctx->Color.Blend[i].SrcRGB);
blend->rt[i].rgb_dst_factor =
translate_blend(st->ctx->Color.Blend[i].DstRGB);
} }
blend->rt[i].alpha_func = translate_blend(st->ctx->Color.BlendEquationA); blend->rt[i].alpha_func =
if (st->ctx->Color.BlendEquationA == GL_MIN || translate_blend(st->ctx->Color.Blend[i].EquationA);
st->ctx->Color.BlendEquationA == GL_MAX) {
if (st->ctx->Color.Blend[i].EquationA == GL_MIN ||
st->ctx->Color.Blend[i].EquationA == GL_MAX) {
/* Min/max are special */ /* Min/max are special */
blend->rt[i].alpha_src_factor = PIPE_BLENDFACTOR_ONE; blend->rt[i].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
blend->rt[i].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; blend->rt[i].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
} }
else { else {
blend->rt[i].alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); blend->rt[i].alpha_src_factor =
blend->rt[i].alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); translate_blend(st->ctx->Color.Blend[i].SrcA);
blend->rt[i].alpha_dst_factor =
translate_blend(st->ctx->Color.Blend[i].DstA);
} }
} }
} }

View File

@@ -438,11 +438,9 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ARB_half_float_vertex = GL_TRUE; ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
} }
#if 0 /* not yet */
if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) { if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) {
ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE; ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE;
} }
#endif
if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) { if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY, PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
#if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */ #if 0 /* XXX re-enable when GLSL compiler again supports geometry shaders */

View File

@@ -75,10 +75,10 @@ blend_noop(struct gl_context *ctx, GLuint n, const GLubyte mask[],
{ {
GLint bytes; GLint bytes;
ASSERT(ctx->Color.BlendEquationRGB == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendEquationA == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendSrcRGB == GL_ZERO); ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ZERO);
ASSERT(ctx->Color.BlendDstRGB == GL_ONE); ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE);
(void) ctx; (void) ctx;
/* just memcpy */ /* just memcpy */
@@ -101,10 +101,10 @@ static void _BLENDAPI
blend_replace(struct gl_context *ctx, GLuint n, const GLubyte mask[], blend_replace(struct gl_context *ctx, GLuint n, const GLubyte mask[],
GLvoid *src, const GLvoid *dst, GLenum chanType) GLvoid *src, const GLvoid *dst, GLenum chanType)
{ {
ASSERT(ctx->Color.BlendEquationRGB == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendEquationA == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendSrcRGB == GL_ONE); ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ONE);
ASSERT(ctx->Color.BlendDstRGB == GL_ZERO); ASSERT(ctx->Color.Blend[0].DstRGB == GL_ZERO);
(void) ctx; (void) ctx;
(void) n; (void) n;
(void) mask; (void) mask;
@@ -125,12 +125,12 @@ blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[],
const GLubyte (*dest)[4] = (const GLubyte (*)[4]) dst; const GLubyte (*dest)[4] = (const GLubyte (*)[4]) dst;
GLuint i; GLuint i;
ASSERT(ctx->Color.BlendEquationRGB == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendEquationA == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendSrcRGB == GL_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA);
ASSERT(ctx->Color.BlendSrcA == GL_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA);
ASSERT(ctx->Color.BlendDstRGB == GL_ONE_MINUS_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA);
ASSERT(ctx->Color.BlendDstA == GL_ONE_MINUS_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA);
ASSERT(chanType == GL_UNSIGNED_BYTE); ASSERT(chanType == GL_UNSIGNED_BYTE);
(void) ctx; (void) ctx;
@@ -170,12 +170,12 @@ blend_transparency_ushort(struct gl_context *ctx, GLuint n, const GLubyte mask[]
const GLushort (*dest)[4] = (const GLushort (*)[4]) dst; const GLushort (*dest)[4] = (const GLushort (*)[4]) dst;
GLuint i; GLuint i;
ASSERT(ctx->Color.BlendEquationRGB == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendEquationA == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendSrcRGB == GL_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA);
ASSERT(ctx->Color.BlendSrcA == GL_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA);
ASSERT(ctx->Color.BlendDstRGB == GL_ONE_MINUS_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA);
ASSERT(ctx->Color.BlendDstA == GL_ONE_MINUS_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA);
ASSERT(chanType == GL_UNSIGNED_SHORT); ASSERT(chanType == GL_UNSIGNED_SHORT);
(void) ctx; (void) ctx;
@@ -208,12 +208,12 @@ blend_transparency_float(struct gl_context *ctx, GLuint n, const GLubyte mask[],
const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst;
GLuint i; GLuint i;
ASSERT(ctx->Color.BlendEquationRGB == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendEquationA == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendSrcRGB == GL_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA);
ASSERT(ctx->Color.BlendSrcA == GL_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA);
ASSERT(ctx->Color.BlendDstRGB == GL_ONE_MINUS_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA);
ASSERT(ctx->Color.BlendDstA == GL_ONE_MINUS_SRC_ALPHA); ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA);
ASSERT(chanType == GL_FLOAT); ASSERT(chanType == GL_FLOAT);
(void) ctx; (void) ctx;
@@ -248,10 +248,10 @@ blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[],
{ {
GLuint i; GLuint i;
ASSERT(ctx->Color.BlendEquationRGB == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendEquationA == GL_FUNC_ADD); ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD);
ASSERT(ctx->Color.BlendSrcRGB == GL_ONE); ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ONE);
ASSERT(ctx->Color.BlendDstRGB == GL_ONE); ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE);
(void) ctx; (void) ctx;
if (chanType == GL_UNSIGNED_BYTE) { if (chanType == GL_UNSIGNED_BYTE) {
@@ -313,8 +313,8 @@ blend_min(struct gl_context *ctx, GLuint n, const GLubyte mask[],
GLvoid *src, const GLvoid *dst, GLenum chanType) GLvoid *src, const GLvoid *dst, GLenum chanType)
{ {
GLuint i; GLuint i;
ASSERT(ctx->Color.BlendEquationRGB == GL_MIN); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_MIN);
ASSERT(ctx->Color.BlendEquationA == GL_MIN); ASSERT(ctx->Color.Blend[0].EquationA == GL_MIN);
(void) ctx; (void) ctx;
if (chanType == GL_UNSIGNED_BYTE) { if (chanType == GL_UNSIGNED_BYTE) {
@@ -366,8 +366,8 @@ blend_max(struct gl_context *ctx, GLuint n, const GLubyte mask[],
GLvoid *src, const GLvoid *dst, GLenum chanType) GLvoid *src, const GLvoid *dst, GLenum chanType)
{ {
GLuint i; GLuint i;
ASSERT(ctx->Color.BlendEquationRGB == GL_MAX); ASSERT(ctx->Color.Blend[0].EquationRGB == GL_MAX);
ASSERT(ctx->Color.BlendEquationA == GL_MAX); ASSERT(ctx->Color.Blend[0].EquationA == GL_MAX);
(void) ctx; (void) ctx;
if (chanType == GL_UNSIGNED_BYTE) { if (chanType == GL_UNSIGNED_BYTE) {
@@ -500,7 +500,7 @@ blend_general_float(struct gl_context *ctx, GLuint n, const GLubyte mask[],
*/ */
/* Source RGB factor */ /* Source RGB factor */
switch (ctx->Color.BlendSrcRGB) { switch (ctx->Color.Blend[0].SrcRGB) {
case GL_ZERO: case GL_ZERO:
sR = sG = sB = 0.0F; sR = sG = sB = 0.0F;
break; break;
@@ -570,7 +570,7 @@ blend_general_float(struct gl_context *ctx, GLuint n, const GLubyte mask[],
} }
/* Source Alpha factor */ /* Source Alpha factor */
switch (ctx->Color.BlendSrcA) { switch (ctx->Color.Blend[0].SrcA) {
case GL_ZERO: case GL_ZERO:
sA = 0.0F; sA = 0.0F;
break; break;
@@ -624,7 +624,7 @@ blend_general_float(struct gl_context *ctx, GLuint n, const GLubyte mask[],
} }
/* Dest RGB factor */ /* Dest RGB factor */
switch (ctx->Color.BlendDstRGB) { switch (ctx->Color.Blend[0].DstRGB) {
case GL_ZERO: case GL_ZERO:
dR = dG = dB = 0.0F; dR = dG = dB = 0.0F;
break; break;
@@ -687,7 +687,7 @@ blend_general_float(struct gl_context *ctx, GLuint n, const GLubyte mask[],
} }
/* Dest Alpha factor */ /* Dest Alpha factor */
switch (ctx->Color.BlendDstA) { switch (ctx->Color.Blend[0].DstA) {
case GL_ZERO: case GL_ZERO:
dA = 0.0F; dA = 0.0F;
break; break;
@@ -738,7 +738,7 @@ blend_general_float(struct gl_context *ctx, GLuint n, const GLubyte mask[],
} }
/* compute the blended RGB */ /* compute the blended RGB */
switch (ctx->Color.BlendEquationRGB) { switch (ctx->Color.Blend[0].EquationRGB) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
r = Rs * sR + Rd * dR; r = Rs * sR + Rd * dR;
g = Gs * sG + Gd * dG; g = Gs * sG + Gd * dG;
@@ -775,7 +775,7 @@ blend_general_float(struct gl_context *ctx, GLuint n, const GLubyte mask[],
} }
/* compute the blended alpha */ /* compute the blended alpha */
switch (ctx->Color.BlendEquationA) { switch (ctx->Color.Blend[0].EquationA) {
case GL_FUNC_ADD: case GL_FUNC_ADD:
a = As * sA + Ad * dA; a = As * sA + Ad * dA;
break; break;
@@ -907,13 +907,13 @@ void
_swrast_choose_blend_func(struct gl_context *ctx, GLenum chanType) _swrast_choose_blend_func(struct gl_context *ctx, GLenum chanType)
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLenum eq = ctx->Color.BlendEquationRGB; const GLenum eq = ctx->Color.Blend[0].EquationRGB;
const GLenum srcRGB = ctx->Color.BlendSrcRGB; const GLenum srcRGB = ctx->Color.Blend[0].SrcRGB;
const GLenum dstRGB = ctx->Color.BlendDstRGB; const GLenum dstRGB = ctx->Color.Blend[0].DstRGB;
const GLenum srcA = ctx->Color.BlendSrcA; const GLenum srcA = ctx->Color.Blend[0].SrcA;
const GLenum dstA = ctx->Color.BlendDstA; const GLenum dstA = ctx->Color.Blend[0].DstA;
if (ctx->Color.BlendEquationRGB != ctx->Color.BlendEquationA) { if (ctx->Color.Blend[0].EquationRGB != ctx->Color.Blend[0].EquationA) {
swrast->BlendFunc = blend_general; swrast->BlendFunc = blend_general;
} }
else if (eq == GL_MIN) { else if (eq == GL_MIN) {