[pango-display-list] Use the Cogl journal for short runs of text
For small runs of text like icon labels, we can get better performance going through the Cogl journal since text may then be batched together with other geometry. For larger runs of text though we still use VBOs since the cost of logging the quads becomes too expensive, including the software transform which isn't at all optimized at this point. VBOs also have the further advantage of avoiding repeated validation of vertices by the driver and repeated mapping of data into the GPU so long as the text doesn't change. Currently the threshold is 100 vertices/25 quads. This number was plucked out of thin air and should be tuned later. With this change I see ~180% fps improvment for test-text. (x61s + i965 + Mesa 7.6-devel)
This commit is contained in:
parent
6ac3b5a564
commit
6562f3224a
@ -244,6 +244,39 @@ _cogl_pango_display_list_render_texture (CoglHandle material,
|
||||
cogl_material_set_color (material, &premult_color);
|
||||
cogl_set_source (material);
|
||||
|
||||
/* For small runs of text like icon labels, we can get better performance
|
||||
* going through the Cogl journal since text may then be batched together
|
||||
* with other geometry. */
|
||||
/* FIXME: 100 is a number I plucked out of thin air; it would be good
|
||||
* to determine this empirically! */
|
||||
if (node->d.texture.verts->len < 100)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < node->d.texture.verts->len; i += 4)
|
||||
{
|
||||
CoglPangoDisplayListVertex *v0 =
|
||||
&g_array_index (node->d.texture.verts,
|
||||
CoglPangoDisplayListVertex, i);
|
||||
CoglPangoDisplayListVertex *v1 =
|
||||
&g_array_index (node->d.texture.verts,
|
||||
CoglPangoDisplayListVertex, i + 2);
|
||||
cogl_rectangle_with_texture_coords (v0->x, v0->y, v1->x, v1->y,
|
||||
v0->t_x, v0->t_y,
|
||||
v1->t_x, v1->t_y);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* It's expensive to go through the Cogl journal for large runs
|
||||
* of text in part because the journal transforms the quads in software
|
||||
* to avoid changing the modelview matrix. So for larger runs of text
|
||||
* we load the vertices into a VBO, and this has the added advantage
|
||||
* that if the text doesn't change from frame to frame the VBO can
|
||||
* be re-used avoiding the repeated cost of validating the data and
|
||||
* mapping it into the GPU... */
|
||||
|
||||
if (node->d.texture.vertex_buffer == COGL_INVALID_HANDLE)
|
||||
{
|
||||
CoglHandle vb = cogl_vertex_buffer_new (node->d.texture.verts->len);
|
||||
|
Loading…
Reference in New Issue
Block a user