3 ms·
The "right way" to do this on the GPU if you're using a monospaced console font is to have a glyph atlas, a persistently mapped text buffer, a persistently mapp
by aappleby 1y ago
The "right way" to do this on the GPU if you're using a monospaced console font is to have a glyph atlas, a persistently mapped text buffer, a persistently mapped attribute buffer, and then draw a single triangle that covers the viewport and do absolutely everything else (text map lookup, attribute lookup, glyph atlas lookup, blending/compositing) in the pixel shader.
You should be able to hit 1000 fps with most modern GPUs, and the code is fairly simple after youve got the buffers and shaders set up.
- dcrazy 1y agoFullscreen tri is not necessarily the way. If the GPU has significant penalties for rejecting fragments, or your text is sparse, you should probably use form-fitting quads or polys. Also, monospace (and implicitly, Latin) is doing a huge amount of lifting in your comment.
- aappleby 1y agoOf course, the example in the article is all monospaced console stuff. I've written a lot of text rendering over the years, everything from tiny bitmap for microcontrollers to analytically-antialiased true type based on code from some paper by Charles Loop years ago. If GPU is cheap and CPU is expensive, draw one tri every frame and don't worry about the rest. If CPU is cheap and GPU is expensive, do a glyph per quad and some basic dirty rectangles if needed.
- bschwindHN 1y agoEssentially as it's described here, right? https://www.youtube.com/watch?v=lStYLF6Us_Q&t=1472s https://www.youtube.com/watch?v=lStYLF6Us_Q&t=1472s Casey refers to it as "backwards" rendering - starting from the pixel location and determining what should be drawn there, vs. "forward" rendering where you have things you want to draw, and you determine which pixels they will be drawn in.
- Terr_ 1y ago> Casey refers to it as "backwards" rendering Sounds much like "backwards" raytracing in 3D, except with some special rules for an orthographic projection. I know that "except with" makes it sound like a narrow refinement, but I suppose the history of computer display hardware likely has it the other way around.