mesa: implement a display list / glBitmap texture atlas

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 <nicolai.haehnle@amd.com>
This commit is contained in:
Brian Paul
2016-02-03 09:35:42 -07:00
parent 6f4a725073
commit b26ddda12f
5 changed files with 448 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
mtx_init(&shared->Mutex, mtx_plain);
shared->DisplayList = _mesa_NewHashTable();
shared->BitmapAtlas = _mesa_NewHashTable();
shared->TexObjects = _mesa_NewHashTable();
shared->Programs = _mesa_NewHashTable();
@@ -143,6 +144,18 @@ delete_displaylist_cb(GLuint id, void *data, void *userData)
}
/**
* Callback for deleting a bitmap atlas. Called by _mesa_HashDeleteAll().
*/
static void
delete_bitmap_atlas_cb(GLuint id, void *data, void *userData)
{
struct gl_bitmap_atlas *atlas = (struct gl_bitmap_atlas *) data;
struct gl_context *ctx = (struct gl_context *) userData;
_mesa_delete_bitmap_atlas(ctx, atlas);
}
/**
* Callback for deleting a texture object. Called by _mesa_HashDeleteAll().
*/
@@ -309,6 +322,8 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
*/
_mesa_HashDeleteAll(shared->DisplayList, delete_displaylist_cb, ctx);
_mesa_DeleteHashTable(shared->DisplayList);
_mesa_HashDeleteAll(shared->BitmapAtlas, delete_bitmap_atlas_cb, ctx);
_mesa_DeleteHashTable(shared->BitmapAtlas);
_mesa_HashWalk(shared->ShaderObjects, free_shader_program_data_cb, ctx);
_mesa_HashDeleteAll(shared->ShaderObjects, delete_shader_cb, ctx);