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
This commit is contained in:
Matthew Waters 2019-05-07 18:36:01 +10:00
parent f8bed33d4b
commit 15cb86435d

View file

@ -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);
}