1. Anders Ruud
  2. love
  3. Issues

Issues

Issue #532 resolved

Text drawing performance improvements

Alex Szpakowski
created an issue

The current method of drawing text with love.graphics.print involves calling a separate display list for every single glyph rendered, which is very inefficient.

I have attached a patch which changes the OpenGL font rendering code to use a single vertex array for each string printed, greatly improving performance when drawing text.

The new code also makes a guesstimate of how much texture space a font's glyphs will take up, and uses an appropriate texture size (between 128x128 and 1024x1024), instead of always using a fixed size of 512x512 per glyph texture sheet. Combined with the fact that it uses OpenGL's luminance-alpha internal texture format for TTF fonts (the original code was using this format to store the font in RAM, but converted it to full 32-bit RGBA when moving it to VRAM), most fonts now take up much less VRAM space on the GPU.

The default font with the default font size loads a texture which takes up only 3% of the VRAM space with the new code compared to standard 0.8.0.

I have also attached a small test .love that shows text drawing performance in a couple of extreme use cases. 'T' toggles all text on/off, and any other key switches between font size 12 and size 70.

Using my Intel HD 3000 with the attached .love, I get

  • ~1.4ms with no text drawn

  • 2.05ms with standard 0.8.0 and the large font

  • 17ms with standard 0.8.0 and the small font

  • 1.47ms with the new drawing method and the large font

  • 2.65ms with the new drawing method and the small font

Comments (4)

  1. Log in to comment