From: Matthew Waters Date: Wed, 9 Mar 2016 13:27:53 +0000 (+1100) Subject: glfilter: retrieve the shader attributes from the GL thread X-Git-Tag: 1.10.4~1031 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92b9b57d3ea0029358b1b76944a3afc7589043b4;p=platform%2Fupstream%2Fgst-plugins-bad.git glfilter: retrieve the shader attributes from the GL thread Otherwise we will receive bogus values https://bugzilla.gnome.org/show_bug.cgi?id=763365 --- diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index 2c518e314..1e18e410e 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -1031,6 +1031,28 @@ gst_gl_filter_render_to_target (GstGLFilter * filter, gboolean resize, filter->fbo, filter->depthbuffer, target, _glcb2, &cb); } +static void +_get_attributes (GstGLFilter * filter) +{ + if (!filter->default_shader) + return; + + if (filter->valid_attributes) + return; + + if (filter->draw_attr_position_loc == -1) + filter->draw_attr_position_loc = + gst_gl_shader_get_attribute_location (filter->default_shader, + "a_position"); + + if (filter->draw_attr_texture_loc == -1) + filter->draw_attr_texture_loc = + gst_gl_shader_get_attribute_location (filter->default_shader, + "a_texcoord"); + + filter->valid_attributes = TRUE; +} + static void _draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff) { @@ -1045,6 +1067,7 @@ _draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff) } #endif + _get_attributes (filter); gst_gl_shader_use (filter->default_shader); gl->ActiveTexture (GL_TEXTURE1); @@ -1057,23 +1080,6 @@ _draw_with_shader_cb (gint width, gint height, guint texture, gpointer stuff) gst_gl_filter_draw_texture (filter, texture, width, height); } -static void -_get_attributes (GstGLFilter * filter) -{ - if (!filter->default_shader) - return; - - if (filter->draw_attr_position_loc == -1) - filter->draw_attr_position_loc = - gst_gl_shader_get_attribute_location (filter->default_shader, - "a_position"); - - if (filter->draw_attr_texture_loc == -1) - filter->draw_attr_texture_loc = - gst_gl_shader_get_attribute_location (filter->default_shader, - "a_texcoord"); -} - /** * gst_gl_filter_render_to_target_with_shader: * @filter: a #GstGLFilter @@ -1094,8 +1100,9 @@ void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter, gboolean resize, GLuint input, GLuint target, GstGLShader * shader) { + if (filter->default_shader != shader) + filter->valid_attributes = FALSE; filter->default_shader = shader; - _get_attributes (filter); gst_gl_filter_render_to_target (filter, resize, input, target, _draw_with_shader_cb, filter); diff --git a/gst-libs/gst/gl/gstglfilter.h b/gst-libs/gst/gl/gstglfilter.h index 94ab33394..a818bab24 100644 --- a/gst-libs/gst/gl/gstglfilter.h +++ b/gst-libs/gst/gl/gstglfilter.h @@ -71,6 +71,7 @@ struct _GstGLFilter GLuint out_tex_id; GstGLShader *default_shader; + gboolean valid_attributes; GLuint vao; GLuint vbo_indices;