summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/context.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 4ff0979c00b..8f9bbf1b732 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1876,6 +1876,58 @@ check_blend_func_error(struct gl_context *ctx)
return false;
}
}
+
+ if (ctx->Color.BlendEnabled && ctx->Color._AdvancedBlendMode) {
+ /* The KHR_blend_equation_advanced spec says:
+ *
+ * "If any non-NONE draw buffer uses a blend equation found in table
+ * X.1 or X.2, the error INVALID_OPERATION is generated by Begin or
+ * any operation that implicitly calls Begin (such as DrawElements)
+ * if:
+ *
+ * * the draw buffer for color output zero selects multiple color
+ * buffers (e.g., FRONT_AND_BACK in the default framebuffer); or
+ *
+ * * the draw buffer for any other color output is not NONE."
+ */
+ if (ctx->DrawBuffer->ColorDrawBuffer[0] == GL_FRONT_AND_BACK) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "advanced blending is active and draw buffer for color "
+ "output zero selects multiple color buffers");
+ return false;
+ }
+
+ for (unsigned i = 1; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
+ if (ctx->DrawBuffer->ColorDrawBuffer[i] != GL_NONE) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "advanced blending is active with multiple color "
+ "draw buffers");
+ return false;
+ }
+ }
+
+ /* The KHR_blend_equation_advanced spec says:
+ *
+ * "Advanced blending equations require the use of a fragment shader
+ * with a matching "blend_support" layout qualifier. If the current
+ * blend equation is found in table X.1 or X.2, and the active
+ * fragment shader does not include the layout qualifier matching
+ * the blend equation or "blend_support_all_equations", the error
+ * INVALID_OPERATION is generated [...]"
+ */
+ const struct gl_shader_program *sh_prog =
+ ctx->_Shader->_CurrentFragmentProgram;
+ const GLbitfield blend_support = !sh_prog ? 0 :
+ sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->info.BlendSupport;
+
+ if ((blend_support & ctx->Color._AdvancedBlendMode) == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "fragment shader does not allow advanced blending mode "
+ "(%s)",
+ _mesa_enum_to_string(ctx->Color.Blend[0].EquationRGB));
+ }
+ }
+
return true;
}