summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-02-04 10:43:13 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-02-04 10:49:36 +0000
commit260c16331a2c7bedbcf35d7f2cbab2f1f4098c87 (patch)
treebfb1e9a466e77deea5cc52a5dca3a330756443a8
parent05ad89f91241b386f72f5b9bac3ebe62faff1d1b (diff)
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@chris-wilson.co.uk>
-rw-r--r--src/cairo-gl-shaders.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index ae2977c5..0bc4e5e1 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;