[cairo-commit] 6 commits - src/cairo-gl-composite.c src/cairo-gl-device.c src/cairo-gl-dispatch-private.h src/cairo-gl-private.h src/cairo-gl-shaders.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Feb 10 06:56:54 PST 2011


 src/cairo-gl-composite.c        |   44 ++++++++++++++++++----------------
 src/cairo-gl-device.c           |   51 ++++++++++++++++++++++++++++++++++------
 src/cairo-gl-dispatch-private.h |    8 ++++++
 src/cairo-gl-private.h          |   27 +++++++++++++++++++++
 src/cairo-gl-shaders.c          |   47 ++++++++++++++++++++++++++++++++++--
 5 files changed, 147 insertions(+), 30 deletions(-)

New commits:
commit e4fdd9a1cd4c0d074dd20417e66de5856b6ba5a7
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Thu Feb 3 23:06:26 2011 +0200

    gl: Replace built-in vertex attributes with custom attributes
    
    Built-in vertex attributes like gl_Vertex and gl_Color, have been obsoleted
    and removed in recent GL versions and they are not supported at all in GLES2.0.
    Custom attributes are supported in all GL versions >= 2.0, in GL 1.x with
    ARB shader extensions and in GLES2.0.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 7cbe894..d5b3c5c 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -3,6 +3,7 @@
  * Copyright © 2009 Eric Anholt
  * Copyright © 2009 Chris Wilson
  * Copyright © 2005,2010 Red Hat, Inc
+ * Copyright © 2011 Linaro Limited
  *
  * This library is free software; you can redistribute it and/or
  * modify it either under the terms of the GNU Lesser General Public
@@ -36,6 +37,7 @@
  *	Carl Worth <cworth at cworth.org>
  *	Chris Wilson <chris at chris-wilson.co.uk>
  *	Eric Anholt <eric at anholt.net>
+ *	Alexandros Frantzis <alexandros.frantzis at linaro.org>
  */
 
 #include "cairoint.h"
@@ -516,6 +518,7 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
                                  unsigned int        vertex_size,
                                  unsigned int        vertex_offset)
 {
+    cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
     cairo_bool_t needs_setup;
 
     /* XXX: we need to do setup when switching from shaders
@@ -543,9 +546,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
     case CAIRO_GL_OPERAND_NONE:
         break;
     case CAIRO_GL_OPERAND_SPANS:
-	glColorPointer (4, GL_UNSIGNED_BYTE, vertex_size,
-                        (void *) (uintptr_t) vertex_offset);
-	glEnableClientState (GL_COLOR_ARRAY);
+	dispatch->VertexAttribPointer (CAIRO_GL_COLOR_ATTRIB_INDEX, 4,
+				       GL_UNSIGNED_BYTE, GL_TRUE, vertex_size,
+				       (void *) (uintptr_t) vertex_offset);
+	dispatch->EnableVertexAttribArray (CAIRO_GL_COLOR_ATTRIB_INDEX);
         /* fall through */
     case CAIRO_GL_OPERAND_CONSTANT:
         break;
@@ -557,10 +561,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
         _cairo_gl_texture_set_filter (ctx, ctx->tex_target,
                                       operand->texture.attributes.filter);
 
-	glClientActiveTexture (GL_TEXTURE0 + tex_unit);
-	glTexCoordPointer (2, GL_FLOAT, vertex_size,
-                           (void *) (uintptr_t) vertex_offset);
-	glEnableClientState (GL_TEXTURE_COORD_ARRAY);
+	dispatch->VertexAttribPointer (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit, 2,
+					GL_FLOAT, GL_FALSE, vertex_size,
+					(void *) (uintptr_t) vertex_offset);
+	dispatch->EnableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
         break;
     case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
     case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
@@ -572,10 +576,10 @@ _cairo_gl_context_setup_operand (cairo_gl_context_t *ctx,
         _cairo_gl_texture_set_extend (ctx, GL_TEXTURE_1D, operand->gradient.extend);
         _cairo_gl_texture_set_filter (ctx, GL_TEXTURE_1D, CAIRO_FILTER_BILINEAR);
 
-	glClientActiveTexture (GL_TEXTURE0 + tex_unit);
-	glTexCoordPointer (2, GL_FLOAT, vertex_size,
-                           (void *) (uintptr_t) vertex_offset);
-	glEnableClientState (GL_TEXTURE_COORD_ARRAY);
+	dispatch->VertexAttribPointer (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit, 2,
+				       GL_FLOAT, GL_FALSE, vertex_size,
+				       (void *) (uintptr_t) vertex_offset);
+	dispatch->EnableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
 	break;
     }
 }
@@ -584,6 +588,7 @@ void
 _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
                                    cairo_gl_tex_t tex_unit)
 {
+    cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
     assert (_cairo_gl_context_is_flushed (ctx));
 
     switch (ctx->operands[tex_unit].type) {
@@ -593,23 +598,19 @@ _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
     case CAIRO_GL_OPERAND_NONE:
         break;
     case CAIRO_GL_OPERAND_SPANS:
-        glDisableClientState (GL_COLOR_ARRAY);
+        dispatch->DisableVertexAttribArray (CAIRO_GL_COLOR_ATTRIB_INDEX);
         /* fall through */
     case CAIRO_GL_OPERAND_CONSTANT:
         break;
     case CAIRO_GL_OPERAND_TEXTURE:
-        glActiveTexture (GL_TEXTURE0 + tex_unit);
-        glClientActiveTexture (GL_TEXTURE0 + tex_unit);
-        glDisableClientState (GL_TEXTURE_COORD_ARRAY);
+        dispatch->DisableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
         break;
     case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
     case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
     case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE:
     case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
         _cairo_gl_gradient_destroy (ctx->operands[tex_unit].gradient.gradient);
-        glActiveTexture (GL_TEXTURE0 + tex_unit);
-        glClientActiveTexture (GL_TEXTURE0 + tex_unit);
-        glDisableClientState (GL_TEXTURE_COORD_ARRAY);
+        dispatch->DisableVertexAttribArray (CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + tex_unit);
         break;
     }
 
@@ -862,8 +863,9 @@ _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
     if (_cairo_gl_context_is_flushed (ctx)) {
         ctx->dispatch.BindBuffer (GL_ARRAY_BUFFER, ctx->vbo);
 
-        glVertexPointer (2, GL_FLOAT, vertex_size, NULL);
-        glEnableClientState (GL_VERTEX_ARRAY);
+	ctx->dispatch.VertexAttribPointer (CAIRO_GL_VERTEX_ATTRIB_INDEX, 2,
+					   GL_FLOAT, GL_FALSE, vertex_size, NULL);
+	ctx->dispatch.EnableVertexAttribArray (CAIRO_GL_VERTEX_ATTRIB_INDEX);
     }
 
     _cairo_gl_context_setup_operand (ctx, CAIRO_GL_TEX_SOURCE, &setup->src, vertex_size, dst_size);
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index fd1af87..475f14a 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -3,6 +3,7 @@
  * Copyright © 2009 Eric Anholt
  * Copyright © 2009 Chris Wilson
  * Copyright © 2005,2010 Red Hat, Inc
+ * Copyright © 2011 Linaro Limited
  *
  * This library is free software; you can redistribute it and/or
  * modify it either under the terms of the GNU Lesser General Public
@@ -37,6 +38,7 @@
  *	Chris Wilson <chris at chris-wilson.co.uk>
  *	Eric Anholt <eric at anholt.net>
  *	T. Zachary Laine <whatwasthataddress at gmail.com>
+ *	Alexandros Frantzis <alexandros.frantzis at linaro.org>
  */
 
 #ifndef CAIRO_GL_PRIVATE_H
@@ -84,6 +86,14 @@
 /* VBO size that we allocate, smaller size means we gotta flush more often */
 #define CAIRO_GL_VBO_SIZE 16384
 
+/* Indices for vertex attributes used by BindAttribLocation etc */
+enum {
+    CAIRO_GL_VERTEX_ATTRIB_INDEX = 0,
+    CAIRO_GL_COLOR_ATTRIB_INDEX  = 1,
+    CAIRO_GL_TEXCOORD0_ATTRIB_INDEX = 2,
+    CAIRO_GL_TEXCOORD1_ATTRIB_INDEX = CAIRO_GL_TEXCOORD0_ATTRIB_INDEX + 1
+};
+
 typedef struct _cairo_gl_surface {
     cairo_surface_t base;
 
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index 6a3a606..a17491e 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -163,6 +163,16 @@ link_shader_core_2_0 (cairo_gl_context_t *ctx, GLuint *program,
     *program = dispatch->CreateProgram ();
     dispatch->AttachShader (*program, vert);
     dispatch->AttachShader (*program, frag);
+
+    dispatch->BindAttribLocation (*program, CAIRO_GL_VERTEX_ATTRIB_INDEX,
+				  "Vertex");
+    dispatch->BindAttribLocation (*program, CAIRO_GL_COLOR_ATTRIB_INDEX,
+				  "Color");
+    dispatch->BindAttribLocation (*program, CAIRO_GL_TEXCOORD0_ATTRIB_INDEX,
+				  "MultiTexCoord0");
+    dispatch->BindAttribLocation (*program, CAIRO_GL_TEXCOORD1_ATTRIB_INDEX,
+				  "MultiTexCoord1");
+
     dispatch->LinkProgram (*program);
     dispatch->GetProgramiv (*program, GL_LINK_STATUS, &gl_status);
     if (gl_status == GL_FALSE) {
@@ -492,12 +502,12 @@ cairo_gl_shader_emit_vertex (cairo_output_stream_t *stream,
         break;
     case CAIRO_GL_VAR_TEXCOORDS:
         _cairo_output_stream_printf (stream, 
-                                     "    %s_texcoords = gl_MultiTexCoord%d.xy;\n",
+                                     "    %s_texcoords = MultiTexCoord%d.xy;\n",
                                      operand_names[name], name);
         break;
     case CAIRO_GL_VAR_COVERAGE:
         _cairo_output_stream_printf (stream, 
-                                     "    %s_coverage = gl_Color.a;\n",
+                                     "    %s_coverage = Color.a;\n",
                                      operand_names[name]);
         break;
     }
@@ -518,10 +528,14 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src,
     cairo_gl_shader_emit_variable (stream, mask, CAIRO_GL_TEX_MASK);
 
     _cairo_output_stream_printf (stream,
+				 "attribute vec4 Vertex;\n"
+				 "attribute vec4 Color;\n"
+				 "attribute vec4 MultiTexCoord0;\n"
+				 "attribute vec4 MultiTexCoord1;\n"
 				 "uniform mat4 ModelViewProjectionMatrix;\n"
 				 "void main()\n"
 				 "{\n"
-				 "    gl_Position = ModelViewProjectionMatrix * gl_Vertex;\n");
+				 "    gl_Position = ModelViewProjectionMatrix * Vertex;\n");
 
     cairo_gl_shader_emit_vertex (stream, src, CAIRO_GL_TEX_SOURCE);
     cairo_gl_shader_emit_vertex (stream, mask, CAIRO_GL_TEX_MASK);
commit e68062d9caafe21b53af22173fff40ad973a8d73
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Thu Feb 3 22:06:27 2011 +0200

    gl: Add gl dispatch entries for functions related to vertex attributes
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-dispatch-private.h b/src/cairo-gl-dispatch-private.h
index bd444a5..0795e70 100644
--- a/src/cairo-gl-dispatch-private.h
+++ b/src/cairo-gl-dispatch-private.h
@@ -85,6 +85,13 @@ cairo_private cairo_gl_dispatch_entry_t dispatch_shaders_entries[] = {
     DISPATCH_ENTRY_ARB (UniformMatrix3fv),
     DISPATCH_ENTRY_ARB (UniformMatrix4fv),
     DISPATCH_ENTRY_ARB (Uniform1i),
+
+    /* Attributes */
+    DISPATCH_ENTRY_ARB (BindAttribLocation),
+    DISPATCH_ENTRY_ARB (VertexAttribPointer),
+    DISPATCH_ENTRY_ARB (EnableVertexAttribArray),
+    DISPATCH_ENTRY_ARB (DisableVertexAttribArray),
+
     DISPATCH_ENTRY_LAST
 };
 
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 61c382d..fd1af87 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -214,6 +214,15 @@ typedef struct _cairo_gl_dispatch {
 			      GLboolean transpose, const GLfloat *value);
     void (*Uniform1i) (GLint location, GLint x);
 
+    /* Attributes */
+    void (*BindAttribLocation) (GLuint program, GLuint index,
+				const GLchar *name);
+    void (*VertexAttribPointer) (GLuint index, GLint size, GLenum type,
+				 GLboolean normalized, GLsizei stride,
+				 const GLvoid *pointer);
+    void (*EnableVertexAttribArray) (GLuint index);
+    void (*DisableVertexAttribArray) (GLuint index);
+
     /* Framebuffer objects */
     void (*GenFramebuffers) (GLsizei n, GLuint* framebuffers);
     void (*BindFramebuffer) (GLenum target, GLuint framebuffer);
commit 80a92b6d799900057ac40c0c0bb63be48eece9ef
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Mon Jan 31 18:02:02 2011 +0200

    gl: Use a custom shader uniform for the ModelViewProjection matrix
    
    The built-in gl_ModelViewProjectionMatrix uniform (and others) has been
    deprecated and removed in recent GLSL versions and is not supported
    at all in GLSL ES. A custom uniform for the same purpose works across
    all versions.
    
    [ickle: base _gl_identity_ortho on the 2D variant of glOrtho i.e. with
            fixed near/far values of [-1, 1]]
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index a32e00d..7cbe894 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -414,6 +414,8 @@ static void
 _cairo_gl_composite_bind_to_shader (cairo_gl_context_t   *ctx,
 				    cairo_gl_composite_t *setup)
 {
+    _cairo_gl_shader_bind_matrix4f(ctx, "ModelViewProjectionMatrix",
+				   ctx->modelviewprojection_matrix);
     _cairo_gl_operand_bind_to_shader (ctx, &setup->src,  CAIRO_GL_TEX_SOURCE);
     _cairo_gl_operand_bind_to_shader (ctx, &setup->mask, CAIRO_GL_TEX_MASK);
 }
diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
index 25423e0..3537dc9 100644
--- a/src/cairo-gl-device.c
+++ b/src/cairo-gl-device.c
@@ -269,6 +269,46 @@ _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx,
     }
 }
 
+/*
+ * Stores a parallel projection transformation in matrix 'm',
+ * using column-major order.
+ *
+ * This is equivalent to:
+ *
+ * glLoadIdentity()
+ * gluOrtho2D()
+ *
+ * The calculation for the ortho tranformation was taken from the
+ * mesa source code.
+ */
+static void
+_gl_identity_ortho (GLfloat *m,
+		    GLfloat left, GLfloat right,
+		    GLfloat bottom, GLfloat top)
+{
+#define M(row,col)  m[col*4+row]
+    M(0,0) = 2.f / (right - left);
+    M(0,1) = 0.f;
+    M(0,2) = 0.f;
+    M(0,3) = -(right + left) / (right - left);
+
+    M(1,0) = 0.f;
+    M(1,1) = 2.f / (top - bottom);
+    M(1,2) = 0.f;
+    M(1,3) = -(top + bottom) / (top - bottom);
+
+    M(2,0) = 0.f;
+    M(2,1) = 0.f;
+    M(2,2) = -1.f;
+    M(2,3) = 0.f;
+
+    M(3,0) = 0.f;
+    M(3,1) = 0.f;
+    M(3,2) = 0.f;
+    M(3,3) = 1.f;
+#undef M
+}
+
 void
 _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
                                    cairo_gl_surface_t *surface)
@@ -295,13 +335,10 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
 
     glViewport (0, 0, surface->width, surface->height);
 
-    glMatrixMode (GL_PROJECTION);
-    glLoadIdentity ();
     if (_cairo_gl_surface_is_texture (surface))
-	glOrtho (0, surface->width, 0, surface->height, -1.0, 1.0);
+	_gl_identity_ortho (ctx->modelviewprojection_matrix,
+			    0, surface->width, 0, surface->height);
     else
-	glOrtho (0, surface->width, surface->height, 0, -1.0, 1.0);
-
-    glMatrixMode (GL_MODELVIEW);
-    glLoadIdentity ();
+	_gl_identity_ortho (ctx->modelviewprojection_matrix,
+			    0, surface->width, surface->height, 0);
 }
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 3dd75f8..61c382d 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -259,6 +259,7 @@ struct _cairo_gl_context {
 
     cairo_bool_t has_mesa_pack_invert;
     cairo_gl_dispatch_t dispatch;
+    GLfloat modelviewprojection_matrix[16];
 
     void (*acquire) (void *ctx);
     void (*release) (void *ctx);
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index 13efccb..6a3a606 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -518,9 +518,10 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src,
     cairo_gl_shader_emit_variable (stream, mask, CAIRO_GL_TEX_MASK);
 
     _cairo_output_stream_printf (stream,
+				 "uniform mat4 ModelViewProjectionMatrix;\n"
 				 "void main()\n"
 				 "{\n"
-				 "    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n");
+				 "    gl_Position = ModelViewProjectionMatrix * gl_Vertex;\n");
 
     cairo_gl_shader_emit_vertex (stream, src, CAIRO_GL_TEX_SOURCE);
     cairo_gl_shader_emit_vertex (stream, mask, CAIRO_GL_TEX_MASK);
commit d88ada384fcb045cc9899339f9e8c1cbb8280c16
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Thu Jan 27 16:10:38 2011 +0200

    gl: Replace ftransform() with manual coordinate calculation in shaders
    
    The ftransform() shader function was deprecated and removed in recent
    GLSL versions and is not included at all in GLSL ES.
    
    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 1b10b04..13efccb 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -520,7 +520,7 @@ cairo_gl_shader_get_vertex_source (cairo_gl_var_type_t src,
     _cairo_output_stream_printf (stream,
 				 "void main()\n"
 				 "{\n"
-				 "    gl_Position = ftransform();\n");
+				 "    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n");
 
     cairo_gl_shader_emit_vertex (stream, src, CAIRO_GL_TEX_SOURCE);
     cairo_gl_shader_emit_vertex (stream, mask, CAIRO_GL_TEX_MASK);
commit b13198348ce053445ca97b513611207e34aa4528
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Mon Jan 31 16:18:29 2011 +0200

    gl: Add function to bind a 4x4 float matrix shader uniform
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 04322f2..3dd75f8 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -523,6 +523,11 @@ _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx,
 			      cairo_matrix_t* m);
 
 cairo_private void
+_cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx,
+				const char *name,
+				GLfloat* gl_m);
+
+cairo_private void
 _cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx,
 			       const char *name,
 			       GLuint tex_unit);
diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index a39883d..1b10b04 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -93,6 +93,12 @@ typedef struct cairo_gl_shader_impl {
 		    cairo_matrix_t* m);
 
     void
+    (*bind_matrix4f) (cairo_gl_context_t *ctx,
+		      cairo_gl_shader_t *shader,
+		      const char *name,
+		      GLfloat* gl_m);
+
+    void
     (*bind_texture) (cairo_gl_context_t *ctx,
 		     cairo_gl_shader_t *shader,
 		     const char *name,
@@ -263,6 +269,18 @@ bind_matrix_core_2_0 (cairo_gl_context_t *ctx,
 }
 
 static void
+bind_matrix4f_core_2_0 (cairo_gl_context_t *ctx,
+		        cairo_gl_shader_t *shader,
+		        const char *name,
+		        GLfloat* gl_m)
+{
+    cairo_gl_dispatch_t *dispatch = &ctx->dispatch;
+    GLint location = dispatch->GetUniformLocation (shader->program, name);
+    assert (location != -1);
+    dispatch->UniformMatrix4fv (location, 1, GL_FALSE, gl_m);
+}
+
+static void
 bind_texture_core_2_0 (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader,
 		       const char *name, cairo_gl_tex_t tex_unit)
 {
@@ -292,6 +310,7 @@ static const cairo_gl_shader_impl_t shader_impl_core_2_0 = {
     bind_vec3_core_2_0,
     bind_vec4_core_2_0,
     bind_matrix_core_2_0,
+    bind_matrix4f_core_2_0,
     bind_texture_core_2_0,
     use_program_core_2_0,
 };
@@ -798,6 +817,13 @@ _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx,
 }
 
 void
+_cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx,
+				const char *name, GLfloat* gl_m)
+{
+    ctx->shader_impl->bind_matrix4f (ctx, ctx->current_shader, name, gl_m);
+}
+
+void
 _cairo_gl_shader_bind_texture (cairo_gl_context_t *ctx,
 			       const char *name, GLuint tex_unit)
 {
commit 966e4a1738c5dc97149ff7bd58e54fa86f048c16
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Mon Jan 31 15:55:07 2011 +0200

    gl: Add entry for UniformMatrix4fv in the gl dispatch table
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gl-dispatch-private.h b/src/cairo-gl-dispatch-private.h
index f3245ed..bd444a5 100644
--- a/src/cairo-gl-dispatch-private.h
+++ b/src/cairo-gl-dispatch-private.h
@@ -83,6 +83,7 @@ cairo_private cairo_gl_dispatch_entry_t dispatch_shaders_entries[] = {
     DISPATCH_ENTRY_ARB (Uniform3f),
     DISPATCH_ENTRY_ARB (Uniform4f),
     DISPATCH_ENTRY_ARB (UniformMatrix3fv),
+    DISPATCH_ENTRY_ARB (UniformMatrix4fv),
     DISPATCH_ENTRY_ARB (Uniform1i),
     DISPATCH_ENTRY_LAST
 };
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 6cea8c0..04322f2 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -210,6 +210,8 @@ typedef struct _cairo_gl_dispatch {
 			 GLfloat w);
     void (*UniformMatrix3fv) (GLint location, GLsizei count,
 				GLboolean transpose, const GLfloat *value);
+    void (*UniformMatrix4fv) (GLint location, GLsizei count,
+			      GLboolean transpose, const GLfloat *value);
     void (*Uniform1i) (GLint location, GLint x);
 
     /* Framebuffer objects */


More information about the cairo-commit mailing list