[Cogl] How can we gracefully handle Cogl and GL out of memory conditions?

Robert Bragg robert at sixbynine.org
Fri Nov 1 09:02:52 PDT 2013


Hi Reza,

It looks like you are getting a GL out-of-memory error in
glDrawElements, which is pretty un-usual and something you'd hope for
drivers to avoid ever happening since it doesn't correlate with a user
requested resource allocation. At this point you're just asking the
GPU to go ahead and process the data you already allocated and store
the results in a buffer you've also already allocated. No doubt the GL
spec technically allows this, but that's pretty mean :-/

Cogl provides apis for allocating textures and framebuffers and
explicitly checking that they have successfully been allocated using
glCheckFramebufferStatus for example. If a driver were to aggressively
try to defer allocation of resources until the point where they are
really needed for rendering then it might tell a white lie when we
call glCheckFramebufferStatus() and say everything looks fine, even
though it doesn't know whether you will have enough memory available
for the buffer later. My guess a.tm is that you're Mali driver is
doing this and you are hitting a situation where in fact you don't
have enough memory and when the driver tries to really allocate your
framebuffer when something is drawn to it, it then reports an OOM
error.

I wonder if you could experimentally try modifying
cogl_framebuffer_allocate() to call cogl_framebuffer_draw_rectangle()
followed by _cogl_framebuffer_flush_journal() at the end, just to try
and provoke the Mali driver to *really* allocate the buffer. You could
then run with G_DEBUG=fatal-warnings in gdb and looking at the
backtraces verify that if you continue to see the warning
"./driver/gl/cogl-framebuffer-gl.c:1139: GL error (1285): Out of
memory" that it always happens while drawing this redundant rectangle.
If that works then we could potentially implement a Mali specific
workaround for this problem that can make sure a framebuffer is really
allocated during cogl_framebuffer_allocate().

--
kind regards,
Robert

On Sat, Oct 26, 2013 at 2:38 AM, Reza Ghassemi <reza.robin1 at gmail.com> wrote:
> Hi Clutter users,
> We are still having problems with out of memory issues when using offscreen
> effects (which use offscreen framebuffers).  The code is running on Arm Mali
> chip hardware running gles2.  What's interesting here is that you can have
> several large textures (1920x1080 and 2048x1556) on screen at once adding up
> to over 131mB before it reports out of memory errors (and only when when you
> try to transform one of them) at which point drawing failures occur. All
> these textures go into Pow2 sized atlases.  However if you have just one
> 1920x1080 image with an offscreen effect (e.g. contrast) on along with other
> plain images then it seems to fail earlier and cause drawing problems.
> Perhaps this is because the offscreen buffers are not Pow2 sized and tend to
> fragment video ram.  It seems with our device the best approach is not to
> offer the offscreen effects or restrict the size of image they are used on.
> Any comments would be appreciated.
>
>
> (.:2748): Cogl-WARNING **: ./driver/gl/cogl-framebuffer-gl.c:1139: GL error
> (1285): Out of memory
>
> Cheers,
> Reza
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
>


More information about the Cogl mailing list