From 0a9807a01491fbb662559e1bc146a8a7a4cf6172 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Tue, 7 May 2019 18:36:01 +1000 Subject: [PATCH] glshader: fix default external-oes shaders In glsl, #extension directives need to before other non-preprocesser directives. We were placing the precision qualifier before that. Fix by moving the #extension to the first line in the shader. Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/601 --- gst-libs/gst/gl/gstglshaderstrings.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/gl/gstglshaderstrings.c b/gst-libs/gst/gl/gstglshaderstrings.c index 4d7ac3d..ecc5da1 100644 --- a/gst-libs/gst/gl/gstglshaderstrings.c +++ b/gst-libs/gst/gl/gstglshaderstrings.c @@ -84,8 +84,10 @@ const gchar *gst_gl_shader_string_fragment_default = MEDIUMP_PRECISION DEFAULT_FRAGMENT_BODY; +#define EXTERNAL_FRAGMENT_HEADER \ + "#extension GL_OES_EGL_image_external : require\n" + #define EXTERNAL_FRAGMENT_BODY \ - "#extension GL_OES_EGL_image_external : require\n" \ "varying vec2 v_texcoord;\n" \ "uniform samplerExternalOES tex;\n" \ "void main()\n" \ @@ -93,6 +95,7 @@ const gchar *gst_gl_shader_string_fragment_default = " gl_FragColor = texture2D(tex, v_texcoord);\n" \ "}" const gchar *gst_gl_shader_string_fragment_external_oes_default = + EXTERNAL_FRAGMENT_HEADER MEDIUMP_PRECISION EXTERNAL_FRAGMENT_BODY; /* *INDENT-ON* */ @@ -168,5 +171,6 @@ gst_gl_shader_string_fragment_external_oes_get_default (GstGLContext * context, const gchar *precision = gst_gl_shader_string_get_highest_precision (context, version, profile); - return g_strdup_printf ("%s%s", precision, EXTERNAL_FRAGMENT_BODY); + return g_strdup_printf ("%s%s%s", EXTERNAL_FRAGMENT_HEADER, precision, + EXTERNAL_FRAGMENT_BODY); } -- 2.7.4