gl/tests: fix shader creation tests
authorMatthew Waters <matthew@centricular.com>
Fri, 7 Jun 2019 10:51:39 +0000 (20:51 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 9 Aug 2019 14:59:26 +0000 (15:59 +0100)
We check the availability of the high precision floats in GLSL shaders
which involves an OpenGL call and thus is required to be executed on the
OpenGL thread.

The tests were not respecting that and could fail on more strict
drivers.

Tests update for 675415bf2ea9ddc75ea5e5b6eae9ae942c19d6dc
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/590

tests/check/libs/gstglheaders.c
tests/check/libs/gstglslstage.c

index 088ce28..0ec396b 100644 (file)
@@ -104,7 +104,6 @@ teardown (void)
 GST_START_TEST (test_constructors)
 {
   GstBufferPool *pool = NULL;
-  GstGLShader *shader = NULL;
   GstGLSLStage *stage = NULL;
   GstGLColorConvert *convert = NULL;
   GstGLOverlayCompositor *compositor = NULL;
@@ -114,10 +113,6 @@ GST_START_TEST (test_constructors)
   fail_if (pool == NULL);
   gst_object_unref (pool);
 
-  shader = gst_gl_shader_new (context);
-  fail_if (shader == NULL);
-  gst_object_unref (shader);
-
   stage = gst_glsl_stage_new_default_fragment (context);
   fail_if (stage == NULL);
   gst_object_unref (stage);
@@ -141,10 +136,15 @@ static void
 _construct_with_activated_context (GstGLContext * context, gpointer unused)
 {
   GstGLFramebuffer *framebuffer = NULL;
+  GstGLShader *shader = NULL;
 
   framebuffer = gst_gl_framebuffer_new (context);
   fail_if (framebuffer == NULL);
   gst_object_unref (framebuffer);
+
+  shader = gst_gl_shader_new (context);
+  fail_if (shader == NULL);
+  gst_object_unref (shader);
 }
 
 GST_START_TEST (test_constructors_require_activated_context)
index d497328..c5814a4 100644 (file)
@@ -68,12 +68,20 @@ GST_START_TEST (test_default_vertex)
 
 GST_END_TEST;
 
+static void
+create_frag_shader (GstGLContext * context, GstGLSLStage ** stage)
+{
+  *stage = gst_glsl_stage_new_default_fragment (context);
+}
+
 GST_START_TEST (test_default_fragment)
 {
   GstGLSLStage *stage;
   GError *error = NULL;
 
-  stage = gst_glsl_stage_new_default_fragment (context);
+  gst_gl_context_thread_add (context,
+      (GstGLContextThreadFunc) create_frag_shader, &stage);
+
   fail_unless (stage != NULL);
   fail_unless (GL_FRAGMENT_SHADER == gst_glsl_stage_get_shader_type (stage));