Earlier quoted context omitted.
The font atlas is definitely still worth it. For example: your comment, which fits in a single browser tile, is made up of 735 drawn glyphs. There are 50 distinct glyphs used (not counting italics because I'm lazy). Assuming it takes twice as long to draw a glyph into an atlas but half as long to draw it once it's in the atlas, an atlas that starts completely empty will speed up text drawing for your comment by 66% (…
The question is about amortized time-cost, though. • Most frames won't involve zooming or text-change—and therefore will be handled at "zero" time-cost by re-using the pre-composited tile. • The frames that do involve text-change (but not zoom) can benefit from font-atlasing. • The frames that involve discrete zoom , where text goes from one integral font size (represented in the atlas) to another integral font size…
Show HN: GPU text rendering with vector textures
81–90 of 91 posts
Re: Show HN: GPU text rendering with vector textures
#82Earlier quoted context omitted.
The question is about amortized time-cost, though. • Most frames won't involve zooming or text-change—and therefore will be handled at "zero" time-cost by re-using the pre-composited tile. • The frames that do involve text-change (but not zoom) can benefit from font-atlasing. • The frames that involve discrete zoom , where text goes from one integral font size (represented in the atlas) to another integral font size…
Font atlasing can and does work during pinch-to-zoom: that was the point I was trying to make. You have to generate a new atlas each time you paint, but drawing multiple "e" glyphs from an atlas is much cheaper than rasterizing each "e" individually.
I have no argument against that kind of font-atlasing as a process; it's fairly more stateless, more like a secret cache inside the black box of the glyph-rendering kernel.
Re: Show HN: GPU text rendering with vector textures
#83Earlier quoted context omitted.
There's also the higher level—the thing web browser rendering engines do, where you generate a texture for each "tile" (single-layer viewport rectangle) of likely-to-be-static text, and carry those around until you have to zoom or the text changes. I'm not sure if you need the medium-level (font atlasing) if you have both lower-level (bezier-curve atlasing), and higher-level (pre-composited "tiles.") This is one of t…
> There's also the higher level—the thing web browser rendering engines do, where you generate a texture for each "tile" (single-layer viewport rectangle) of likely-to-be-static text, and carry those around until you have to zoom or the text changes. I think this is actually a harmful approach in most cases--all it does is reduce the number of vertices and slightly reduces overdraw in exchange for a lot more memory c…
I don't think we're imagining the same things here. Think less '3D landscape with text floating in it for some reason' (e.g. SecondLife), and more '3D landscape with labels applied to it' (e.g. Google Earth). Nothing from the "VR" layer obscures the "labels" layer; the labels float above everything, as if part of the GUI, but following the same scale as the things they label.
> PDFs
I'm actually unsure why a (non-interactive) PDF page, displayed at 100% zoom, can't be baked into a single extremely-high-resolution tile—applied as a texture to a single GL rectangle with plain-old lanzcos downsampling. That'd work for the overwhelming majority of the frames.
You'd only need to re-render the tile when you zoom in enough that it'd look bad; effectively, you could think of the PDF page as coming from a mipmapped texture, but where you only have the current size and will just-in-time rerender when the zoom-factor changes. And then, when the zoom factor makes the PDF not fit on the screen, the "tile" would be the screen size—so you'd re-render sibling tiles when the user moves.
Or, in other words: PDFs can be rendered exactly the way the image tiles on a mapping website are rendered, can't they? Doesn't that approach win over re-rendering all the text from a font-atlas every frame? And if not, why do browser rendering engines use tiles? (This isn't a rhetorical question to make my point; I'm not a graphics dev and I honestly don't see why.)
Re: Show HN: GPU text rendering with vector textures
#84Earlier quoted context omitted.
> There's also the higher level—the thing web browser rendering engines do, where you generate a texture for each "tile" (single-layer viewport rectangle) of likely-to-be-static text, and carry those around until you have to zoom or the text changes. I think this is actually a harmful approach in most cases--all it does is reduce the number of vertices and slightly reduces overdraw in exchange for a lot more memory c…
> Overdraw I don't think we're imagining the same things here. Think less '3D landscape with text floating in it for some reason' (e.g. SecondLife), and more '3D landscape with labels applied to it' (e.g. Google Earth). Nothing from the "VR" layer obscures the "labels" layer; the labels float above everything, as if part of the GUI, but following the same scale as the things they label. > PDFs I'm actually unsure why…
Sure, but that uses a lot of memory, and initial pageload is going to be really slow. Especially when you consider you need to generate mipmaps if it's really high resolution, or else blow out your GPU's L1/L2 cache in FS execution.
> Doesn't that approach win over re-rendering all the text from a font-atlas every frame?
Not significantly, in my experience. Assume, in the simple case, that you're just rendering a bunch of text with no overlap. In that case, the only thing that tiles buy you over rerendering all the text from an atlas is decreased vertex count. You're still touching the same number of pixels in the FS and ROP units either way: you just do so with more vertices in the texture atlas case and fewer vertices in the tiling case. Now consider that creating and maintaining the tiles has costs over maintaining the glyph atlas (which you have to do either way): you have the memory of the tiles, the overhead of creating and switching FBOs, lots of little textures to keep around (which in naive implementations results in tons of state changes), and extra draw calls to render the tiles after rendering the content.
> why do browser rendering engines use tiles?
Mostly because it was an easy way to fit GPU-accelerated panning and zooming into the existing, originally CPU-based, rendering architectures that browser engines used (and still largely use). Tiling was popularized by Mobile Safari on the iPhone in 2007 as an easy way to avoid repainting the entire page on the CPU every frame when the user performed touch gestures. I don't think it's necessarily a globally optimal decision.
Re: Show HN: GPU text rendering with vector textures
#85Earlier quoted context omitted.
The question is about amortized time-cost, though. • Most frames won't involve zooming or text-change—and therefore will be handled at "zero" time-cost by re-using the pre-composited tile. • The frames that do involve text-change (but not zoom) can benefit from font-atlasing. • The frames that involve discrete zoom , where text goes from one integral font size (represented in the atlas) to another integral font size…
Font atlasing can and does work during pinch-to-zoom: that was the point I was trying to make. You have to generate a new atlas each time you paint, but drawing multiple "e" glyphs from an atlas is much cheaper than rasterizing each "e" individually.
Re: Show HN: GPU text rendering with vector textures
#86no subpixel rendering or hinting. Im confused - is there a problem with cpu rendered fonts that needs fixing? I didnt notice anything wrong last time I was reading schematics and datasheets on 4K monitor.
Hinting was necessary back before good antialiasing existed but I don't think many renderers use it now. This technique renders each glyph differently according to its subpixel position - completely the opposite approach to hinting, which snaps features of the glyph to integer positions on the pixel grid.
Re: Show HN: GPU text rendering with vector textures
#87Earlier quoted context omitted.
Font atlasing can and does work during pinch-to-zoom: that was the point I was trying to make. You have to generate a new atlas each time you paint, but drawing multiple "e" glyphs from an atlas is much cheaper than rasterizing each "e" individually.
Consider that each "e" may be slightly differently aligned to the pixel grid though. So using an atlas is lower quality than drawing each "e" from scratch exactly as it aligns to the screen.
Re: Show HN: GPU text rendering with vector textures
#88Earlier quoted context omitted.
The something you're missing is that we're used to see this done on the CPU, and it's not something CPUs are good at: Pages full of text rendered with scalable fonts involves either a huge number of bezier curves etc. or a huge number of small blits, though you can trade some of it off by spending huge amounts of memory pre-rendering and caching (but if you cache bitmaps at the character level, you will find it harde…
Sorry to sound like an old fart, but computers have been doing this for years, and no, caching rendered glyphs does not eat huge amounts of memory. e.g. RiscOS on ancient ARM processors, drawing sub-pixel anti-aliased text on a CPU that had no floating point. Even just 64kb of font cache to store the bitmaps could keep everything running blazingly fast. Of course, the font renderers have gotten smarter, and of course…
With the CPU, yes, but not on the GPU. The point is that we've generally been limited to doing this serially, which ties into this:
> and no, caching rendered glyphs does not eat huge amounts of memory
It does the moment your user starts to zoom rapidly in and out like in this demo and you want smooth zooming without rendering artefacts, potentially with multiple fonts, and potentially dealing with large font sizes and multi-colour fonts.
I'm an old enough fart myself to know that at least the earliest ARMs with RiscOS (as well as the Amiga's) had little enough memory/cpu bandwidth to make fast, smooth zooming of lots of text a challenge even with pre-cached font-bitmaps. And it took a long time before most systems would have enough memory to be able to treat this that casually.
> Of course, the font renderers have gotten smarter, and of course, screen resolutions have increased, but the difficulties inherent in font renderering are all at the small scale, where you want text to remain crisp even when using only a few pixels.
I've written terminal emulator code, and I've written GUI toolkit code several times, and text rendering speed on CPUs is still something that needs a lot of optimization to avoid it being a bottleneck. At small sizes you obviously can easily afford to cache, but then you end up having many more small blits - the overhead is still painful but for different reasons. E.g. intelligently blitting the existing window content to minimize re-rendering tends to be a major speedup vs. re-rendering every glyph even with fixed width bitmap fonts.
Re: Show HN: GPU text rendering with vector textures
#89Earlier quoted context omitted.
I don't know why you are being downvoted, that is what is happening and I am not convinced that straight textures would be better. We already know that SDF textures are better than straight texture atlases anyway. The technique is obviously practical in some respect (since it renders a pdf faster than anything else I've seen) and the quality of the text is very sharp, even close up. Super sharp lines when zoomed in m…
> We already know that SDF textures are better than straight texture atlases anyway. This is isn't true. SDF textures can be "better" for "some" applications (like games that want to display stencils mostly at arbitrary zoom levels without losing a lot of quality) but they're also visibly lower-quality compared to glyphs rendered by freetype at each one of these zoom levels. So, for an application that simply display…
Re: Show HN: GPU text rendering with vector textures
#90Earlier quoted context omitted.
Sorry to sound like an old fart, but computers have been doing this for years, and no, caching rendered glyphs does not eat huge amounts of memory. e.g. RiscOS on ancient ARM processors, drawing sub-pixel anti-aliased text on a CPU that had no floating point. Even just 64kb of font cache to store the bitmaps could keep everything running blazingly fast. Of course, the font renderers have gotten smarter, and of course…
> Sorry to sound like an old fart, but computers have been doing this for years With the CPU, yes, but not on the GPU. The point is that we've generally been limited to doing this serially, which ties into this: > and no, caching rendered glyphs does not eat huge amounts of memory It does the moment your user starts to zoom rapidly in and out like in this demo and you want smooth zooming without rendering artefacts,…
Well yes, that'll wipe out the cache hit rate, but when has the use case of 'zooming rapidly in and out of text' ever been a particular point on contention for any application? Even the original iphone's web zoom was good enough, a smooth zoom with temporarily blurry text until you pick a good zoom point. Seems like a very obscure niche functionality to optimise, one where no-one apparently cares about right now.
I'm an old enough fart myself to know that at least the earliest ARMs with RiscOS (as well as the Amiga's) had little enough memory/cpu bandwidth to make fast, smooth zooming of lots of text a challenge even with pre-cached font-bitmaps.
True enough! I can't even think of any app that had smooth zooming... most apps had a zoom factor (e.g. x1, x2, etc) that would work perfectly with a font cache. The main crunch point was the simple, intelligent, partial rendering of text as you pan around a page.
At small sizes you obviously can easily afford to cache, but then you end up having many more small blits
Going back to my nostalgia for RiscOS, I wrote a dumb anti-aliased font renderer that would draw fonts dot-by-dot rather than by blitting a 2d transparent bitmap to the screen, it turned out to be massively faster than even a simple cached bitmap font renderer, even at larger sizes. Definitely not a good approach today with higher-res screens though... (and the storage format was massively wasteful at larger sizes)
Terminal text rendering is a bone of contention for me, as it's frustrating how some modern-day terminals can be utterly appalling at doing their job (e.g. typing 'dmesg' and having to wait several seconds for it to complete), so I'm all in favour of anyone who takes an interest in making it fast. Most terminals unfortunately seem to try and redraw every new line to the screen, rather than realising that they've got another 10000 lines to print and perhaps the user might be content with a (say) 30fps update interval...