[vlc-devel] [PATCH 11/18] opengl: initialize fshader from vout_helper

Romain Vimont rom1v at videolabs.io
Fri Dec 20 15:48:53 CET 2019


Initialize the fragment shader from the vout module directly. The
"glconv" modules are not responsible for initializing the fragment
shader anymore.
---
 modules/video_output/opengl/converter_sw.c     | 16 +++++-----------
 modules/video_output/opengl/fragment_shaders.c |  5 -----
 modules/video_output/opengl/vout_helper.c      | 12 ++++++++++++
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/modules/video_output/opengl/converter_sw.c b/modules/video_output/opengl/converter_sw.c
index 10c2928558..17a8f6d991 100644
--- a/modules/video_output/opengl/converter_sw.c
+++ b/modules/video_output/opengl/converter_sw.c
@@ -299,7 +299,6 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
 {
     struct vlc_gl_importer *imp = &tc->importer;
 
-    GLuint fragment_shader = 0;
     video_color_space_t space;
     const vlc_fourcc_t *list;
 
@@ -325,11 +324,11 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
         space = COLOR_SPACE_UNDEF;
     }
 
+    int ret = VLC_EGENERIC;
     while (*list)
     {
-        fragment_shader =
-            opengl_fragment_shader_init(tc, GL_TEXTURE_2D, *list, space);
-        if (fragment_shader != 0)
+        ret = opengl_importer_init(imp, GL_TEXTURE_2D, *list, space);
+        if (ret == VLC_SUCCESS)
         {
             imp->fmt.i_chroma = *list;
 
@@ -350,15 +349,12 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
         }
         list++;
     }
-    if (fragment_shader == 0)
-        return VLC_EGENERIC;
+    if (ret != VLC_SUCCESS)
+        return ret;
 
     struct priv *priv = imp->priv = calloc(1, sizeof(struct priv));
     if (unlikely(priv == NULL))
-    {
-        imp->vt->DeleteShader(fragment_shader);
         return VLC_ENOMEM;
-    }
 
     static const struct vlc_gl_importer_ops ops = {
         .allocate_textures = tc_common_allocate_textures,
@@ -393,8 +389,6 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
         }
     }
 
-    tc->fshader = fragment_shader;
-
     return VLC_SUCCESS;
 }
 
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index b9e3c6ad11..f639397d90 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -578,11 +578,6 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
     if (desc == NULL)
         return 0;
 
-    ret = opengl_importer_init_impl(&tc->importer, tex_target, chroma,
-                                    yuv_space);
-    if (ret != VLC_SUCCESS)
-        return 0;
-
     if (chroma == VLC_CODEC_XYZ12)
         return xyz12_shader_init(tc);
 
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 8528622476..1846fddb61 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -623,6 +623,18 @@ opengl_init_program(vout_display_opengl_t *vgl, vlc_video_context *context,
         return VLC_EGENERIC;
     }
 
+    GLuint fragment_shader =
+        opengl_fragment_shader_init_impl(tc, imp->tex_target,
+                                         imp->sw_fmt.i_chroma,
+                                         imp->sw_fmt.space);
+    if (!fragment_shader)
+    {
+        vlc_object_delete(tc);
+        return VLC_EGENERIC;
+    }
+
+    tc->fshader = fragment_shader;
+
     assert(tc->fshader != 0 &&
            imp->tex_target != 0 &&
            imp->tex_count > 0 &&
-- 
2.24.1



More information about the vlc-devel mailing list