Kenneth Graunke <kenn...@whitecape.org> writes: > Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> > --- > src/mesa/main/context.c | 51 > +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 51 insertions(+) > > diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c > index 4ff0979..e63d8a6 100644 > --- a/src/mesa/main/context.c > +++ b/src/mesa/main/context.c > @@ -1876,6 +1876,57 @@ 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 [...]" > + */ > + struct gl_shader_program *sh_prog = > ctx->_Shader->_CurrentFragmentProgram; > + struct gl_shader_info *fs_info = > + &sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->info;
Don't you need a NULL check here to avoid a crash if there is no valid fragment program bound to the pipeline? You could also declare the variables above as pointers to const. With that fixed: Reviewed-by: Francisco Jerez <curroje...@riseup.net> > + > + if ((fs_info->BlendSupport & 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; > } > > -- > 2.9.3 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev