4 ms·
This is using FreeType to CPU render to a text atlas, to be clear.
by krona 5y ago
This is using FreeType to CPU render to a text atlas, to be clear.
- deathanatos 5y agoBut is this wrong? I think the current implementation might have some bugs, but why not create an atlas? Especially for code, most of the characters will be in ASCII, and if they're not, you can always push what isn't dynamically as needed. Most of the rendering still occurs GPU side. I suspect the post's code is also cheating on shaping, but even that seems like something you should be able to at least cache on the GPU? Like the 98% of cases, the GPU, and if for the 2% oddball stuff, the CPU needs to step in, so what? (Edit: perhaps I'm projecting the "wrong" part onto your comment; there's a lot of "why?" in these comments and the more I think about it, it honestly seems pretty sensible to push graphics to the *G*PU.)
- krona 5y agoI'm just commenting on the extent to which it is 'GPU-rendered', which in this case is apparently no more than a standard text rendering facilities provided by the OS. That's not to say it's not impressive considering how simple it is.
- dahart 5y agoIsn’t that how more or less all editors render text, on the GPU and on the CPU?
- Pulcinella 5y agoIt’s possible to perform the rendering of the font itself on the GPU (e.g. Pathfinder) instead of rendering an atlas on the CPU and sending it over to the GPU, but I’m not sure of any text editors that do so.
- dahart 5y agoOf course, it’s definitely possible. Just doesn’t seem like there are good reasons to spend time directly rendering the same font characters repeatedly, right? That’d be spending a lot of compute doing something you can pre-render and cache in a texture. ;) This is why a lot of CPU implementations render text atlases too.
- Pulcinella 5y agoI suppose you could also pre-render to an atlas on the GPU. I would also say, personally, there is something aesthetically pleasing about rendering vector graphics (fonts, SVG, etc.) on the GPU. “It’s a graphics processing unit, shouldn’t it be handling vector graphics as well?!” :)
- dahart 5y agoTotally, you could. But in the case of a text editor, that would probably be purely to flex and not because it’s faster or better or easier, right? People are definitely doing tons of vector rendering on the GPU. And the GPU is fantastic for vector graphics generally, mainly still because of the conversion to pixels. I posted links to Hughes Hoppe’s paper and the NV path rendering library, for example. Those can do font rendering as well, but I still wouldn’t use those for rendering fonts directly or for rendering text atlases because it would be difficult to implement.
- Vogtinator 5y agoYep, that's basically what glyph caches do.
- liz3_de 5y agoFreeType Renders a atlas which is then uploaded to the gpu within the ascii range, other characters are then lazy loaded into the buffer