case GL_SRC1_ALPHA:
case GL_ONE_MINUS_SRC1_COLOR:
case GL_ONE_MINUS_SRC1_ALPHA:
- return _mesa_is_desktop_gl(ctx)
+ return ctx->API != API_OPENGLES
&& ctx->Extensions.ARB_blend_func_extended;
default:
return GL_FALSE;
case GL_ONE_MINUS_CONSTANT_ALPHA:
return _mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2;
case GL_SRC_ALPHA_SATURATE:
- return (_mesa_is_desktop_gl(ctx)
+ return (ctx->API != API_OPENGLES
&& ctx->Extensions.ARB_blend_func_extended)
|| _mesa_is_gles3(ctx);
case GL_SRC1_COLOR:
case GL_SRC1_ALPHA:
case GL_ONE_MINUS_SRC1_COLOR:
case GL_ONE_MINUS_SRC1_ALPHA:
- return _mesa_is_desktop_gl(ctx)
+ return ctx->API != API_OPENGLES
&& ctx->Extensions.ARB_blend_func_extended;
default:
return GL_FALSE;
blend_factor_is_dual_src(ctx->Color.Blend[buf].DstA));
}
+
+/**
+ * Return the number of per-buffer blend states to update in
+ * glBlendFunc, glBlendFuncSeparate, glBlendEquation, etc.
+ */
+static inline unsigned
+num_buffers(const struct gl_context *ctx)
+{
+ return ctx->Extensions.ARB_draw_buffers_blend
+ ? ctx->Const.MaxDrawBuffers : 1;
+}
+
+
/**
* Set the separate blend source/dest factors for all draw buffers.
*
_mesa_BlendFuncSeparate( GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA )
{
- GLuint buf, numBuffers;
- bool changed = false;
GET_CURRENT_CONTEXT(ctx);
+ const unsigned numBuffers = num_buffers(ctx);
+ unsigned buf;
+ bool changed = false;
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glBlendFuncSeparate %s %s %s %s\n",
_mesa_enum_to_string(sfactorA),
_mesa_enum_to_string(dfactorA));
- numBuffers = ctx->Extensions.ARB_draw_buffers_blend
- ? ctx->Const.MaxDrawBuffers : 1;
-
/* Check if we're really changing any state. If not, return early. */
if (ctx->Color._BlendFuncPerBuffer) {
/* Check all per-buffer states */
ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
- update_uses_dual_src(ctx, buf);
}
+
+ update_uses_dual_src(ctx, 0);
+ for (buf = 1; buf < numBuffers; buf++) {
+ ctx->Color.Blend[buf]._UsesDualSrc = ctx->Color.Blend[0]._UsesDualSrc;
+ }
+
ctx->Color._BlendFuncPerBuffer = GL_FALSE;
if (ctx->Driver.BlendFuncSeparate) {
void GLAPIENTRY
_mesa_BlendEquation( GLenum mode )
{
- GLuint buf, numBuffers;
- bool changed = false;
GET_CURRENT_CONTEXT(ctx);
+ const unsigned numBuffers = num_buffers(ctx);
+ unsigned buf;
+ bool changed = false;
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glBlendEquation(%s)\n",
_mesa_enum_to_string(mode));
- numBuffers = ctx->Extensions.ARB_draw_buffers_blend
- ? ctx->Const.MaxDrawBuffers : 1;
-
if (ctx->Color._BlendEquationPerBuffer) {
/* Check all per-buffer states */
for (buf = 0; buf < numBuffers; buf++) {
ctx->Color._BlendEquationPerBuffer = GL_FALSE;
if (ctx->Driver.BlendEquationSeparate)
- (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode );
+ ctx->Driver.BlendEquationSeparate(ctx, mode, mode);
}
buf, _mesa_enum_to_string(mode));
if (buf >= ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBlendFuncSeparatei(buffer=%u)",
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBlendEquationi(buffer=%u)",
buf);
return;
}
void GLAPIENTRY
_mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA )
{
- GLuint buf, numBuffers;
- bool changed = false;
GET_CURRENT_CONTEXT(ctx);
+ const unsigned numBuffers = num_buffers(ctx);
+ unsigned buf;
+ bool changed = false;
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glBlendEquationSeparateEXT(%s %s)\n",
_mesa_enum_to_string(modeRGB),
_mesa_enum_to_string(modeA));
- numBuffers = ctx->Extensions.ARB_draw_buffers_blend
- ? ctx->Const.MaxDrawBuffers : 1;
-
if (ctx->Color._BlendEquationPerBuffer) {
/* Check all per-buffer states */
for (buf = 0; buf < numBuffers; buf++) {
ctx->Color.BlendColor[3] = CLAMP(tmp[3], 0.0F, 1.0F);
if (ctx->Driver.BlendColor)
- (*ctx->Driver.BlendColor)(ctx, ctx->Color.BlendColor);
+ ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor);
}
* \param opcode operation.
*
* Verifies that \p opcode is a valid enum and updates
-gl_colorbuffer_attrib::LogicOp.
+ * gl_colorbuffer_attrib::LogicOp.
* On a change, flushes the vertices and notifies the driver via the
* dd_function_table::LogicOpcode callback.
*/