Journal usage during animations

35 views
Skip to first unread message

Luca Bruno

unread,
Sep 29, 2011, 12:52:15 PM9/29/11
to cog...@googlegroups.com
Hello,
I've profiled the crate example using callgrind, and I saw that the functions with most instructions in cogl are those related to the journal, in particular upload_vertices. It's being called for every animation frame because the quads of the cube rotate.
In addition to this consider that the example never tries to read pixels, therefore the journal is useless (this is the main reason why journal exists if I'm not wrong).

The journal is a kind of speculation to avoid calling glReadPixels, and as such it's useful as long as there's a gain (that is, if the total time spent using glReadPixels is more than the time spent in the journal).

I'd like to hear if there's a plan to use a kind of state-machine statistics (something cheap like used for branch prediction in a CPU, but for try_read_pixel prediction), maybe based on the number of journal flushes/logged quads. Or any other solution to bypass the journal when it's not used, or if there's any other bigger plan...

Best regards,

--
www.debian.org - The Universal Operating System

Neil Roberts

unread,
Sep 29, 2011, 2:15:04 PM9/29/11
to Luca Bruno, cog...@googlegroups.com
Hi Luca,

Luca Bruno <letha...@gmail.com> wrote:

> In addition to this consider that the example never tries to read
> pixels, therefore the journal is useless (this is the main reason why
> journal exists if I'm not wrong).

The journal is more useful than just an optimisation for avoiding
glReadPixels. In fact that was only added relatively recently and the
journal has existed for much longer. Without the journal any quads to
draw would have to be submitted to OpenGL individually with separate
draw calls. GPUs are designed to be efficient for drawing large batches
of geometry and there can therefore be a fairly large overhead to set up
the drawing pipeline. If you go through this effort to only paint one
quad then the overhead is pretty much wasted.

In the crate example the crate is actually drawn using a CoglPrimitive
instead of drawing rectangles so it doesn't actually use the journal at
all. I'd imagine the reason you're seeing upload_vertices being called
is instead because of the text. The glyphs for short runs of text are
rendered using cogl_rectangles which ends up getting put in the
journal. In this particular example the journal doesn't actually help
much because because there is only one label. But usually in a typical
2D application there will be many quads in a single frame which can
benefit a lot from being batched together.

If you use Cogl to make a 3D-style game where the models are drawn using
CoglPrimitives then the journal will stay out of the way and you can
have more direct control over how stuff is rendered. However if you want
the convenience of just being able to paint rectangles without having to
collaborate with other components of the application to get it to render
efficiently (like Clutter would) then the journal can help a lot.

Regards,
- Neil

Robert Bragg

unread,
Sep 29, 2011, 2:56:14 PM9/29/11
to cog...@googlegroups.com, Luca Bruno
Just to a add a bit to what Neil said, you might be interested to try the COGL_DEBUG=rectangles option to be able to visualize things that are rendered via the journal. For example if you use that option with the crate demo you'll see a wire, rectangle, outline around the glyphs. Something else nice about this visualization is that the rectangles will be the same color if they have been batched together into a single draw command.

kind regards,
- Robert
Reply all
Reply to author
Forward
0 new messages