[vlc-commits] opengl: initialize fshader from vout_helper

Romain Vimont git at videolan.org
Mon Jan 13 11:44:19 CET 2020


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Wed Dec  4 16:13:50 2019 +0100| [2bdf0ebb79c1c3165cf09487647a5c13ea06a01a] | committer: Thomas Guillem

opengl: initialize fshader from vout_helper

Initialize the fragment shader from the vout module directly. The
"glconv" modules are not responsible for initializing the fragment
shader anymore.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2bdf0ebb79c1c3165cf09487647a5c13ea06a01a
---

 modules/video_output/opengl/converter_sw.c     | 16 +++++-----------
 modules/video_output/opengl/fragment_shaders.c |  4 ----
 modules/video_output/opengl/vout_helper.c      | 12 ++++++++++++
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/modules/video_output/opengl/converter_sw.c b/modules/video_output/opengl/converter_sw.c
index 5c59a53bfa..c441c68ae2 100644
--- a/modules/video_output/opengl/converter_sw.c
+++ b/modules/video_output/opengl/converter_sw.c
@@ -300,7 +300,6 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
 {
     struct vlc_gl_interop *interop = &tc->interop;
 
-    GLuint fragment_shader = 0;
     video_color_space_t space;
     const vlc_fourcc_t *list;
 
@@ -326,11 +325,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_interop_init(interop, GL_TEXTURE_2D, *list, space);
+        if (ret == VLC_SUCCESS)
         {
             interop->fmt.i_chroma = *list;
 
@@ -351,15 +350,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 = interop->priv = calloc(1, sizeof(struct priv));
     if (unlikely(priv == NULL))
-    {
-        interop->vt->DeleteShader(fragment_shader);
         return VLC_ENOMEM;
-    }
 
     static const struct vlc_gl_interop_ops ops = {
         .allocate_textures = tc_common_allocate_textures,
@@ -394,8 +390,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 77b4e98c41..9d73088509 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -578,10 +578,6 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
     if (desc == NULL)
         return 0;
 
-    ret = opengl_interop_init_impl(&tc->interop, 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 a4c351b46a..6f8853c6d9 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, interop->tex_target,
+                                         interop->sw_fmt.i_chroma,
+                                         interop->sw_fmt.space);
+    if (!fragment_shader)
+    {
+        vlc_object_delete(tc);
+        return VLC_EGENERIC;
+    }
+
+    tc->fshader = fragment_shader;
+
     assert(tc->fshader != 0 &&
            interop->tex_target != 0 &&
            interop->tex_count > 0 &&



More information about the vlc-commits mailing list