From b26ddda12fe7dbb6a4e6af3b47c1e837cc7ebb03 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 3 Feb 2016 09:35:42 -0700 Subject: mesa: implement a display list / glBitmap texture atlas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This improves the performance of applications which use glXUseXFont() or wglUseFontBitmaps() and glCallLists() to draw bitmap text. Basically, we collect all the glBitmap images from the display lists and put them into a texture atlas. To render the bitmaps for a glCallLists() command, we render a set of textured quads where each quad is textured with one bitmap image. Actually, the rendering part has to be done by the Mesa driver or Mesa/gallium state tracker. Note that GLUT demos that use glutBitmapCharacter() don't benefit from this. v2, per Nicolai Hähnle: - check the max tex rect size is at least 1024. - add comment in dd.h that texture_rectangle is required. - in _mesa_DeleteLists(), try to delete the atlas before the list(s) Reviewed-by: Nicolai Hähnle --- src/mesa/main/dlist.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/mesa/main/dlist.h') diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index 7a23208ba5a..22b696f50c1 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -36,6 +36,44 @@ #include "main/mtypes.h" +/** + * Describes the location and size of a glBitmap image in a texture atlas. + */ +struct gl_bitmap_glyph +{ + unsigned short x, y, w, h; /**< position and size in the texture */ + float xorig, yorig; /**< bitmap origin */ + float xmove, ymove; /**< rasterpos move */ +}; + + +/** + * Describes a set of glBitmap display lists which live in a texture atlas. + * The idea is when we see a code sequence of glListBase(b), glCallLists(n) + * we're probably drawing bitmap font glyphs. We try to put all the bitmap + * glyphs into one texture map then render the glCallLists as a textured + * quadstrip. + */ +struct gl_bitmap_atlas +{ + bool complete; /**< Is the atlas ready to use? */ + bool incomplete; /**< Did we fail to construct this atlas? */ + + unsigned numBitmaps; + unsigned texWidth, texHeight; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + unsigned glyphHeight; + + struct gl_bitmap_glyph *glyphs; +}; + +void +_mesa_delete_bitmap_atlas(struct gl_context *ctx, + struct gl_bitmap_atlas *atlas); + + GLboolean GLAPIENTRY _mesa_IsList(GLuint list); -- cgit v1.2.3