If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Fog: A High-Performance Alternative To Cairo

03-04-2012, 08:00 AM

Phoronix: Fog: A High-Performance Alternative To Cairo

While Cairo gets much of the spotlight when it comes to a 2D vector graphics drawing library, there's another open-source project that claims to provide even faster performance and greater benefits; meet the Fog-Framework...

The multi-threaded capablities have been long desired, but improvements to cairo-image pale in significance to enabling GPU acceleration. However, judging from those results there are a few areas where we can easily improve cairo, but overall it appears cairo is in relatively good shape.

Comment

and why is it we cannot just go to using straight openvg? it sure seems wasteful to keep coming up with 2d vector graphics replacements for cario when in the end they will all just be wrappers around a way to accelerate them with the gpu. (openvg, opengl, gallium3d)

Comment

Is it? Afaik, no graphics framework in multithreaded since generic thread safety incurs too much a performance penalty. "Multithreaded" in the context of graphics frameworks usually means that it supports (and in some places requires) the use of multiple threads.
Nitpicking aside, good for them!

Comment

Is it? Afaik, no graphics framework in multithreaded since generic thread safety incurs too much a performance penalty. "Multithreaded" in the context of graphics frameworks usually means that it supports (and in some places requires) the use of multiple threads.
Nitpicking aside, good for them!

If you have any real sense of how to do proper high performance multithreading, there usually isn't much thread safety overhead. Larger batches distributed to a task-based thread-pool in a "shared nothing" architecture works really well. If done right it requires no synchronization primitives of any kind besides the task management bits (which only incur overhead on a thread when they're not processing a task). That is, after all, exactly what a GPU does.

A lot of people got into threading with Java, which teaches you to thread _everything_ and then synchronize the hell out of every data structure. That's awful, and wrong. If you're looking to reduce latency for event handling (e.g., handling network sockets), then use an event-based API. If you're looking to utilize all cores in today's multicore CPUs, then don't do something as silly as adding a ton of chokepoints and potential deadlocks to your code.

In the case of a 2D/3D renderer, there are many opportunities for threading. Path tessellation, region tessellation, gradient generation, programmable shaders, blitting large buffers, color conversion and blending... all of these are data-intensive operations that can easily be broken into separate independent chunks, farmed out to a number of threads, and the results processed with little to no extra work. The operation that's blending the pixel at (20,35) is not dependent on the operation blending the pixel at (10,23), after all. They can both be done in parallel, with absolutely no need to add any locking or atomic synchronization operations. The only thing to be careful of is the memory architecture of the host system (where cache line boundaries are, and which addresses in memory can be safely modified on different hardware threads without contention or data races; this is all well-documented and very easy to deal with, though).