summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-27 20:51:55 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-27 20:51:55 +0100
commitcc080a1e2731a42045709d789587070da944145c (patch)
treea994ea143a03787462ef443428e6032abf24a872
parentb3e15bd5c307352065555c6c3ae5f0bd15b9a791 (diff)
gl: Unmap the vertex buffer prior to using in DaawArrays()
"It is an INVALID_OPERTION error to source data from a buffer object that is currently mapped." mesa is currently lax in this regard, but the Nvidia libGL conforms to the spec and thus was causing failures.
-rw-r--r--src/cairo-gl-composite.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 50f2c074..39633101 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -1100,11 +1100,9 @@ _cairo_gl_composite_begin (cairo_gl_context_t *ctx,
static inline void
_cairo_gl_composite_draw (cairo_gl_context_t *ctx,
- cairo_gl_composite_t *setup)
+ cairo_gl_composite_t *setup,
+ unsigned int count)
{
- unsigned int count = ctx->vb_offset / ctx->vertex_size;
-
- _cairo_gl_check_error();
if (! setup->pre_shader) {
glDrawArrays (GL_TRIANGLES, 0, count);
} else {
@@ -1122,16 +1120,23 @@ _cairo_gl_composite_draw (cairo_gl_context_t *ctx,
_cairo_gl_set_component_alpha_mask_operand (ctx, setup);
glDrawArrays (GL_TRIANGLES, 0, count);
}
- _cairo_gl_check_error();
}
void
_cairo_gl_composite_flush (cairo_gl_context_t *ctx,
cairo_gl_composite_t *setup)
{
+ unsigned int count;
+
if (ctx->vb_offset == 0)
return;
+ count = ctx->vb_offset / ctx->vertex_size;
+
+ glUnmapBufferARB (GL_ARRAY_BUFFER_ARB);
+ ctx->vb = NULL;
+ ctx->vb_offset = 0;
+
if (setup->clip_region) {
int i, num_rectangles = cairo_region_num_rectangles (setup->clip_region);
@@ -1141,15 +1146,11 @@ _cairo_gl_composite_flush (cairo_gl_context_t *ctx,
cairo_region_get_rectangle (setup->clip_region, i, &rect);
glScissor (rect.x, rect.y, rect.width, rect.height);
- _cairo_gl_composite_draw (ctx, setup);
+ _cairo_gl_composite_draw (ctx, setup, count);
}
} else {
- _cairo_gl_composite_draw (ctx, setup);
+ _cairo_gl_composite_draw (ctx, setup, count);
}
-
- glUnmapBufferARB (GL_ARRAY_BUFFER_ARB);
- ctx->vb = NULL;
- ctx->vb_offset = 0;
}
static void