gl: GL_ARRAY_BUFFER is not a part of VAO state

As a result we need to bind it on every draw in order to have the
correct state in the GL state machine.
This commit is contained in:
Matthew Waters 2017-03-14 14:15:00 +11:00
parent b01ae6e5e6
commit efc015f27d
12 changed files with 26 additions and 62 deletions

View file

@ -995,8 +995,7 @@ gst_ca_opengl_layer_sink_on_draw (GstCAOpenGLLayerSink * ca_sink)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (ca_sink->vao); gl->BindVertexArray (ca_sink->vao);
else _bind_buffer (ca_sink);
_bind_buffer (ca_sink);
gl->ActiveTexture (GL_TEXTURE0); gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, ca_sink->redisplay_texture); gl->BindTexture (GL_TEXTURE_2D, ca_sink->redisplay_texture);
@ -1006,8 +1005,7 @@ gst_ca_opengl_layer_sink_on_draw (GstCAOpenGLLayerSink * ca_sink)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (ca_sink);
_unbind_buffer (ca_sink);
/* end default opengl scene */ /* end default opengl scene */
GST_CA_OPENGL_LAYER_SINK_UNLOCK (ca_sink); GST_CA_OPENGL_LAYER_SINK_UNLOCK (ca_sink);

View file

@ -213,16 +213,14 @@ _src_shader_fill_bound_fbo (gpointer impl)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (src->vao); gl->BindVertexArray (src->vao);
else _bind_buffer (src);
_bind_buffer (src);
gl->DrawElements (GL_TRIANGLES, src->n_indices, GL_UNSIGNED_SHORT, gl->DrawElements (GL_TRIANGLES, src->n_indices, GL_UNSIGNED_SHORT,
(gpointer) (gintptr) src->index_offset); (gpointer) (gintptr) src->index_offset);
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (src);
_unbind_buffer (src);
gst_gl_context_clear_shader (src->base.context); gst_gl_context_clear_shader (src->base.context);

View file

@ -476,15 +476,13 @@ _callback (gpointer stuff)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (cube_filter->vao); gl->BindVertexArray (cube_filter->vao);
else _bind_buffer (cube_filter);
_bind_buffer (cube_filter);
gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0); gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (cube_filter);
_unbind_buffer (cube_filter);
gl->Disable (GL_DEPTH_TEST); gl->Disable (GL_DEPTH_TEST);

View file

@ -2228,8 +2228,7 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (gl_sink->vao); gl->BindVertexArray (gl_sink->vao);
else _bind_buffer (gl_sink);
_bind_buffer (gl_sink);
gl->ActiveTexture (GL_TEXTURE0); gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (gl_target, gl_sink->redisplay_texture); gl->BindTexture (gl_target, gl_sink->redisplay_texture);
@ -2258,8 +2257,7 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (gl_sink);
_unbind_buffer (gl_sink);
if (gl_sink->ignore_alpha) if (gl_sink->ignore_alpha)
gl->Disable (GL_BLEND); gl->Disable (GL_BLEND);

View file

@ -522,9 +522,7 @@ gst_gl_overlay_callback (GstGLFilter * filter, GstGLMemory * in_tex,
GL_STATIC_DRAW); GL_STATIC_DRAW);
} }
if (!gl->GenVertexArrays || overlay->geometry_change) { _bind_buffer (overlay, overlay->overlay_vbo);
_bind_buffer (overlay, overlay->overlay_vbo);
}
gl->BindTexture (GL_TEXTURE_2D, image_tex); gl->BindTexture (GL_TEXTURE_2D, image_tex);
gst_gl_shader_set_uniform_1f (overlay->shader, "alpha", overlay->alpha); gst_gl_shader_set_uniform_1f (overlay->shader, "alpha", overlay->alpha);
@ -539,11 +537,9 @@ gst_gl_overlay_callback (GstGLFilter * filter, GstGLMemory * in_tex,
ret = TRUE; ret = TRUE;
out: out:
if (gl->GenVertexArrays) { if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
} else { _unbind_buffer (overlay);
_unbind_buffer (overlay);
}
gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context); gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);

View file

@ -960,19 +960,15 @@ gst_gl_transformation_callback (gpointer stuff)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (transformation->vao); gl->BindVertexArray (transformation->vao);
if (transformation->caps_change) { if (transformation->caps_change)
_upload_vertices (transformation); _upload_vertices (transformation);
_bind_buffer (transformation); _bind_buffer (transformation);
} else if (!gl->GenVertexArrays) {
_bind_buffer (transformation);
}
gl->DrawElements (GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, 0); gl->DrawElements (GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, 0);
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (transformation);
_unbind_buffer (transformation);
gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context); gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
transformation->caps_change = FALSE; transformation->caps_change = FALSE;

View file

@ -191,8 +191,7 @@ _redraw_texture (GtkGstGLWidget * gst_widget, guint tex)
if (gl->BindVertexArray) if (gl->BindVertexArray)
gl->BindVertexArray (priv->vao); gl->BindVertexArray (priv->vao);
else gtk_gst_gl_widget_bind_buffer (gst_widget);
gtk_gst_gl_widget_bind_buffer (gst_widget);
gl->ActiveTexture (GL_TEXTURE0); gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, tex); gl->BindTexture (GL_TEXTURE_2D, tex);
@ -202,8 +201,7 @@ _redraw_texture (GtkGstGLWidget * gst_widget, guint tex)
if (gl->BindVertexArray) if (gl->BindVertexArray)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else gtk_gst_gl_widget_unbind_buffer (gst_widget);
gtk_gst_gl_widget_unbind_buffer (gst_widget);
gl->BindTexture (GL_TEXTURE_2D, 0); gl->BindTexture (GL_TEXTURE_2D, 0);
} }

View file

@ -2476,8 +2476,7 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
if (gl->BindVertexArray) if (gl->BindVertexArray)
gl->BindVertexArray (convert->priv->vao); gl->BindVertexArray (convert->priv->vao);
else _bind_buffer (convert);
_bind_buffer (convert);
for (i = c_info->in_n_textures - 1; i >= 0; i--) { for (i = c_info->in_n_textures - 1; i >= 0; i--) {
gchar *scale_name = g_strdup_printf ("tex_scale%u", i); gchar *scale_name = g_strdup_printf ("tex_scale%u", i);
@ -2501,8 +2500,7 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
if (gl->BindVertexArray) if (gl->BindVertexArray)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (convert);
_unbind_buffer (convert);
if (gl->DrawBuffer) if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE); gl->DrawBuffer (GL_NONE);

View file

@ -1203,26 +1203,16 @@ gst_gl_filter_draw_fullscreen_quad (GstGLFilter * filter)
gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, filter->vbo_indices); gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, filter->vbo_indices);
gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices, gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
GL_STATIC_DRAW); GL_STATIC_DRAW);
if (gl->GenVertexArrays) {
_bind_buffer (filter);
gl->BindVertexArray (0);
}
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
} }
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (filter->vao); gl->BindVertexArray (filter->vao);
else _bind_buffer (filter);
_bind_buffer (filter);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (filter);
_unbind_buffer (filter);
} }
} }

View file

@ -1923,8 +1923,7 @@ _do_view_convert_draw (GstGLContext * context, GstGLViewConvert * viewconvert)
if (gl->BindVertexArray) if (gl->BindVertexArray)
gl->BindVertexArray (priv->vao); gl->BindVertexArray (priv->vao);
else _bind_buffer (viewconvert);
_bind_buffer (viewconvert);
if (in_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED || if (in_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) { in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
@ -1944,8 +1943,7 @@ _do_view_convert_draw (GstGLContext * context, GstGLViewConvert * viewconvert)
if (gl->BindVertexArray) if (gl->BindVertexArray)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (viewconvert);
_unbind_buffer (viewconvert);
if (gl->DrawBuffer) if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE); gl->DrawBuffer (GL_NONE);
/* we are done with the shader */ /* we are done with the shader */

View file

@ -239,15 +239,13 @@ blit_tex (gpointer data)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (vao); gl->BindVertexArray (vao);
else _bind_buffer (context);
_bind_buffer (context);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (context);
_unbind_buffer (context);
return TRUE; return TRUE;
} }

View file

@ -237,8 +237,7 @@ blit_tex (gpointer data)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (vao); gl->BindVertexArray (vao);
else _bind_buffer (context);
_bind_buffer (context);
gl->ActiveTexture (GL_TEXTURE0); gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_2D, tex_id); gl->BindTexture (GL_TEXTURE_2D, tex_id);
@ -248,8 +247,7 @@ blit_tex (gpointer data)
if (gl->GenVertexArrays) if (gl->GenVertexArrays)
gl->BindVertexArray (0); gl->BindVertexArray (0);
else _unbind_buffer (context);
_unbind_buffer (context);
return TRUE; return TRUE;
} }