mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
glfilter: retrieve the shader attributes from the GL thread
Otherwise we will receive bogus values https://bugzilla.gnome.org/show_bug.cgi?id=763365
This commit is contained in:
parent
59da66f969
commit
92b9b57d3e
2 changed files with 26 additions and 18 deletions
|
@ -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);
|
||||
|
|
|
@ -71,6 +71,7 @@ struct _GstGLFilter
|
|||
GLuint out_tex_id;
|
||||
|
||||
GstGLShader *default_shader;
|
||||
gboolean valid_attributes;
|
||||
|
||||
GLuint vao;
|
||||
GLuint vbo_indices;
|
||||
|
|
Loading…
Reference in a new issue