From patchwork Mon Jul 25 13:56:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 3093 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9655C23E54 for ; Mon, 25 Jul 2011 13:58:05 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 5F700A1844E for ; Mon, 25 Jul 2011 13:58:05 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so3003702qwb.11 for ; Mon, 25 Jul 2011 06:58:05 -0700 (PDT) Received: by 10.229.25.212 with SMTP id a20mr3470499qcc.148.1311602285065; Mon, 25 Jul 2011 06:58:05 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs77914qcb; Mon, 25 Jul 2011 06:58:04 -0700 (PDT) Received: by 10.223.4.147 with SMTP id 19mr1362147far.39.1311602284131; Mon, 25 Jul 2011 06:58:04 -0700 (PDT) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by mx.google.com with ESMTPS id 18si7042659fat.105.2011.07.25.06.58.03 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:58:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.161.44 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) client-ip=209.85.161.44; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.161.44 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) smtp.mail=alexandros.frantzis@linaro.org Received: by mail-fx0-f44.google.com with SMTP id 6so6802455fxe.17 for ; Mon, 25 Jul 2011 06:58:03 -0700 (PDT) Received: by 10.223.65.197 with SMTP id k5mr6814336fai.26.1311602283725; Mon, 25 Jul 2011 06:58:03 -0700 (PDT) Received: from localhost (77.49.93.204.dsl.dyn.forthnet.gr [77.49.93.204]) by mx.google.com with ESMTPS id w11sm3807284faj.14.2011.07.25.06.58.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jul 2011 06:58:03 -0700 (PDT) From: alexandros.frantzis@linaro.org To: patches@linaro.org Subject: [PATCH 21/21] gl: Add fallback path for GLES2 implementations not supporting GL_OES_mapbuffer Date: Mon, 25 Jul 2011 16:56:48 +0300 Message-Id: <1311602208-5973-21-git-send-email-alexandros.frantzis@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1311602208-5973-1-git-send-email-alexandros.frantzis@linaro.org> References: <1311602208-5973-1-git-send-email-alexandros.frantzis@linaro.org> From: Alexandros Frantzis Signed-off-by: Chris Wilson --- src/cairo-gl-composite.c | 18 ++++++++++++++---- src/cairo-gl-device.c | 14 ++++++++++++++ src/cairo-gl-dispatch.c | 3 +-- src/cairo-gl-private.h | 2 ++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c index 575719b..bb88f59 100644 --- a/src/cairo-gl-composite.c +++ b/src/cairo-gl-composite.c @@ -1014,7 +1014,12 @@ _cairo_gl_composite_flush (cairo_gl_context_t *ctx) count = ctx->vb_offset / ctx->vertex_size; - ctx->dispatch.UnmapBuffer (GL_ARRAY_BUFFER); + if (ctx->has_map_buffer) + ctx->dispatch.UnmapBuffer (GL_ARRAY_BUFFER); + else + ctx->dispatch.BufferData (GL_ARRAY_BUFFER, ctx->vb_offset, + ctx->vb, GL_STREAM_DRAW); + ctx->vb = NULL; ctx->vb_offset = 0; @@ -1044,9 +1049,14 @@ _cairo_gl_composite_prepare_buffer (cairo_gl_context_t *ctx, _cairo_gl_composite_flush (ctx); if (ctx->vb == NULL) { - dispatch->BufferData (GL_ARRAY_BUFFER, CAIRO_GL_VBO_SIZE, - NULL, GL_STREAM_DRAW); - ctx->vb = dispatch->MapBuffer (GL_ARRAY_BUFFER, GL_WRITE_ONLY); + if (ctx->has_map_buffer) { + dispatch->BufferData (GL_ARRAY_BUFFER, CAIRO_GL_VBO_SIZE, + NULL, GL_STREAM_DRAW); + ctx->vb = dispatch->MapBuffer (GL_ARRAY_BUFFER, GL_WRITE_ONLY); + } + else { + ctx->vb = ctx->vb_mem; + } } } diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index c94e36f..170cf96 100644 --- a/src/cairo-gl-device.c +++ b/src/cairo-gl-device.c @@ -132,6 +132,8 @@ _gl_destroy (void *device) cairo_region_destroy (ctx->clip_region); + free (ctx->vb_mem); + ctx->destroy (ctx); free (ctx); @@ -191,6 +193,10 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) ! _cairo_gl_has_extension ("GL_EXT_texture_format_BGRA8888")) return _cairo_error (CAIRO_STATUS_DEVICE_ERROR); + ctx->has_map_buffer = (gl_flavor == CAIRO_GL_FLAVOR_DESKTOP || + (gl_flavor == CAIRO_GL_FLAVOR_ES && + _cairo_gl_has_extension ("GL_OES_mapbuffer"))); + ctx->has_mesa_pack_invert = _cairo_gl_has_extension ("GL_MESA_pack_invert"); @@ -209,6 +215,14 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx) if (unlikely (status)) return status; + if (! ctx->has_map_buffer) { + ctx->vb_mem = _cairo_malloc_ab (CAIRO_GL_VBO_SIZE, 1); + if (unlikely (ctx->vb_mem == NULL)) { + _cairo_cache_fini (&ctx->gradients); + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + } + } + /* PBO for any sort of texture upload */ dispatch->GenBuffers (1, &ctx->texture_load_pbo); dispatch->GenBuffers (1, &ctx->vbo); diff --git a/src/cairo-gl-dispatch.c b/src/cairo-gl-dispatch.c index 344b0eb..5bffddd 100644 --- a/src/cairo-gl-dispatch.c +++ b/src/cairo-gl-dispatch.c @@ -125,8 +125,7 @@ _cairo_gl_dispatch_init_buffers (cairo_gl_dispatch_t *dispatch, return CAIRO_STATUS_DEVICE_ERROR; } else if (gl_flavor == CAIRO_GL_FLAVOR_ES && - gl_version >= CAIRO_GL_VERSION_ENCODE (2, 0) && - _cairo_gl_has_extension ("GL_OES_mapbuffer")) + gl_version >= CAIRO_GL_VERSION_ENCODE (2, 0)) { dispatch_name = CAIRO_GL_DISPATCH_NAME_ES; } diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h index 3f3153e..edd1355 100644 --- a/src/cairo-gl-private.h +++ b/src/cairo-gl-private.h @@ -285,6 +285,7 @@ struct _cairo_gl_context { cairo_gl_operand_t operands[2]; char *vb; + char *vb_mem; unsigned int vb_offset; unsigned int vertex_size; cairo_region_t *clip_region; @@ -293,6 +294,7 @@ struct _cairo_gl_context { cairo_gl_dispatch_t dispatch; GLfloat modelviewprojection_matrix[16]; cairo_gl_flavor_t gl_flavor; + cairo_bool_t has_map_buffer; void (*acquire) (void *ctx); void (*release) (void *ctx);