summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shared.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2016-02-03 09:35:42 -0700
committerBrian Paul <brianp@vmware.com>2016-02-17 19:57:48 -0700
commitb26ddda12fe7dbb6a4e6af3b47c1e837cc7ebb03 (patch)
treea220397fcbea69d3e6dea7e0eece28186c82a7ba /src/mesa/main/shared.c
parent6f4a725073fcef6b7b5a7b9acdc99539fa3fa1f4 (diff)
downloadexternal_mesa3d-b26ddda12fe7dbb6a4e6af3b47c1e837cc7ebb03.zip
external_mesa3d-b26ddda12fe7dbb6a4e6af3b47c1e837cc7ebb03.tar.gz
external_mesa3d-b26ddda12fe7dbb6a4e6af3b47c1e837cc7ebb03.tar.bz2
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>
Diffstat (limited to 'src/mesa/main/shared.c')
-rw-r--r--src/mesa/main/shared.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index b9f7bb6..49e5f02 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -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();
@@ -144,6 +145,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().
*/
static void
@@ -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);