cairo-gl: Make VBO size run-time settable

The default VBO size was reduced from 256k to 16k last year in commit
90860241 due to problems with larger VBOs on embedded hardware.
However, that change resulted in a 5% performance impact to the
firefox-fishbowl benchmark when using the spans or traps compositors.

This patch doesn't change the VBO size, but does permit it to be
altered via an environment variable, to facilitate testing.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
Bryce Harrington 2013-08-19 19:38:26 -07:00 committed by Bryce Harrington
parent 8479b60867
commit 036f47c345
4 changed files with 30 additions and 4 deletions

View file

@ -875,7 +875,7 @@ _cairo_gl_composite_prepare_buffer (cairo_gl_context_t *ctx,
ctx->primitive_type = primitive_type;
}
if (ctx->vb_offset + n_vertices * ctx->vertex_size > CAIRO_GL_VBO_SIZE)
if (ctx->vb_offset + n_vertices * ctx->vertex_size > _cairo_gl_get_vbo_size())
_cairo_gl_composite_flush (ctx);
}

View file

@ -297,7 +297,7 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
if (unlikely (status))
return status;
ctx->vb = malloc (CAIRO_GL_VBO_SIZE);
ctx->vb = malloc (_cairo_gl_get_vbo_size());
if (unlikely (ctx->vb == NULL)) {
_cairo_cache_fini (&ctx->gradients);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

View file

@ -29,6 +29,8 @@
* Alexandros Frantzis <alexandros.frantzis@linaro.org>
*/
#include <errno.h>
#include "cairoint.h"
#include "cairo-gl-private.h"
@ -71,6 +73,26 @@ _cairo_gl_get_flavor (void)
return flavor;
}
long
_cairo_gl_get_vbo_size (void)
{
static long vbo_size = -1;
if (vbo_size < 0) {
const char *env = getenv ("CAIRO_GL_VBO_SIZE");
if (env == NULL) {
vbo_size = CAIRO_GL_VBO_SIZE_DEFAULT;
} else {
errno = 0;
vbo_size = strtol (env, NULL, 10);
assert (errno == 0);
assert (vbo_size > 0);
}
}
return vbo_size;
}
cairo_bool_t
_cairo_gl_has_extension (const char *ext)
{

View file

@ -93,8 +93,9 @@
/* VBO size that we allocate, smaller size means we gotta flush more often,
* but larger means hogging more memory and can cause trouble for drivers
* (especially on embedded devices). */
#define CAIRO_GL_VBO_SIZE (16*1024)
* (especially on embedded devices). Use the CAIRO_GL_VBO_SIZE environment
* variable to set this to a different size. */
#define CAIRO_GL_VBO_SIZE_DEFAULT (16*1024)
typedef struct _cairo_gl_surface cairo_gl_surface_t;
@ -702,6 +703,9 @@ _cairo_gl_get_version (void);
cairo_private cairo_gl_flavor_t
_cairo_gl_get_flavor (void);
cairo_private long
_cairo_gl_get_vbo_size (void);
cairo_private cairo_bool_t
_cairo_gl_has_extension (const char *ext);