4 ms·
always appreciate raph's work on rendering and UI programming, but want to ask a somewhat unrelated question to this post: does anyone have a lot of experience
by slmjkdbtl 6y ago
always appreciate raph's work on rendering and UI programming, but want to ask a somewhat unrelated question to this post: does anyone have a lot of experience doing 2d graphics on the cpu? i wonder if there'll be a day we're confident doing all 2d stuff on the cpu since cpus are much easier to work with and have much more control, i also read some old 3d games are also using software rendering and did well on old hardwares, that gave me a lot of confidence in software render every (lowrez) thing
- Jasper_ 6y agoYes? We know how to write scanline renderers for 2D graphics. They're not that hard, a simple one can be done in ~100 lines of code or so, see my article here https://magcius.github.io/xplain/article/rast1.html https://magcius.github.io/xplain/article/rast1.html
- slmjkdbtl 6y agoTanks for the amazing article! I wonder if you met any performance annoyances / bottlenecks when doing actual GUI / game dev with this?
- iainmerrick 6y agoYou just need to render your font on the CPU once, and upload mipmaps to the GPU (either signed distance fields, or just sharpened textures, that works absolutely fine too). I think all this GPU font rendering stuff is a bit of a red herring. Are any popular apps or games actually making heavy use of it?
- olau 6y agoEnjoyable article, thanks!
- bumbada 6y agoI have lots of experience, created several font renderers in the CPU and GPU. No, doing CPU drawing is too inefficient. Without too much trouble you get 50x more efficiency in the GPU, that is, you can draw 50frames per every frame in the CPU, using the same amount of energy and time. If you go deeper, low level with Vulkan-Metal and specially control the GPU memory, you can get 200x, being way harder to program. CPU drawing is very useful for testing: You create the reference you compare the GPU stuff with. CPU drawing is the past, not the future.
- slmjkdbtl 6y agoThanks for the write up. Yeah i can see the huge performance difference, one thing that GPU bothers me is now every vendor provides a different set of API, you kinda have to use a hardware abstraction layer to use the GPU if you really want cross platform, and that's often a huge effort or dependency and hard to do right, even in OpenGL days it's easy because you only have to deal with one API instead of three vulkan/metal/d3d. With CPU if ignore the performance lack it's just a plain pixel array that can be easily displayed on any environment and you have control over any bits of it, I just can't get over the lightness and elegance difference between the two..
- bumbada 6y agoVulkan/metal/d3d give you control to do things you could not do with OpenGL, and they are very similar. All my code works first in Vulkan and Metal, but d3d is not hard when you have your vulkan code working. OpenGL was designed by committee and politics(like not giving you the option to compile shaders for a long time while d3d could do it). The hard part is thinking in term extreme parallelism. That is super hard. Once you have something working in the GPU, you can translate it to electronics like using FPGAs. The difference in efficiency is so big, that most GPU approaches do not really work. They are really approximations that fail with certain glyphs. Designers create a model that works with most glyphs, and sometimes they have a fallback, inefficient method for them. With the CPU you can calculate the area under a pixel exactly.
- pjmlp 6y ago> OpenGL was designed by committee and politics Vulkan is exactly designed the same way, by the same people. I already lost track of the extensions, and the joke it is post Vulkan 1.0 to configure everything, to the point a graphical configuration tool is required to ease the process.
- fulafel 6y agoThe future is now: on many systems there's fairly little GPU acceleration going on when runing eg a web browser and things work fine.