[cairo] Reducing GL context switches

Martin Robinson mrobinson at igalia.com
Tue Feb 28 14:55:44 PST 2012


Recently I've been experimenting with ways to reduce unnecessary context
switches in the GL backend. Based on input from Henry Song and Chris
Wilson I've written two patches at:

https://github.com/mrobinson/cairo/tree/reduce-context-switches

1. This patch adds two new APIs, cairo_glx_device_set_thread_aware and
cairo_egl_device_set_thread_aware. When a device sets "thread-aware" to
false, it simply does not release the context after painting. This
should work well for applications that do not try to access the same
OpenGL context from different threads.

2. The second patch tracks what context was active upon activating
Cairo's painting context. After painting, it restores the previously
active context or, if no change took place, does nothing. I think this
improves Cairo's current behavior because it makes a Cairo paint
slightly more "invisible."

I'd love to get some feedback on these patches. They are both pretty
simple. I've tested them locally with seemingly no regressions.

--Martin


More information about the cairo mailing list