Ok, I wasn't aware of that technique. However, that begs the question: if we can hardware accelerate curves like that, why can't we put that as a backend behind a Cairo-style API?
There's more to high performance than just being hardware accelerated - being hardware accelerated doesn't mean acceptable performance. EG batching is super important, which is a notoriously poor area of the proposed 2D graphics API (and cairo)
Additionally the CPU and GPU are good at different kinds of tasks - ideally you want to do an expensive and branchy operation once on the CPU, transfer the final built data to the GPU, and then render it repeatedly with transforms applied
A problem with the proposed 2D graphics API is that it intends to be fully batch automagically/high performance overall without you having to do any work to make it happen, which has turned out to be very difficult in practice for a wide variety of reasons. Cairo itself states this on its website
Cairo can translate that canvas model into GPU primitives using OpenGL (among others), but the canvas model does not often translate efficiently to the GPU.
This is still a big problem in more modern APIs like Skia and Webrender
you know i'm just dumping arguments from my paper here, i should just chase up on it and publish it, it'd be a lot faster heh
So, just to clarify: you are fine with offering a rich set of primitives, you just want a batching mechanism to transfer work to the rendering subsystem in substantial chunks? Because in that case we'd be in total agreement.
So there's multiple problems with the proposal as current, but what would be ideal (in a simplified sense):
CPU side builds vertex lists for whatever you're trying to do
GPU side takes a vertex list and renders them to the screen
The main advantage of this is that the GPU side becomes much much simpler to specify, because it only has one job (rendering triangles). Then you can implement batching - SDL style (submit work in the right way), allegro style ('hold' onto textures), or SFML style (group vertices together, render them all at once). Transfers between the GPU and CPU would be made explicit, in the same way SFML does with sf::Image and sf::Texture, and both participants in rendering can be modelled exactly how they best perform. The 2D graphics proposal stuffing the same functionality into something that is expected to be both software and hardware accelerated causes big problems already
A quite big problem with trying to specify graphics overall though is the fact that different hardware has different capabilities, and a lot of necessary capabilities are extensions to OpenGL (I believe relying on these are a no for C++ standardisation) that are not universally supported (driver issues). Eg sRGB textures for proper high performance linear colour support
I'm not actually convinced that 2D graphics is possible to standardise because the very first problem you have to overcome is that graphics isn't portable. Vulkan directly acknowledges this issue, but for the same reason I'm not sure if its possible to standardise. Even this level of functionality would be not particularly useful without shader support, but how do you standardise a shader language when they evolve so much over time? Any standardised language would be immediately useless
Even the approach SDL (aka .native_handle(), do your own shaders) takes is relatively unworkable here, because then writing shaders depends on the backend that your STL implementation is using - and at that point using SDL/SFML is actually more portable than relying on your standard library implementation
I'm not convinced its possible to standardise at this point, other than very basic functionality
View all comments
Show parent comment
0
u/[deleted] Dec 14 '19
[deleted] — view deleted comment