From 98dd3f723c19b1d9f5a249d6bd08db58c76eabba Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 3 Dec 2010 16:59:52 +0000 Subject: [PATCH] pipeline simple optimization for _needs_blending_enabled In _cogl_pipeline_needs_blending_enabled after first checking whether the property most recently changed requires blending we would then resort to checking all other properties too in case some other state also requires blending. We now avoid checking all other properties in the case that blending was previously disabled and checking the property recently changed doesn't require blending. Note: the plan is to improve this further by explicitly keeping track of the properties that currently cause blending to be enabled so that we never have to resort to checking all other properties we can constrain the checks to those masked properties. --- cogl/cogl-pipeline.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 7932911a2..0362b59d7 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -907,11 +907,20 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline, if (has_alpha) return TRUE; } - else + + /* At this point, considering just the state that has changed it + * looks like blending isn't needed. If blending was previously + * enabled though it could be that some other state still requires + * that we have blending enabled. In this case we still need to + * go and check the other state... + * + * FIXME: We should explicitly keep track of the mask of state + * groups that are currently causing blending to be enabled so that + * we never have to resort to checking *all* the state and can + * instead always limit the check to those in the mask. + */ + if (pipeline->real_blend_enable) { - /* In this case we have so far only checked the property that - * has been changed so we now need to check all the other - * properties too. */ other_state = COGL_PIPELINE_STATE_AFFECTS_BLENDING & ~changes; if (other_state && _cogl_pipeline_needs_blending_enabled (pipeline,