_mesa_BlendFuncSeparateEXT(sfactor, dfactor, sfactor, dfactor);
}
+static GLboolean
+blend_factor_is_dual_src(GLenum factor)
+{
+ return (factor == GL_SRC1_COLOR ||
+ factor == GL_SRC1_ALPHA ||
+ factor == GL_ONE_MINUS_SRC1_COLOR ||
+ factor == GL_ONE_MINUS_SRC1_ALPHA);
+}
+
+static void
+update_uses_dual_src(struct gl_context *ctx, int buf)
+{
+ ctx->Color.Blend[buf]._UsesDualSrc =
+ (blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcRGB) ||
+ blend_factor_is_dual_src(ctx->Color.Blend[buf].DstRGB) ||
+ blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcA) ||
+ blend_factor_is_dual_src(ctx->Color.Blend[buf].DstA));
+}
/**
* Set the separate blend source/dest factors for all draw buffers.
ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
+ update_uses_dual_src(ctx, buf);
}
ctx->Color._BlendFuncPerBuffer = GL_FALSE;
ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
+ update_uses_dual_src(ctx, buf);
ctx->Color._BlendFuncPerBuffer = GL_TRUE;
if (ctx->Driver.BlendFuncSeparatei) {
ctx->mvp_with_dp4 = flag;
}
-static GLboolean
-blend_factor_is_dual_src(GLenum factor)
-{
- return factor == GL_SRC1_COLOR || factor == GL_SRC1_ALPHA ||
- factor == GL_ONE_MINUS_SRC1_COLOR || factor == GL_ONE_MINUS_SRC1_ALPHA;
-}
-
/*
* ARB_blend_func_extended - ERRORS section
* "The error INVALID_OPERATION is generated by Begin or any procedure that
_mesa_check_blend_func_error(struct gl_context *ctx)
{
GLuint i;
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- if (blend_factor_is_dual_src(ctx->Color.Blend[i].SrcRGB) ||
- blend_factor_is_dual_src(ctx->Color.Blend[i].DstRGB) ||
- blend_factor_is_dual_src(ctx->Color.Blend[i].SrcA) ||
- blend_factor_is_dual_src(ctx->Color.Blend[i].DstA)) {
- if (i >= ctx->Const.MaxDualSourceDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "dual source blend on illegal attachment");
- return GL_FALSE;
- }
+ for (i = ctx->Const.MaxDualSourceDrawBuffers;
+ i < ctx->DrawBuffer->_NumColorDrawBuffers;
+ i++) {
+ if (ctx->Color.Blend[i]._UsesDualSrc) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "dual source blend on illegal attachment");
+ return GL_FALSE;
}
}
return GL_TRUE;
GLenum DstA; /**< Alpha blend dest term */
GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
+ /**
+ * Set if any blend factor uses SRC1. Computed at the time blend factors
+ * get set.
+ */
+ GLboolean _UsesDualSrc;
} Blend[MAX_DRAW_BUFFERS];
/** Are the blend func terms currently different for each buffer/target? */
GLboolean _BlendFuncPerBuffer;