[Cogl] is test-state in clutter test framework applicable for cogl-batching
Robert Bragg
robert at sixbynine.org
Mon Feb 18 17:07:30 PST 2013
Hi,
I'm fairly sure that in the past clutter's test-state used to get
batched fairly well, but from digging into it now it seems there are a
few things that make it difficult to automatically batch at the cogl
level.
The first thing is that all of the actors in that test have a
desaturate effect applied to them which results in each actor being
redirected to an offscreen framebuffer and so even though they are
based on the same texture the final texture used for each actor is
actually different. I think changing the ClutterDesaturateEffect to
avoid using using offscreen framebuffers when the desaturate factor is
close to 0 would be good for this test since it's only really the
actor that has the mouse over it that is actually desaturated.
Here's a hack I used to work around this issue:
diff --git a/clutter/clutter-desaturate-effect.c
b/clutter/clutter-desaturate-effect.c
index c5fd04b..25e90f2 100644
--- a/clutter/clutter-desaturate-effect.c
+++ b/clutter/clutter-desaturate-effect.c
@@ -119,6 +119,9 @@ clutter_desaturate_effect_pre_paint (ClutterEffect *effect)
ClutterDesaturateEffect *self = CLUTTER_DESATURATE_EFFECT (effect);
ClutterEffectClass *parent_class;
+ if (self->factor < 0.001f)
+ return FALSE;
+
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
return FALSE;
The second thing is that each item in test-state is actually a
ClutterGroup with two actors in it; a ClutterTexture for the hand logo
and a ClutterRectangle for the background. This effectively makes it
difficult for cogl to batch the geometry because cogl sees 1 textured
rectangle followed by 1 non-texture rectangle, then 1 textured
rectangle, then 1 non-textured rectangle... and in terms of submitting
that to the gpu it's rather tricky for us to avoid needing a state
change between each item.
To do what test-state does more efficiently I think it would somehow
need to be changed so that it either drew all of the backgrounds
back-to-back as a set followed by drawing all of the textured hands
back-to-back as a set, or it could be changed so that instead of using
two actors for each item it instead used one actor that was able to
modulate the desired colour directly with texture.
I'm afraid I don't know the easiest way to do that with clutter a.t.m
since I haven't been keeping up with the latest paint-nodes api but if
you need to do something similar in an application of yours I'd
suggest looking into achieving the result by only using a single actor
per item which only has a single paint-node that can combine a custom
colour with the texture. If you use clutter_pipeline_node_new()
somehow then it would be possible to create a CoglPipeline with a
texture set on layer 0 and then you can set a color on the pipeline
too and that will be modulated with the texture. E.g. something along
these lines:
CoglPipeline *pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, hand_texture);
cogl_pipeline_set_color4f (pipeline, r, g, b, 1);
node = clutter_pipeline_node_new (pipeline);
(Then find out how to attach that node to an actor)
I hope that helps a bit,
kind regards,
- Robert
On Sat, Feb 16, 2013 at 8:25 AM, mahesh gawali <maheshgawali at gmail.com> wrote:
> Hi,
>
> Please take a look at this
>
> https://mail.gnome.org/archives/clutter-list/2013-February/msg00057.html
>
> I have wondered about this too with respect to cogl-batching.
>
> this test draws a lot of actors using same image and size, cogl-batching
> however shows batch length=1 more than often.
>
> I have seen deteriorated performance for this application when i ported it
> to my ARM target. Wondering if cogl-batching has anything to do with this ?
>
>
> - Mahesh
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
>
More information about the Cogl
mailing list