gl: Only unbind buffers/vertex attrib arrays if we can't directly bind the vertex...
authorSebastian Dröge <sebastian@centricular.com>
Wed, 16 Jan 2019 12:09:18 +0000 (14:09 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 16 Jan 2019 12:09:18 +0000 (14:09 +0200)
Binding the vertex array to 0 will unbind everything else already.

In the previous order older versions of the Intel GL driver caused
errors to be printed for every single call when disabling the vertex
attrib arrays after binding the vertex array to 0.

12 files changed:
ext/gl/caopengllayersink.m
ext/gl/gltestsrc.c
ext/gl/gstglfiltercube.c
ext/gl/gstglimagesink.c
ext/gl/gstgloverlay.c
ext/gl/gstgltransformation.c
ext/gl/gstglvideomixer.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 1cb72e5..5c7b476 100644 (file)
@@ -1005,7 +1005,8 @@ gst_ca_opengl_layer_sink_on_draw (GstCAOpenGLLayerSink * ca_sink)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  _unbind_buffer (ca_sink);
+  else
+    _unbind_buffer (ca_sink);
 
   /* end default opengl scene */
   GST_CA_OPENGL_LAYER_SINK_UNLOCK (ca_sink);
index f6faea3..c822103 100644 (file)
@@ -222,7 +222,8 @@ _src_shader_fill_bound_fbo (gpointer impl)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  _unbind_buffer (src);
+  else
+    _unbind_buffer (src);
 
   gst_gl_context_clear_shader (src->base.context);
 
index 9e04ea0..776aece 100644 (file)
@@ -484,7 +484,8 @@ _callback (gpointer stuff)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  _unbind_buffer (cube_filter);
+  else
+    _unbind_buffer (cube_filter);
 
   gl->Disable (GL_DEPTH_TEST);
 
index aa0ae40..3fcdced 100644 (file)
@@ -2299,7 +2299,8 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink)
 
     if (gl->GenVertexArrays)
       gl->BindVertexArray (0);
-    _unbind_buffer (gl_sink);
+    else
+      _unbind_buffer (gl_sink);
 
     if (gl_sink->ignore_alpha)
       gl->Disable (GL_BLEND);
index a2c9fbb..72f6ff4 100644 (file)
@@ -545,7 +545,8 @@ gst_gl_overlay_callback (GstGLFilter * filter, GstGLMemory * in_tex,
 out:
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  _unbind_buffer (overlay);
+  else
+    _unbind_buffer (overlay);
 
   gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
 
index bb4bd2c..dba8733 100644 (file)
@@ -961,7 +961,8 @@ gst_gl_transformation_callback (gpointer stuff)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  _unbind_buffer (transformation);
+  else
+    _unbind_buffer (transformation);
 
   gst_gl_context_clear_shader (GST_GL_BASE_FILTER (filter)->context);
   transformation->caps_change = FALSE;
index 0306d22..1e14c5e 100644 (file)
@@ -1613,15 +1613,16 @@ gst_gl_video_mixer_callback (gpointer stuff)
   video_mixer->output_geo_change = FALSE;
   GST_OBJECT_UNLOCK (video_mixer);
 
-  gl->DisableVertexAttribArray (attr_position_loc);
-  gl->DisableVertexAttribArray (attr_texture_loc);
-
-  if (gl->GenVertexArrays)
+  if (gl->GenVertexArrays) {
     gl->BindVertexArray (0);
+  } else {
+    gl->DisableVertexAttribArray (attr_position_loc);
+    gl->DisableVertexAttribArray (attr_texture_loc);
 
-  gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
-  gl->BindBuffer (GL_ARRAY_BUFFER, 0);
-  gl->BindTexture (GL_TEXTURE_2D, 0);
+    gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
+    gl->BindBuffer (GL_ARRAY_BUFFER, 0);
+    gl->BindTexture (GL_TEXTURE_2D, 0);
+  }
 
   gl->Disable (GL_BLEND);
 
index 3247735..297d371 100644 (file)
@@ -2589,7 +2589,8 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
 
   if (gl->BindVertexArray)
     gl->BindVertexArray (0);
-  _unbind_buffer (convert);
+  else
+    _unbind_buffer (convert);
 
   if (gl->DrawBuffer)
     gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
index aba9daa..bb38fb6 100644 (file)
@@ -1251,6 +1251,7 @@ gst_gl_filter_draw_fullscreen_quad (GstGLFilter * filter)
 
     if (gl->GenVertexArrays)
       gl->BindVertexArray (0);
-    _unbind_buffer (filter);
+    else
+      _unbind_buffer (filter);
   }
 }
index f057ce1..63a6789 100644 (file)
@@ -1928,7 +1928,8 @@ _do_view_convert_draw (GstGLContext * context, GstGLViewConvert * viewconvert)
 
   if (gl->BindVertexArray)
     gl->BindVertexArray (0);
-  _unbind_buffer (viewconvert);
+  else
+    _unbind_buffer (viewconvert);
   if (gl->DrawBuffer)
     gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
   /* we are done with the shader */
index 37bac2c..bc2e40e 100644 (file)
@@ -246,7 +246,8 @@ blit_tex (gpointer data)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  _unbind_buffer (context);
+  else
+    _unbind_buffer (context);
 
   return TRUE;
 }
index fe3efea..516655f 100644 (file)
@@ -247,7 +247,8 @@ blit_tex (gpointer data)
 
   if (gl->GenVertexArrays)
     gl->BindVertexArray (0);
-  _unbind_buffer (context);
+  else
+    _unbind_buffer (context);
 
   return TRUE;
 }