diff mbox

[19/21] gl: Define the float precision in the fragment shader for GLES2

Message ID 1311602208-5973-19-git-send-email-alexandros.frantzis@linaro.org
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org July 25, 2011, 1:56 p.m. UTC
From: Alexandros Frantzis <alexandros.frantzis@linaro.org>

According to the GLSL ES standard, the precision of variables in the fragment
shader should be explicitly defined (although mesa's compiler is not that
strict).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 src/cairo-gl-shaders.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/src/cairo-gl-shaders.c b/src/cairo-gl-shaders.c
index 77a28aa..7d60c0f 100644
--- a/src/cairo-gl-shaders.c
+++ b/src/cairo-gl-shaders.c
@@ -385,6 +385,9 @@  cairo_status_t
 _cairo_gl_context_init_shaders (cairo_gl_context_t *ctx)
 {
     static const char *fill_fs_source =
+	"#ifdef GL_ES\n"
+	"precision mediump float;\n"
+	"#endif\n"
 	"uniform vec4 color;\n"
 	"void main()\n"
 	"{\n"
@@ -847,6 +850,11 @@  cairo_gl_shader_get_fragment_source (cairo_gl_context_t *ctx,
     unsigned long length;
     cairo_status_t status;
 
+    _cairo_output_stream_printf (stream,
+	"#ifdef GL_ES\n"
+	"precision mediump float;\n"
+	"#endif\n");
+
     if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES) {
 	if (_cairo_gl_shader_needs_border_fade (src))
 	    _cairo_gl_shader_emit_border_fade (stream, src, CAIRO_GL_TEX_SOURCE);