From 4fd7a2c783e96e5ebec513f8fd178ba34b2a527f Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 7 Jun 2019 20:51:39 +1000 Subject: [PATCH] gl/tests: fix shader creation tests 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 | 10 +++++----- tests/check/libs/gstglslstage.c | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/check/libs/gstglheaders.c b/tests/check/libs/gstglheaders.c index 088ce28eec..0ec396ba70 100644 --- a/tests/check/libs/gstglheaders.c +++ b/tests/check/libs/gstglheaders.c @@ -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) diff --git a/tests/check/libs/gstglslstage.c b/tests/check/libs/gstglslstage.c index d497328b88..c5814a405c 100644 --- a/tests/check/libs/gstglslstage.c +++ b/tests/check/libs/gstglslstage.c @@ -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));