framebuffer: flush journal when switching framebuffers
authorRobert Bragg <robert@linux.intel.com>
Fri, 21 Jan 2011 19:05:23 +0000 (19:05 +0000)
committerRobert Bragg <robert@linux.intel.com>
Mon, 24 Jan 2011 18:53:08 +0000 (18:53 +0000)
commitbca39776d3080c180cdcf6698a54ee2c25bb5383
tree23c12e14ee6d4f88a2d5aad54f6805cb26eeec73
parent4609770bb9faa4dc74ddd0f25e099ff46b91e258
framebuffer: flush journal when switching framebuffers

There is currently a problem with per-framebuffer journals in that it's
possible to create a framebuffer from a texture which then gets rendered
too but the framebuffer (and corresponding journal) can be freed before
the texture gets used to draw with.

Conceptually we want to make sure when freeing a framebuffer that - if
it is associated with a texture - we flush the journal as the last thing
before really freeing the framebuffer's meta data. Technically though
this is awkward to implement since the obvious mechanism for us to be
notified about the framebuffer's destruction (by setting some user data
internally with a callback) notifies when the framebuffer has a
ref-count of 0. This means we'd have to be careful what we do with the
framebuffer to consider e.g. recursive destruction; anything that would
set more user data on the framebuffer while it is being destroyed and
ensuring nothing else gets notified of the framebuffer's destruction
before the journal has been flushed.

For simplicity, for now, this patch provides another solution which is
to flush framebuffer journals whenever we switch away from a given
framebuffer via cogl_set_framebuffer or cogl_push/pop_framebuffer. The
disadvantage of this approach is that we can't batch all the geometry of
a scene that involves intermediate renders to offscreen framebufers.
Clutter is doing this more and more with applications that use the
ClutterEffect APIs so this is a shame. Hopefully this will only be a
stop-gap solution while we consider how to reliably support journal
logging across framebuffer changes.
clutter/cogl/cogl/cogl-framebuffer.c