such an unfortunate state of affairs!
i am currently learning how to render graphics using the GPU on my mac using apple metal. what i am getting is that the GPU has been optimized for 3D rendering?! GPUs make no provision or easy way for rendering 2D graphics?
it makes no sense to me... that's where you start...
And: historically they've been computed mostly on CPU, but I think it's time for that to change.
At any rate, the 2D graphics we expect now are a lot more complex than the unantialiased lines, blits, and fills of old.
It would be great to wait a bit for OS & GPU power management to evolve before biting the bullet on that. My laptop goes from 6 to 2.something hours of battery as soon as I have a GL context opening somewhere, likely because it seems to power on its discrete GPU automatically in that case.
maybe ? the computer on which this happens is a 1070. But please be aware that series 10 are a very small percentage of people. The average laptop of non-tech people around me is easily 8 years old, often on their 2nd or 3rd battery... and these people won't be able to complain easily to anyone when their new battery's life suddenly is halved because of $SOFTWARE.
1) tricky to shoehorn 2D graphics onto the APIs that GPUs provide and
2) really not needed. I can easily render eg: a world map with hundreds of thousands of lines at hundreds of frames/second with one core.The various libraries such as freetype for font rastrization only works on CPU.
Plenty of work should be done to research and implementation is left to be done in order to use the GPU more widely.
Of course CPU rendering is always more straightforward than GPU, the higher performance comes at a significant cost in complexity.
as far as i understand, 2d and 3d have literally zero to do with each other in how they are rendered. one is a bunch of triangles. the other is lines, curves, thickness, gradients, and fonts (which are essentially little programs)
You can reduce all these to drawing triangles.
You can, people have tried this, and it sucks. The main problem is that the conversion of Bézier paths to triangles is a hard problem with lots of conditional branching. Even when you do it, there is the other problem of rendering triangles with really good antialiasing, MSAA forces a compromise between performance and quality. By contrast, piet-gpu does an exact-area calculation for antialiasing.
So it's not a question of whether you can do it, but whether it works well, and approaches like piet-gpu absolutely stomp triangles.
Easier than you think. Here's couple lines of pixel shader that does that, with really good antialiasing and without MSAA:
https://github.com/Const-me/Vrmac/blob/master/Vrmac/Draw/Sha...
Raph is describing an architecture where path evaluation happens on the GPU, without being baked to triangles.
In the meantime, antigrain.com is one good (if old) source. The original PostScript "red book" was extremely influential in its time (it's where I learned a lot of this stuff) but is quite dated now. Best of luck, and I'm also happy to field requests for more specific areas. For example, for color theory (an important aspect of 2D graphics!), handprint.com is quite a remarkable resource.