[cairo-commit] 2 commits - src/cairo-gl-glyphs.c src/cairo-gl-private.h src/cairo-gl-shaders.c src/cairo-gl-spans-compositor.c src/cairo-gl-surface.c src/cairo-gl-surface-legacy.c src/cairo-gl-traps-compositor.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Feb 4 02:51:43 PST 2013


 src/cairo-gl-glyphs.c           |    2 -
 src/cairo-gl-private.h          |    3 +-
 src/cairo-gl-shaders.c          |   49 ++++++++++++++++++++++++----------------
 src/cairo-gl-spans-compositor.c |    2 -
 src/cairo-gl-surface-legacy.c   |    7 +++--
 src/cairo-gl-surface.c          |   16 ++++++++-----
 src/cairo-gl-traps-compositor.c |    9 ++++---
 7 files changed, 54 insertions(+), 34 deletions(-)

New commits:
commit 4cb181d985adbbf79e80ff695adc908810b41544
Author: Henry Song <henry.song at samsung.com>
Date:   Tue Jan 29 17:53:38 2013 +0000

    gl: do not force flush everytime uploading a glyph image to glyph cache
    
    In normal cases, we want to flush pending operations reading from the
    texture before modifying its contents.  However during uploading of
    glyphs into the glyph cache, we repeatedly modify the texture as we
    construct the vbo (whilst referencing it for that operation). We track
    unused areas in the glyph cache so that if we run out of space, we can
    explicitly flush the pending glyphs and start afresh and avoid having to
    flush the operation in common case.

diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index 3f65248..34b5d72 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -134,7 +134,7 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
     status = _cairo_gl_surface_draw_image (cache->surface, glyph_surface,
                                            0, 0,
                                            glyph_surface->width, glyph_surface->height,
-                                           node->x, node->y);
+                                           node->x, node->y, FALSE);
     if (unlikely (status))
 	return status;
 
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 2b254f9..cc17c70 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -437,7 +437,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
 			      cairo_image_surface_t *src,
 			      int src_x, int src_y,
 			      int width, int height,
-			      int dst_x, int dst_y);
+			      int dst_x, int dst_y,
+			      cairo_bool_t force_flush);
 
 static cairo_always_inline cairo_bool_t
 _cairo_gl_device_has_glsl (cairo_device_t *device)
diff --git a/src/cairo-gl-spans-compositor.c b/src/cairo-gl-spans-compositor.c
index 92e5779..c5d97aa 100644
--- a/src/cairo-gl-spans-compositor.c
+++ b/src/cairo-gl-spans-compositor.c
@@ -311,7 +311,7 @@ draw_image_boxes (void *_dst,
 	    status = _cairo_gl_surface_draw_image (dst, image,
 						   x + dx, y + dy,
 						   w, h,
-						   x, y);
+						   x, y, TRUE);
 	    if (unlikely (status))
 		return status;
 	}
diff --git a/src/cairo-gl-surface-legacy.c b/src/cairo-gl-surface-legacy.c
index 61bdd1f..92b27c9 100644
--- a/src/cairo-gl-surface-legacy.c
+++ b/src/cairo-gl-surface-legacy.c
@@ -77,7 +77,8 @@ _cairo_gl_surface_release_dest_image (void		      *abstract_surface,
     status = _cairo_gl_surface_draw_image (abstract_surface, image,
 					   0, 0,
 					   image->width, image->height,
-					   image_rect->x, image_rect->y);
+					   image_rect->x, image_rect->y,
+					   TRUE);
     /* as we created the image, its format should be directly applicable */
     assert (status == CAIRO_STATUS_SUCCESS);
 
@@ -126,7 +127,7 @@ _cairo_gl_surface_clone_similar (void		     *abstract_surface,
 	status = _cairo_gl_surface_draw_image (clone, image_src,
 					       src_x, src_y,
 					       width, height,
-					       0, 0);
+					       0, 0, TRUE);
 	if (status) {
 	    cairo_surface_destroy (&clone->base);
 	    return status;
@@ -236,7 +237,7 @@ _cairo_gl_surface_composite (cairo_operator_t		  op,
             status = _cairo_gl_surface_draw_image (dst, image,
                                                    dx, dy,
                                                    width, height,
-                                                   dst_x, dst_y);
+                                                   dst_x, dst_y, TRUE);
             if (status != CAIRO_INT_STATUS_UNSUPPORTED)
                 return status;
         }
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 922f234..1d7515a 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -840,7 +840,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
 			      cairo_image_surface_t *src,
 			      int src_x, int src_y,
 			      int width, int height,
-			      int dst_x, int dst_y)
+			      int dst_x, int dst_y,
+			      cairo_bool_t force_flush)
 {
     GLenum internal_format, format, type;
     cairo_bool_t has_alpha, needs_swap;
@@ -882,9 +883,11 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
 
     cpp = PIXMAN_FORMAT_BPP (src->pixman_format) / 8;
 
-    status = _cairo_gl_surface_flush (&dst->base, 0);
-    if (unlikely (status))
-	goto FAIL;
+    if (force_flush) {
+	status = _cairo_gl_surface_flush (&dst->base, 0);
+	if (unlikely (status))
+	    goto FAIL;
+    }
 
     if (_cairo_gl_surface_is_texture (dst)) {
 	void *data_start = src->data + src_y * src->stride + src_x * cpp;
@@ -951,7 +954,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
                                                src,
                                                src_x, src_y,
                                                width, height,
-                                               0, 0);
+                                               0, 0, force_flush);
         if (status == CAIRO_INT_STATUS_SUCCESS) {
             cairo_surface_pattern_t tmp_pattern;
 	    cairo_rectangle_int_t r;
@@ -1231,7 +1234,8 @@ _cairo_gl_surface_unmap_image (void		      *abstract_surface,
 					   0, 0,
 					   image->width, image->height,
 					   image->base.device_transform_inverse.x0,
-					   image->base.device_transform_inverse.y0);
+					   image->base.device_transform_inverse.y0,
+					   TRUE);
 
     cairo_surface_finish (&image->base);
     cairo_surface_destroy (&image->base);
diff --git a/src/cairo-gl-traps-compositor.c b/src/cairo-gl-traps-compositor.c
index 9589ffc..548162b 100644
--- a/src/cairo-gl-traps-compositor.c
+++ b/src/cairo-gl-traps-compositor.c
@@ -96,7 +96,8 @@ draw_image_boxes (void *_dst,
 	    status = _cairo_gl_surface_draw_image (dst, image,
 						   x + dx, y + dy,
 						   w, h,
-						   x, y);
+						   x, y,
+						   TRUE);
 	    if (unlikely (status))
 		return status;
 	}
@@ -345,7 +346,8 @@ traps_to_operand (void *_dst,
 					   (cairo_image_surface_t *)image,
 					   0, 0,
 					   extents->width, extents->height,
-					   0, 0);
+					   0, 0,
+					   TRUE);
     cairo_surface_destroy (image);
 
     if (unlikely (status))
@@ -456,7 +458,8 @@ tristrip_to_surface (void *_dst,
 					   (cairo_image_surface_t *)image,
 					   0, 0,
 					   extents->width, extents->height,
-					   0, 0);
+					   0, 0,
+					   TRUE);
     cairo_surface_destroy (image);
     if (unlikely (status)) {
 	cairo_surface_destroy (mask);
commit 260c16331a2c7bedbcf35d7f2cbab2f1f4098c87
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Feb 4 10:43:13 2013 +0000

    gl: Include the vertex ident in the shader cache hash
    
    As we may specialise the vertex program depending upon details of the
    fragment shader, and may have more than one program for the same
    combination of fragment sources, we need to include the vertex tag in
    the cache entry.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index ae2977c..0bc4e5e 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -55,10 +55,13 @@ _cairo_gl_shader_compile_and_link (cairo_gl_context_t *ctx,
 typedef struct _cairo_shader_cache_entry {
     cairo_cache_entry_t base;
 
+    unsigned vertex;
+
     cairo_gl_operand_type_t src;
     cairo_gl_operand_type_t mask;
     cairo_gl_operand_type_t dest;
     cairo_bool_t use_coverage;
+
     cairo_gl_shader_in_t in;
     GLint src_gl_filter;
     cairo_bool_t src_border_fade;
@@ -79,13 +82,14 @@ _cairo_gl_shader_cache_equal_desktop (const void *key_a, const void *key_b)
     cairo_bool_t both_have_npot_repeat =
 	a->ctx->has_npot_repeat && b->ctx->has_npot_repeat;
 
-    return a->src  == b->src  &&
-           a->mask == b->mask &&
-           a->dest == b->dest &&
-	   a->use_coverage == b->use_coverage &&
-           a->in   == b->in &&
-	   (both_have_npot_repeat || a->src_extend == b->src_extend) &&
-	   (both_have_npot_repeat || a->mask_extend == b->mask_extend);
+    return (a->vertex == b->vertex &&
+	    a->src  == b->src  &&
+	    a->mask == b->mask &&
+	    a->dest == b->dest &&
+	    a->use_coverage == b->use_coverage &&
+	    a->in   == b->in &&
+	    (both_have_npot_repeat || a->src_extend == b->src_extend) &&
+	    (both_have_npot_repeat || a->mask_extend == b->mask_extend));
 }
 
 /*
@@ -101,23 +105,24 @@ _cairo_gl_shader_cache_equal_gles2 (const void *key_a, const void *key_b)
     cairo_bool_t both_have_npot_repeat =
 	a->ctx->has_npot_repeat && b->ctx->has_npot_repeat;
 
-    return a->src  == b->src  &&
-	   a->mask == b->mask &&
-	   a->dest == b->dest &&
-	   a->use_coverage == b->use_coverage &&
-	   a->in   == b->in   &&
-	   a->src_gl_filter == b->src_gl_filter &&
-	   a->src_border_fade == b->src_border_fade &&
-	   (both_have_npot_repeat || a->src_extend == b->src_extend) &&
-	   a->mask_gl_filter == b->mask_gl_filter &&
-	   a->mask_border_fade == b->mask_border_fade &&
-	   (both_have_npot_repeat || a->mask_extend == b->mask_extend);
+    return (a->vertex && b->vertex &&
+	    a->src  == b->src  &&
+	    a->mask == b->mask &&
+	    a->dest == b->dest &&
+	    a->use_coverage == b->use_coverage &&
+	    a->in   == b->in   &&
+	    a->src_gl_filter == b->src_gl_filter &&
+	    a->src_border_fade == b->src_border_fade &&
+	    (both_have_npot_repeat || a->src_extend == b->src_extend) &&
+	    a->mask_gl_filter == b->mask_gl_filter &&
+	    a->mask_border_fade == b->mask_border_fade &&
+	    (both_have_npot_repeat || a->mask_extend == b->mask_extend));
 }
 
 static unsigned long
 _cairo_gl_shader_cache_hash (const cairo_shader_cache_entry_t *entry)
 {
-    return (entry->src << 24) | (entry->mask << 16) | (entry->dest << 8) | (entry->in << 1) | entry->use_coverage;
+    return ((entry->src << 24) | (entry->mask << 16) | (entry->dest << 8) | (entry->in << 1) | entry->use_coverage) ^ entry->vertex;
 }
 
 static void
@@ -988,6 +993,12 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
     cairo_status_t status;
 
     lookup.ctx = ctx;
+
+    lookup.vertex = cairo_gl_var_type_hash (cairo_gl_operand_get_var_type (source),
+					    cairo_gl_operand_get_var_type (mask),
+					    use_coverage,
+					    CAIRO_GL_VAR_NONE);
+
     lookup.src = source->type;
     lookup.mask = mask->type;
     lookup.dest = CAIRO_GL_OPERAND_NONE;


More information about the cairo-commit mailing list