From cf002a79898d154edadf00e38e0ce18e17e26e05 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 29 May 2013 16:20:58 +0100 Subject: [PATCH] pipeline: ignore driver in blend state tracking This removes the various checks for != COGL_DRIVER_GLES1 when tracking blend state that was trying to avoid checking the equation or alpha component factors when they are known to be fixed on gles1. Now we just rely on the opengl driver to do the right thing for the different drivers and ignore the differences in the general pipeline state tracking. Reviewed-by: Neil Roberts (cherry picked from commit f67c7eaf23e1e2088e9956cb2b66dfdc9abc8b3b) --- cogl/cogl-pipeline-state.c | 113 +++++++++++++++---------------------- 1 file changed, 46 insertions(+), 67 deletions(-) diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c index bb00568d1..528fabd09 100644 --- a/cogl/cogl-pipeline-state.c +++ b/cogl/cogl-pipeline-state.c @@ -119,40 +119,35 @@ _cogl_pipeline_blend_state_equal (CoglPipeline *authority0, _COGL_GET_CONTEXT (ctx, FALSE); -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) - if (ctx->driver != COGL_DRIVER_GLES1) - { - if (blend_state0->blend_equation_rgb != blend_state1->blend_equation_rgb) - return FALSE; - if (blend_state0->blend_equation_alpha != - blend_state1->blend_equation_alpha) - return FALSE; - if (blend_state0->blend_src_factor_alpha != - blend_state1->blend_src_factor_alpha) - return FALSE; - if (blend_state0->blend_dst_factor_alpha != - blend_state1->blend_dst_factor_alpha) - return FALSE; - } -#endif + if (blend_state0->blend_equation_rgb != blend_state1->blend_equation_rgb) + return FALSE; + + if (blend_state0->blend_equation_alpha != + blend_state1->blend_equation_alpha) + return FALSE; + if (blend_state0->blend_src_factor_alpha != + blend_state1->blend_src_factor_alpha) + return FALSE; + if (blend_state0->blend_dst_factor_alpha != + blend_state1->blend_dst_factor_alpha) + return FALSE; + if (blend_state0->blend_src_factor_rgb != blend_state1->blend_src_factor_rgb) return FALSE; if (blend_state0->blend_dst_factor_rgb != blend_state1->blend_dst_factor_rgb) return FALSE; -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) - if (ctx->driver != COGL_DRIVER_GLES1 && - (blend_state0->blend_src_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || - blend_state0->blend_src_factor_rgb == GL_CONSTANT_COLOR || - blend_state0->blend_dst_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || - blend_state0->blend_dst_factor_rgb == GL_CONSTANT_COLOR)) + + if (blend_state0->blend_src_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || + blend_state0->blend_src_factor_rgb == GL_CONSTANT_COLOR || + blend_state0->blend_dst_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || + blend_state0->blend_dst_factor_rgb == GL_CONSTANT_COLOR) { if (!cogl_color_equal (&blend_state0->blend_constant, &blend_state1->blend_constant)) return FALSE; } -#endif return TRUE; } @@ -980,26 +975,15 @@ cogl_pipeline_set_blend (CoglPipeline *pipeline, _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); blend_state = &pipeline->big_state->blend_state; -#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2) - if (ctx->driver != COGL_DRIVER_GLES1) - { - setup_blend_state (rgb, - &blend_state->blend_equation_rgb, - &blend_state->blend_src_factor_rgb, - &blend_state->blend_dst_factor_rgb); - setup_blend_state (a, - &blend_state->blend_equation_alpha, - &blend_state->blend_src_factor_alpha, - &blend_state->blend_dst_factor_alpha); - } - else -#endif - { - setup_blend_state (rgb, - NULL, - &blend_state->blend_src_factor_rgb, - &blend_state->blend_dst_factor_rgb); - } + + setup_blend_state (rgb, + &blend_state->blend_equation_rgb, + &blend_state->blend_src_factor_rgb, + &blend_state->blend_dst_factor_rgb); + setup_blend_state (a, + &blend_state->blend_equation_alpha, + &blend_state->blend_src_factor_alpha, + &blend_state->blend_dst_factor_alpha); /* If we are the current authority see if we can revert to one of our * ancestors being the authority */ @@ -1752,33 +1736,28 @@ _cogl_pipeline_hash_blend_state (CoglPipeline *authority, hash = state->hash; -#if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) - if (ctx->driver != COGL_DRIVER_GLES1) + hash = + _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_equation_rgb, + sizeof (blend_state->blend_equation_rgb)); + hash = + _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_equation_alpha, + sizeof (blend_state->blend_equation_alpha)); + hash = + _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_src_factor_alpha, + sizeof (blend_state->blend_src_factor_alpha)); + hash = + _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_dst_factor_alpha, + sizeof (blend_state->blend_dst_factor_alpha)); + + if (blend_state->blend_src_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || + blend_state->blend_src_factor_rgb == GL_CONSTANT_COLOR || + blend_state->blend_dst_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || + blend_state->blend_dst_factor_rgb == GL_CONSTANT_COLOR) { hash = - _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_equation_rgb, - sizeof (blend_state->blend_equation_rgb)); - hash = - _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_equation_alpha, - sizeof (blend_state->blend_equation_alpha)); - hash = - _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_src_factor_alpha, - sizeof (blend_state->blend_src_factor_alpha)); - hash = - _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_dst_factor_alpha, - sizeof (blend_state->blend_dst_factor_alpha)); - - if (blend_state->blend_src_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || - blend_state->blend_src_factor_rgb == GL_CONSTANT_COLOR || - blend_state->blend_dst_factor_rgb == GL_ONE_MINUS_CONSTANT_COLOR || - blend_state->blend_dst_factor_rgb == GL_CONSTANT_COLOR) - { - hash = - _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_constant, - sizeof (blend_state->blend_constant)); - } + _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_constant, + sizeof (blend_state->blend_constant)); } -#endif hash = _cogl_util_one_at_a_time_hash (hash, &blend_state->blend_src_factor_rgb,