[cairo-commit] 4 commits - boilerplate/cairo-boilerplate-vg.c perf/cairo-perf-print.c perf/Makefile.am src/cairo-gl-surface.c
Chris Wilson
ickle at kemper.freedesktop.org
Thu Jul 23 07:33:39 PDT 2009
boilerplate/cairo-boilerplate-vg.c | 19 ++++-----
perf/Makefile.am | 8 +++-
perf/cairo-perf-print.c | 72 +++++++++++++++++++++++++++++++++++++
src/cairo-gl-surface.c | 49 +++++++++++++++++++------
4 files changed, 124 insertions(+), 24 deletions(-)
New commits:
commit f5a1cdf283a6aa1f4409ccbf3c2274fb587724fe
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Jul 23 14:46:16 2009 +0100
[gl] Simplify the common CLEAR of a surface
Almost every surface is at sometime cleared, so catch the operation in
paint(), and emit a simple glClear() instead.
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index a591594..571fc96 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1861,6 +1861,29 @@ _cairo_gl_surface_get_font_options (void *abstract_surface,
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
}
+
+static cairo_int_status_t
+_cairo_gl_surface_paint (void *abstract_surface,
+ cairo_operator_t op,
+ const cairo_pattern_t *source,
+ cairo_clip_t *clip)
+{
+ /* simplify the common case of clearing the surface */
+ if (op == CAIRO_OPERATOR_CLEAR && clip == NULL) {
+ cairo_gl_surface_t *surface = abstract_surface;
+ cairo_gl_context_t *ctx;
+
+ ctx = _cairo_gl_context_acquire (surface->ctx);
+ _cairo_gl_set_destination (surface);
+ glClear (GL_COLOR_BUFFER_BIT);
+ _cairo_gl_context_release (ctx);
+
+ return CAIRO_STATUS_SUCCESS;
+ }
+
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+}
+
static const cairo_surface_backend_t _cairo_gl_surface_backend = {
CAIRO_SURFACE_TYPE_GL,
_cairo_gl_surface_create_similar,
@@ -1886,7 +1909,7 @@ static const cairo_surface_backend_t _cairo_gl_surface_backend = {
NULL, /* mark_dirty_rectangle */
NULL, /* scaled_font_fini */
NULL, /* scaled_glyph_fini */
- NULL, /* paint */
+ _cairo_gl_surface_paint,
NULL, /* mask */
NULL, /* stroke */
NULL, /* fill */
commit eed17527f62eab826af65258b60cd4545a71a22d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Jul 23 14:30:46 2009 +0100
[gl] Do not use unchecked GL v1.5 features
The span renderer uses ARB_vertex_buffer_object which was included into
the core as part of OpenGL 1.5. We failed to check for the required version
during initialisation, and to my surprise the i915 can only support OpenGL
1.4 as it lacks ARB_occlusion_query. So just use the ARB extension instead
which is present on i915.
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index c3b4231..a591594 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -118,16 +118,18 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
CAIRO_REFERENCE_COUNT_INIT (&ctx->ref_count, 1);
CAIRO_MUTEX_INIT (ctx->mutex);
- if (glewInit () != GLEW_OK) {
+ if (glewInit () != GLEW_OK)
return _cairo_error (CAIRO_STATUS_INVALID_FORMAT); /* XXX */
- }
- if (! GLEW_EXT_framebuffer_object ||
+ if (! GLEW_ARB_vertex_buffer_object ||
+ ! GLEW_EXT_framebuffer_object ||
! GLEW_ARB_texture_env_combine ||
! GLEW_ARB_texture_non_power_of_two)
{
fprintf (stderr,
"Required GL extensions not available:\n");
+ if (! GLEW_ARB_vertex_buffer_object)
+ fprintf (stderr, " GL_ARB_vertex_buffer_object\n");
if (! GLEW_EXT_framebuffer_object)
fprintf (stderr, " GL_EXT_framebuffer_object\n");
if (! GLEW_ARB_texture_env_combine)
@@ -1547,7 +1549,7 @@ _cairo_gl_span_renderer_flush (cairo_gl_surface_span_renderer_t *renderer)
if (renderer->vbo_offset == 0)
return;
- glUnmapBuffer (GL_ARRAY_BUFFER_ARB);
+ glUnmapBufferARB (GL_ARRAY_BUFFER_ARB);
glDrawArrays (GL_LINES, 0, renderer->vbo_offset / renderer->vertex_size);
renderer->vbo_offset = 0;
}
@@ -1560,8 +1562,8 @@ _cairo_gl_span_renderer_get_vbo (cairo_gl_surface_span_renderer_t *renderer,
if (renderer->vbo == 0) {
renderer->vbo_size = 16384;
- glGenBuffers (1, &renderer->vbo);
- glBindBuffer (GL_ARRAY_BUFFER_ARB, renderer->vbo);
+ glGenBuffersARB (1, &renderer->vbo);
+ glBindBufferARB (GL_ARRAY_BUFFER_ARB, renderer->vbo);
if (renderer->setup.src.type == OPERAND_TEXTURE)
renderer->vertex_size = 4 * sizeof (float) + sizeof (uint32_t);
@@ -1591,10 +1593,10 @@ _cairo_gl_span_renderer_get_vbo (cairo_gl_surface_span_renderer_t *renderer,
if (renderer->vbo_offset == 0) {
/* We'll only be using these vertices once. */
- glBufferData (GL_ARRAY_BUFFER_ARB, renderer->vbo_size, NULL,
+ glBufferDataARB (GL_ARRAY_BUFFER_ARB, renderer->vbo_size, NULL,
GL_STREAM_DRAW_ARB);
- renderer->vbo_base = glMapBuffer (GL_ARRAY_BUFFER_ARB,
- GL_WRITE_ONLY_ARB);
+ renderer->vbo_base = glMapBufferARB (GL_ARRAY_BUFFER_ARB,
+ GL_WRITE_ONLY_ARB);
}
offset = renderer->vbo_offset;
@@ -1721,8 +1723,8 @@ _cairo_gl_surface_span_renderer_finish (void *abstract_renderer)
_cairo_gl_span_renderer_flush (renderer);
- glBindBuffer (GL_ARRAY_BUFFER_ARB, 0);
- glDeleteBuffers (1, &renderer->vbo);
+ glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0);
+ glDeleteBuffersARB (1, &renderer->vbo);
glDisableClientState (GL_VERTEX_ARRAY);
glDisableClientState (GL_COLOR_ARRAY);
commit 6c28c7a1e268fad0ad34cac0d8a9a3951d8f3c7a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Jul 23 08:45:58 2009 +0100
[perf] Add a simple report printer.
After a run, it can be useful to reprint the results, so add
cairo-perf-print to perform that task.
For the future, I'd like to move the performance suite over to the
git/perf style of single, multi-function binary.
The sequence of operations that I typically do are:
./cairo-perf-trace -r -v -i 6 > `git describe`.`hostname`.perf
./cairo-perf-diff-files REVA REVB
./cairo-perf-print REVA
./cairo-perf-compare-backends REVA
which misses the caching available with cairo-perf-diff. 'make html' is
almost what I want, but still too prescriptive. However, that does need to
be addressed for continuous performance monitoring.
Along the perf lines, those sequence of operations become:
./cairo-perf record -i 6
./cairo-perf report
./cairo-perf report REVA REVB
./cairo-perf report --backends="image,xlib,gl" REVA REVB
./cairo-perf report --html REVA REVB
Also we want to think about installing the cairo-perf binary. So we want
to differentiate when run inside a git checkout.
diff --git a/perf/Makefile.am b/perf/Makefile.am
index 8588fe0..2fd427c 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -13,14 +13,15 @@ AM_LDFLAGS = $(CAIRO_LDFLAGS)
EXTRA_PROGRAMS += cairo-perf \
cairo-perf-trace \
cairo-perf-diff-files \
+ cairo-perf-print \
cairo-perf-compare-backends \
cairo-perf-graph-files
EXTRA_DIST += cairo-perf-diff COPYING
EXTRA_LTLIBRARIES += libcairoperf.la
-LDADD = $(top_builddir)/boilerplate/libcairoboilerplate.la \
+LDADD = libcairoperf.la \
+ $(top_builddir)/boilerplate/libcairoboilerplate.la \
$(top_builddir)/src/libcairo.la \
- libcairoperf.la \
$(CAIROPERF_LIBS)
cairo_perf_SOURCES = \
@@ -99,6 +100,9 @@ cairo_perf_trace_DEPENDENCIES = \
cairo_perf_diff_files_SOURCES = \
cairo-perf-diff-files.c
+cairo_perf_print_SOURCES = \
+ cairo-perf-print.c
+
cairo_perf_compare_backends_SOURCES = \
cairo-perf-compare-backends.c
diff --git a/perf/cairo-perf-print.c b/perf/cairo-perf-print.c
new file mode 100644
index 0000000..05bf5bd
--- /dev/null
+++ b/perf/cairo-perf-print.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ * Copyright © 2009 Chris Wilson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Authors: Carl Worth <cworth at cworth.org>
+ * Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-perf.h"
+
+#include <stdio.h>
+
+static void
+report_print (const cairo_perf_report_t *report)
+{
+ const test_report_t *tests;
+
+ tests = report->tests;
+ for (tests = report->tests; tests->name != NULL; tests++) {
+ if (tests->stats.iterations == 0)
+ continue;
+
+ if (tests->size) {
+ printf ("%5s-%-4s %26s-%-3d %6.2f %4.2f%%\n",
+ tests->backend, tests->content,
+ tests->name, tests->size,
+ tests->stats.median_ticks / tests->stats.ticks_per_ms,
+ tests->stats.std_dev * 100);
+ } else {
+ printf ("%5s %26s %6.2f %4.2f%%\n",
+ tests->backend, tests->name,
+ tests->stats.median_ticks / tests->stats.ticks_per_ms,
+ tests->stats.std_dev * 100);
+ }
+ }
+}
+
+int
+main (int argc, const char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++ ) {
+ cairo_perf_report_t report;
+
+ cairo_perf_report_load (&report, argv[i], NULL);
+ report_print (&report);
+ }
+
+ return 0;
+}
commit 92ba74d760f20cd257b3916a51c8efef1c0e021e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed Jul 22 19:04:07 2009 +0100
[vg] Compile fixes for EGL boilerplate
diff --git a/boilerplate/cairo-boilerplate-vg.c b/boilerplate/cairo-boilerplate-vg.c
index 224a2d5..75756dd 100644
--- a/boilerplate/cairo-boilerplate-vg.c
+++ b/boilerplate/cairo-boilerplate-vg.c
@@ -195,7 +195,7 @@ _cairo_boilerplate_vg_cleanup_egl (void *closure)
eglDestroyContext (vgc->dpy, vgc->ctx);
eglDestroySurface (vgc->dpy, vgc->dummy);
- eglDestroyDisplay (vgc->dpy);
+ eglTerminate (vgc->dpy);
free (vgc);
}
@@ -216,7 +216,7 @@ _cairo_boilerplate_vg_create_surface_egl (const char *name,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
- ELG_RENDERABLE_TYPE, EGL_OPENVG_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
None
};
int rgb_attribs[] = {
@@ -224,9 +224,9 @@ _cairo_boilerplate_vg_create_surface_egl (const char *name,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
- EGL_VG_ALPHA_FORMAT, VG_ALPHA_FORMAT_PRE,
+ EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE_BIT,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
- ELG_RENDERABLE_TYPE, EGL_OPENVG_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
None
};
int dummy_attribs[] = {
@@ -235,11 +235,12 @@ _cairo_boilerplate_vg_create_surface_egl (const char *name,
};
EGLDisplay *dpy;
int major, minor;
- EGLConfig *config;
+ EGLConfig config;
int num_configs;
EGLContext *egl_context;
+ EGLSurface *dummy;
cairo_vg_context_t *context;
- cairo_vg_surface_t *surface;
+ cairo_surface_t *surface;
vg_closure_egl_t *vgc;
dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
@@ -250,10 +251,9 @@ _cairo_boilerplate_vg_create_surface_egl (const char *name,
eglBindAPI (EGL_OPENVG_API);
if (! eglChooseConfig (dpy,
- attribs,
content == CAIRO_CONTENT_COLOR_ALPHA ?
rgba_attribs : rgb_attribs,
- 1, &num_configs) ||
+ &config, 1, &num_configs) ||
num_configs != 1)
{
return NULL;
@@ -284,10 +284,9 @@ _cairo_boilerplate_vg_create_surface_egl (const char *name,
*closure = vgc;
context = cairo_vg_context_create_for_egl (vgc->dpy, vgc->ctx);
- vgc->surface = cairo_vg_surface_create (context, content, width, height);
+ surface = cairo_vg_surface_create (context, content, width, height);
cairo_vg_context_destroy (context);
- surface = vgc->surface;
if (cairo_surface_status (surface))
_cairo_boilerplate_vg_cleanup_egl (vgc);
More information about the cairo-commit
mailing list