diff options
author | Bryce Harrington <b.harrington@samsung.com> | 2013-08-19 19:38:26 -0700 |
---|---|---|
committer | Bryce Harrington <bryce@osg.samsung.com> | 2014-09-19 17:23:50 -0700 |
commit | 036f47c34579259fa86d0193797b6f83fe79bbeb (patch) | |
tree | ab866f6edc386e5f14d72e3810d1d9ebdc6a5c58 | |
parent | 8479b6086710e11c81c0059ffc5fa6a71d14256c (diff) | |
download | cairo-036f47c34579259fa86d0193797b6f83fe79bbeb.tar.gz |
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>
-rw-r--r-- | src/cairo-gl-composite.c | 2 | ||||
-rw-r--r-- | src/cairo-gl-device.c | 2 | ||||
-rw-r--r-- | src/cairo-gl-info.c | 22 | ||||
-rw-r--r-- | src/cairo-gl-private.h | 8 |
4 files changed, 30 insertions, 4 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 30b793130..65b0f26bb 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -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); } diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 054f1452f..dc2b6d6ec 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -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); diff --git a/src/cairo-gl-info.c b/src/cairo-gl-info.c index 12a618da0..c47033ecd 100644 --- a/src/cairo-gl-info.c +++ b/src/cairo-gl-info.c @@ -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) { diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 8379abc95..79b67a5d2 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -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); |