gl: GL_ARRAY_BUFFER is not a part of VAO state
authorMatthew Waters <matthew@centricular.com>
Tue, 14 Mar 2017 03:15:00 +0000 (14:15 +1100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:32:27 +0000 (19:32 +0000)
As a result we need to bind it on every draw in order to have the
correct state in the GL state machine.

ext/gl/caopengllayersink.m
ext/gl/gltestsrc.c
ext/gl/gstglfiltercube.c
ext/gl/gstglimagesink.c
ext/gl/gstgloverlay.c
ext/gl/gstgltransformation.c
gst-libs/gst/gl/gstglcolorconvert.c
gst-libs/gst/gl/gstglfilter.c
gst-libs/gst/gl/gstglviewconvert.c
tests/check/libs/gstglcontext.c
tests/check/libs/gstglupload.c

index 1e42034..fc96258 100644 (file)
@@ -995,8 +995,7 @@ gst_ca_opengl_layer_sink_on_draw (GstCAOpenGLLayerSink * ca_sink)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (ca_sink->vao);
-  else
-    _bind_buffer (ca_sink);
+  _bind_buffer (ca_sink);
 
   gl->ActiveTexture (GL_TEXTURE0);
   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)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (ca_sink);
+  _unbind_buffer (ca_sink);
 
   /* end default opengl scene */
   GST_CA_OPENGL_LAYER_SINK_UNLOCK (ca_sink);
index 87e302c..ac845c6 100644 (file)
@@ -213,16 +213,14 @@ _src_shader_fill_bound_fbo (gpointer impl)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (src->vao);
-  else
-    _bind_buffer (src);
+  _bind_buffer (src);
 
   gl->DrawElements (GL_TRIANGLES, src->n_indices, GL_UNSIGNED_SHORT,
       (gpointer) (gintptr) src->index_offset);
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (src);
+  _unbind_buffer (src);
 
   gst_gl_context_clear_shader (src->base.context);
 
index 0d58656..735d45e 100644 (file)
@@ -476,15 +476,13 @@ _callback (gpointer stuff)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (cube_filter->vao);
-  else
-    _bind_buffer (cube_filter);
+  _bind_buffer (cube_filter);
 
   gl->DrawElements (GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (cube_filter);
+  _unbind_buffer (cube_filter);
 
   gl->Disable (GL_DEPTH_TEST);
 
index 2b20b1e..1c8d314 100644 (file)
@@ -2228,8 +2228,7 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink)
 
     if (gl->GenVertexArrays)
       gl->BindVertexArray (gl_sink->vao);
-    else
-      _bind_buffer (gl_sink);
+    _bind_buffer (gl_sink);
 
     gl->ActiveTexture (GL_TEXTURE0);
     gl->BindTexture (gl_target, gl_sink->redisplay_texture);
@@ -2258,8 +2257,7 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink)
 
     if (gl->GenVertexArrays)
       gl->BindVertexArray (0);
-    else
-      _unbind_buffer (gl_sink);
+    _unbind_buffer (gl_sink);
 
     if (gl_sink->ignore_alpha)
       gl->Disable (GL_BLEND);
index 9846f53..8c21bac 100644 (file)
@@ -522,9 +522,7 @@ gst_gl_overlay_callback (GstGLFilter * filter, GstGLMemory * in_tex,
         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);
   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;
 
 out:
-  if (gl->GenVertexArrays) {
+  if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  } else {
-    _unbind_buffer (overlay);
-  }
+  _unbind_buffer (overlay);
 
   gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
 
index eec262b..f6c9e3f 100644 (file)
@@ -960,19 +960,15 @@ gst_gl_transformation_callback (gpointer stuff)
   if (gl->GenVertexArrays)
     gl->BindVertexArray (transformation->vao);
 
-  if (transformation->caps_change) {
+  if (transformation->caps_change)
     _upload_vertices (transformation);
-    _bind_buffer (transformation);
-  } else if (!gl->GenVertexArrays) {
-    _bind_buffer (transformation);
-  }
+  _bind_buffer (transformation);
 
   gl->DrawElements (GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, 0);
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (transformation);
+  _unbind_buffer (transformation);
 
   gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
   transformation->caps_change = FALSE;
index b04e414..4373be5 100644 (file)
@@ -2476,8 +2476,7 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
 
   if (gl->BindVertexArray)
     gl->BindVertexArray (convert->priv->vao);
-  else
-    _bind_buffer (convert);
+  _bind_buffer (convert);
 
   for (i = c_info->in_n_textures - 1; i >= 0; 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)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (convert);
+  _unbind_buffer (convert);
 
   if (gl->DrawBuffer)
     gl->DrawBuffer (GL_NONE);
index f0c02cf..61cce02 100644 (file)
@@ -1203,26 +1203,16 @@ gst_gl_filter_draw_fullscreen_quad (GstGLFilter * filter)
       gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, filter->vbo_indices);
       gl->BufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (indices), indices,
           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)
       gl->BindVertexArray (filter->vao);
-    else
-      _bind_buffer (filter);
+    _bind_buffer (filter);
 
     gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
 
     if (gl->GenVertexArrays)
       gl->BindVertexArray (0);
-    else
-      _unbind_buffer (filter);
+    _unbind_buffer (filter);
   }
 }
index 2d119e6..86f877e 100644 (file)
@@ -1923,8 +1923,7 @@ _do_view_convert_draw (GstGLContext * context, GstGLViewConvert * viewconvert)
 
   if (gl->BindVertexArray)
     gl->BindVertexArray (priv->vao);
-  else
-    _bind_buffer (viewconvert);
+  _bind_buffer (viewconvert);
 
   if (in_mode == GST_VIDEO_MULTIVIEW_MODE_SEPARATED ||
       in_mode == GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME) {
@@ -1944,8 +1943,7 @@ _do_view_convert_draw (GstGLContext * context, GstGLViewConvert * viewconvert)
 
   if (gl->BindVertexArray)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (viewconvert);
+  _unbind_buffer (viewconvert);
   if (gl->DrawBuffer)
     gl->DrawBuffer (GL_NONE);
   /* we are done with the shader */
index 96c5d92..c0b9117 100644 (file)
@@ -239,15 +239,13 @@ blit_tex (gpointer data)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (vao);
-  else
-    _bind_buffer (context);
+  _bind_buffer (context);
 
   gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (context);
+  _unbind_buffer (context);
 
   return TRUE;
 }
index 7508cf5..d036916 100644 (file)
@@ -237,8 +237,7 @@ blit_tex (gpointer data)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (vao);
-  else
-    _bind_buffer (context);
+  _bind_buffer (context);
 
   gl->ActiveTexture (GL_TEXTURE0);
   gl->BindTexture (GL_TEXTURE_2D, tex_id);
@@ -248,8 +247,7 @@ blit_tex (gpointer data)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  else
-    _unbind_buffer (context);
+  _unbind_buffer (context);
 
   return TRUE;
 }