+static enum gl_advanced_blend_mode
+advanced_blend_mode_from_gl_enum(GLenum mode)
+{
+ switch (mode) {
+ case GL_MULTIPLY_KHR:
+ return BLEND_MULTIPLY;
+ case GL_SCREEN_KHR:
+ return BLEND_SCREEN;
+ case GL_OVERLAY_KHR:
+ return BLEND_OVERLAY;
+ case GL_DARKEN_KHR:
+ return BLEND_DARKEN;
+ case GL_LIGHTEN_KHR:
+ return BLEND_LIGHTEN;
+ case GL_COLORDODGE_KHR:
+ return BLEND_COLORDODGE;
+ case GL_COLORBURN_KHR:
+ return BLEND_COLORBURN;
+ case GL_HARDLIGHT_KHR:
+ return BLEND_HARDLIGHT;
+ case GL_SOFTLIGHT_KHR:
+ return BLEND_SOFTLIGHT;
+ case GL_DIFFERENCE_KHR:
+ return BLEND_DIFFERENCE;
+ case GL_EXCLUSION_KHR:
+ return BLEND_EXCLUSION;
+ case GL_HSL_HUE_KHR:
+ return BLEND_HSL_HUE;
+ case GL_HSL_SATURATION_KHR:
+ return BLEND_HSL_SATURATION;
+ case GL_HSL_COLOR_KHR:
+ return BLEND_HSL_COLOR;
+ case GL_HSL_LUMINOSITY_KHR:
+ return BLEND_HSL_LUMINOSITY;
+ default:
+ return BLEND_NONE;
+ }
+}
+
+/**
+ * If \p mode is one of the advanced blending equations defined by
+ * GL_KHR_blend_equation_advanced (and the extension is supported),
+ * return the corresponding BLEND_* enum. Otherwise, return BLEND_NONE
+ * (which can also be treated as false).
+ */
+static enum gl_advanced_blend_mode
+advanced_blend_mode(const struct gl_context *ctx, GLenum mode)
+{
+ return _mesa_has_KHR_blend_equation_advanced(ctx) ?
+ advanced_blend_mode_from_gl_enum(mode) : BLEND_NONE;
+}