[vlc-commits] opengl: pass interop to "glconv" modules

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


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Dec  5 11:54:30 2019 +0100| [a3b0dd83c78a0a467b2ffc6dc64663d6d1e1164d] | committer: Thomas Guillem

opengl: pass interop to "glconv" modules

Pass an interop instead of a tex converter to "glconv" modules.

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

 modules/hw/nvdec/Makefile.am                    |  2 +-
 modules/hw/nvdec/nvdec_gl.c                     | 17 +++----
 modules/video_output/Makefile.am                | 10 ++--
 modules/video_output/opengl/converter.h         |  2 -
 modules/video_output/opengl/converter_android.c | 19 ++++----
 modules/video_output/opengl/converter_cvpx.c    | 62 +++++++++++++------------
 modules/video_output/opengl/converter_vaapi.c   | 28 +++++------
 modules/video_output/opengl/converter_vdpau.c   | 25 +++++-----
 modules/video_output/opengl/interop.h           |  2 +
 modules/video_output/opengl/vout_helper.c       | 10 ++--
 modules/video_output/win32/direct3d9.c          | 14 +++---
 11 files changed, 98 insertions(+), 93 deletions(-)

diff --git a/modules/hw/nvdec/Makefile.am b/modules/hw/nvdec/Makefile.am
index 3471bf9462..e342fbdc6f 100644
--- a/modules/hw/nvdec/Makefile.am
+++ b/modules/hw/nvdec/Makefile.am
@@ -18,7 +18,7 @@ nvdec_LTLIBRARIES = libnvdec_chroma_plugin.la
 endif
 
 libglconv_nvdec_plugin_la_SOURCES = hw/nvdec/nvdec_gl.c \
-	video_output/opengl/converter.h hw/nvdec/nvdec_fmt.h
+	video_output/opengl/interop.h hw/nvdec/nvdec_fmt.h
 libglconv_nvdec_plugin_la_LIBADD = $(LIBDL)
 if HAVE_GL
 if HAVE_NVDEC
diff --git a/modules/hw/nvdec/nvdec_gl.c b/modules/hw/nvdec/nvdec_gl.c
index f6b808a477..af766f5e95 100644
--- a/modules/hw/nvdec/nvdec_gl.c
+++ b/modules/hw/nvdec/nvdec_gl.c
@@ -29,12 +29,14 @@
 #include <vlc_common.h>
 #include <vlc_vout_window.h>
 #include <vlc_codec.h>
+#include <vlc_plugin.h>
 
 #include <ffnvcodec/dynlink_loader.h>
 
 #include "nvdec_fmt.h"
 
 #include "../../video_output/opengl/internal.h"
+#include "../../video_output/opengl/interop.h"
 
 // glew.h conflicts with glext.h, but also makes glext.h unnecessary.
 #ifndef __GLEW_H__
@@ -146,15 +148,14 @@ error:
 
 static void Close(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *)obj;
-    converter_sys_t *p_sys = tc->interop->priv;
+    struct vlc_gl_interop *interop = (void *)obj;
+    converter_sys_t *p_sys = interop->priv;
     vlc_decoder_device_Release(p_sys->device);
 }
 
 static int Open(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *) obj;
-    struct vlc_gl_interop *interop = tc->interop;
+    struct vlc_gl_interop *interop = (void *) obj;
     if (!is_nvdec_opaque(interop->fmt.i_chroma))
         return VLC_EGENERIC;
 
@@ -162,7 +163,7 @@ static int Open(vlc_object_t *obj)
     if (device == NULL || device->type != VLC_DECODER_DEVICE_NVDEC)
         return VLC_EGENERIC;
 
-    converter_sys_t *p_sys = vlc_obj_malloc(VLC_OBJECT(tc), sizeof(*p_sys));
+    converter_sys_t *p_sys = vlc_obj_malloc(VLC_OBJECT(interop), sizeof(*p_sys));
     if (unlikely(p_sys == NULL))
     {
         vlc_decoder_device_Release(device);
@@ -208,11 +209,11 @@ static int Open(vlc_object_t *obj)
         default:                         render_chroma = VLC_CODEC_NV12; break;
     }
 
-    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, render_chroma, interop->fmt.space);
-    if (!tc->fshader)
+    int ret = opengl_interop_init(interop, GL_TEXTURE_2D, render_chroma, interop->fmt.space);
+    if (ret != VLC_SUCCESS)
     {
         Close(obj);
-        return VLC_EGENERIC;
+        return ret;
     }
 
     static const struct vlc_gl_interop_ops ops = {
diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index 3c1bee98cb..baf7818cac 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -4,7 +4,7 @@ vout_LTLIBRARIES =
 EXTRA_DIST += video_output/README
 
 OPENGL_COMMONSOURCES = video_output/opengl/vout_helper.c \
-	video_output/opengl/gl_common.h \
+	video_output/opengl/gl_common.h video_output/opengl/interop.h \
 	video_output/opengl/vout_helper.h video_output/opengl/converter.h \
 	video_output/opengl/internal.h video_output/opengl/fragment_shaders.c \
 	video_output/opengl/converter_sw.c
@@ -31,7 +31,7 @@ vout_LTLIBRARIES += libdecklinkoutput_plugin.la
 endif
 
 libglconv_cvpx_plugin_la_SOURCES = video_output/opengl/converter_cvpx.c \
-	video_output/opengl/converter.h
+	video_output/opengl/interop.h
 libglconv_cvpx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)'
 
 if HAVE_OSX
@@ -87,13 +87,13 @@ libgl_plugin_la_LIBADD += $(GL_LIBS)
 endif
 
 libglconv_vaapi_plugin_la_SOURCES = video_output/opengl/converter_vaapi.c \
-	video_output/opengl/converter.h \
+	video_output/opengl/interop.h \
 	hw/vaapi/vlc_vaapi.c hw/vaapi/vlc_vaapi.h
 libglconv_vaapi_plugin_la_CFLAGS = $(AM_CFLAGS) $(GL_CFLAGS)
 libglconv_vaapi_plugin_la_LIBADD = $(LIBVA_LIBS) $(LIBVA_EGL_LIBS)
 
 libglconv_vdpau_plugin_la_SOURCES = video_output/opengl/converter_vdpau.c \
-	video_output/opengl/converter.h hw/vdpau/picture.c hw/vdpau/vlc_vdpau.h
+	video_output/opengl/interop.h hw/vdpau/picture.c hw/vdpau/vlc_vdpau.h
 libglconv_vdpau_plugin_la_CFLAGS = $(AM_CFLAGS) $(VDPAU_CFLAGS)
 libglconv_vdpau_plugin_la_LIBADD = $(LIBDL) libvlc_vdpau.la $(X_LIBS) $(X_PRE_LIBS) -lX11
 
@@ -280,7 +280,7 @@ libandroid_display_plugin_la_CFLAGS = $(AM_CFLAGS)
 libandroid_display_plugin_la_LIBADD = $(LIBDL)
 
 libglconv_android_plugin_la_SOURCES = video_output/opengl/converter_android.c \
-	video_output/opengl/converter.h
+	video_output/opengl/interop.h
 libglconv_android_plugin_la_CFLAGS = $(AM_CFLAGS) -DUSE_OPENGL_ES2
 
 if HAVE_ANDROID
diff --git a/modules/video_output/opengl/converter.h b/modules/video_output/opengl/converter.h
index 417e7dfc58..eb58d118b7 100644
--- a/modules/video_output/opengl/converter.h
+++ b/modules/video_output/opengl/converter.h
@@ -43,8 +43,6 @@ struct opengl_tex_converter_t
 {
     struct vlc_object_t obj;
 
-    module_t *p_module;
-
     /* Pointer to object gl, set by the caller */
     vlc_gl_t *gl;
 
diff --git a/modules/video_output/opengl/converter_android.c b/modules/video_output/opengl/converter_android.c
index 36e8f2b6da..80297f12ce 100644
--- a/modules/video_output/opengl/converter_android.c
+++ b/modules/video_output/opengl/converter_android.c
@@ -26,7 +26,8 @@
 # error this file must be built from android
 #endif
 
-#include "converter.h"
+#include <vlc_plugin.h>
+#include "interop.h"
 #include "../android/utils.h"
 
 struct priv
@@ -93,8 +94,8 @@ tc_get_transform_matrix(const struct vlc_gl_interop *interop)
 static void
 Close(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *)obj;
-    struct priv *priv = tc->interop->priv;
+    struct vlc_gl_interop *interop = (void *)obj;
+    struct priv *priv = interop->priv;
 
     if (priv->stex_attached)
         SurfaceTexture_detachFromGLContext(priv->awh);
@@ -105,8 +106,7 @@ Close(vlc_object_t *obj)
 static int
 Open(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *) obj;
-    struct vlc_gl_interop *interop = tc->interop;
+    struct vlc_gl_interop *interop = (void *) obj;
 
     if (interop->fmt.i_chroma != VLC_CODEC_ANDROID_OPAQUE
      || !interop->gl->surface->handle.anativewindow
@@ -167,10 +167,11 @@ Open(vlc_object_t *obj)
             break;
     }
 
-    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_EXTERNAL_OES,
-                                              VLC_CODEC_RGB32,
-                                              COLOR_SPACE_UNDEF);
-    if (!tc->fshader)
+    int ret = opengl_interop_init(interop, GL_TEXTURE_EXTERNAL_OES,
+                                  VLC_CODEC_RGB32,
+                                  COLOR_SPACE_UNDEF);
+
+    if (ret != VLC_SUCCESS)
     {
         free(priv);
         return VLC_EGENERIC;
diff --git a/modules/video_output/opengl/converter_cvpx.c b/modules/video_output/opengl/converter_cvpx.c
index 68047d2eae..80d2104a35 100644
--- a/modules/video_output/opengl/converter_cvpx.c
+++ b/modules/video_output/opengl/converter_cvpx.c
@@ -22,7 +22,8 @@
 # include "config.h"
 #endif
 
-#include "converter.h"
+#include <vlc_plugin.h>
+#include "interop.h"
 #include "../../codec/vt_utils.h"
 
 #if TARGET_OS_IPHONE
@@ -143,8 +144,7 @@ tc_cvpx_update(const struct vlc_gl_interop *interop, GLuint *textures,
 static void
 Close(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *)obj;
-    struct vlc_gl_interop *interop = tc->interop;
+    struct vlc_gl_interop *interop = (void *) obj;
     struct priv *priv = interop->priv;
 
 #if TARGET_OS_IPHONE
@@ -164,8 +164,7 @@ Close(vlc_object_t *obj)
 static int
 Open(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *) obj;
-    struct vlc_gl_interop *interop = tc->interop;
+    struct vlc_gl_interop *interop = (void *) obj;
 
     if (interop->fmt.i_chroma != VLC_CODEC_CVPX_UYVY
      && interop->fmt.i_chroma != VLC_CODEC_CVPX_NV12
@@ -212,7 +211,7 @@ Open(vlc_object_t *obj)
     }
 #endif
 
-    GLuint fragment_shader;
+    int ret;
     switch (interop->fmt.i_chroma)
     {
         case VLC_CODEC_CVPX_UYVY:
@@ -222,9 +221,11 @@ Open(vlc_object_t *obj)
              * and red color channels, respectively. cf. APPLE_rgb_422 khronos
              * extenstion. */
 
-            fragment_shader =
-                opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_VYUY,
-                                            interop->fmt.space);
+            ret = opengl_interop_init(interop, tex_target, VLC_CODEC_VYUY,
+                                      interop->fmt.space);
+            if (ret != VLC_SUCCESS)
+                goto error;
+
             interop->texs[0].internal = GL_RGB;
             interop->texs[0].format = GL_RGB_422_APPLE;
             interop->texs[0].type = GL_UNSIGNED_SHORT_8_8_APPLE;
@@ -232,27 +233,34 @@ Open(vlc_object_t *obj)
             break;
         case VLC_CODEC_CVPX_NV12:
         {
-            fragment_shader =
-                opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_NV12,
-                                            interop->fmt.space);
+            ret = opengl_interop_init(interop, tex_target, VLC_CODEC_NV12,
+                                      interop->fmt.space);
+            if (ret != VLC_SUCCESS)
+                goto error;
             break;
         }
         case VLC_CODEC_CVPX_P010:
         {
-            fragment_shader =
-                opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_P010,
-                                            interop->fmt.space);
+            ret = opengl_interop_init(interop, tex_target, VLC_CODEC_P010,
+                                      interop->fmt.space);
+            if (ret != VLC_SUCCESS)
+                goto error;
+
             break;
         }
         case VLC_CODEC_CVPX_I420:
-            fragment_shader =
-                opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_I420,
-                                            interop->fmt.space);
+            ret = opengl_interop_init(interop, tex_target, VLC_CODEC_I420,
+                                      interop->fmt.space);
+            if (ret != VLC_SUCCESS)
+                goto error;
+
             break;
         case VLC_CODEC_CVPX_BGRA:
-            fragment_shader =
-                opengl_fragment_shader_init(tc, tex_target, VLC_CODEC_RGB32,
-                                            COLOR_SPACE_UNDEF);
+            ret = opengl_interop_init(interop, tex_target, VLC_CODEC_RGB32,
+                                      COLOR_SPACE_UNDEF);
+            if (ret != VLC_SUCCESS)
+                goto error;
+
             interop->texs[0].internal = GL_RGBA;
             interop->texs[0].format = GL_BGRA;
 #if TARGET_OS_IPHONE
@@ -265,12 +273,6 @@ Open(vlc_object_t *obj)
             vlc_assert_unreachable();
     }
 
-    if (fragment_shader == 0)
-    {
-        free(priv);
-        return VLC_EGENERIC;
-    }
-
 #if TARGET_OS_IPHONE
     interop->handle_texs_gen = true;
 #endif
@@ -280,9 +282,11 @@ Open(vlc_object_t *obj)
     };
     interop->ops = &ops;
 
-    tc->fshader           = fragment_shader;
-
     return VLC_SUCCESS;
+
+error:
+    free(priv);
+    return VLC_EGENERIC;
 }
 
 vlc_module_begin ()
diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index c99a04239b..a862868837 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -31,8 +31,9 @@
 #include <vlc_common.h>
 #include <vlc_vout_window.h>
 #include <vlc_codec.h>
+#include <vlc_plugin.h>
 
-#include "converter.h"
+#include "interop.h"
 #include "../../hw/vaapi/vlc_vaapi.h"
 
 /* From https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image.txt
@@ -228,11 +229,11 @@ error:
 static void
 Close(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *)obj;
-    struct priv *priv = tc->interop->priv;
+    struct vlc_gl_interop *interop = (void *)obj;
+    struct priv *priv = interop->priv;
 
     if (priv->last.pic != NULL)
-        vaegl_release_last_pic(tc->interop, priv);
+        vaegl_release_last_pic(interop, priv);
 
     free(priv);
 }
@@ -338,17 +339,16 @@ done:
 static int
 Open(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *) obj;
-    struct vlc_gl_interop *interop = tc->interop;
+    struct vlc_gl_interop *interop = (void *) obj;
 
     if (interop->vctx == NULL)
         return VLC_EGENERIC;
     vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(interop->vctx);
     if (dec_device->type != VLC_DECODER_DEVICE_VAAPI
      || !vlc_vaapi_IsChromaOpaque(interop->fmt.i_chroma)
-     || tc->gl->ext != VLC_GL_EXT_EGL
-     || tc->gl->egl.createImageKHR == NULL
-     || tc->gl->egl.destroyImageKHR == NULL)
+     || interop->gl->ext != VLC_GL_EXT_EGL
+     || interop->gl->egl.createImageKHR == NULL
+     || interop->gl->egl.destroyImageKHR == NULL)
     {
         vlc_decoder_device_Release(dec_device);
         return VLC_EGENERIC;
@@ -360,7 +360,7 @@ Open(vlc_object_t *obj)
         return VLC_EGENERIC;
     }
 
-    const char *eglexts = tc->gl->egl.queryString(tc->gl, EGL_EXTENSIONS);
+    const char *eglexts = interop->gl->egl.queryString(interop->gl, EGL_EXTENSIONS);
     if (eglexts == NULL || !vlc_gl_StrHasToken(eglexts, "EGL_EXT_image_dma_buf_import"))
     {
         vlc_decoder_device_Release(dec_device);
@@ -392,7 +392,7 @@ Open(vlc_object_t *obj)
         goto error;
 
     priv->glEGLImageTargetTexture2DOES =
-        vlc_gl_GetProcAddress(tc->gl, "glEGLImageTargetTexture2DOES");
+        vlc_gl_GetProcAddress(interop->gl, "glEGLImageTargetTexture2DOES");
     if (priv->glEGLImageTargetTexture2DOES == NULL)
         goto error;
 
@@ -405,9 +405,9 @@ Open(vlc_object_t *obj)
     if (tc_va_check_derive_image(interop))
         goto error;
 
-    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, vlc_sw_chroma,
-                                              interop->fmt.space);
-    if (tc->fshader == 0)
+    int ret = opengl_interop_init(interop, GL_TEXTURE_2D, vlc_sw_chroma,
+                                  interop->fmt.space);
+    if (ret != VLC_SUCCESS)
         goto error;
 
     static const struct vlc_gl_interop_ops ops = {
diff --git a/modules/video_output/opengl/converter_vdpau.c b/modules/video_output/opengl/converter_vdpau.c
index c813a21243..2b257f0a64 100644
--- a/modules/video_output/opengl/converter_vdpau.c
+++ b/modules/video_output/opengl/converter_vdpau.c
@@ -33,9 +33,11 @@
 #include <vlc_vout_window.h>
 #include <vlc_xlib.h>
 #include <vlc_codec.h>
+#include <vlc_plugin.h>
 
 #include "../../hw/vdpau/vlc_vdpau.h"
 #include "internal.h"
+#include "interop.h"
 
 #define INTEROP_CALL(fct, ...) \
     _##fct(__VA_ARGS__); \
@@ -105,9 +107,9 @@ tc_vdpau_gl_update(const struct vlc_gl_interop *interop, GLuint textures[],
 static void
 Close(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *)obj;
-    _glVDPAUFiniNV(); assert(tc->vt->GetError() == GL_NO_ERROR);
-    converter_sys_t *sys = tc->interop->priv;
+    struct vlc_gl_interop *interop = (void *)obj;
+    _glVDPAUFiniNV(); assert(interop->vt->GetError() == GL_NO_ERROR);
+    converter_sys_t *sys = interop->priv;
     vlc_decoder_device *dec_device = sys->dec_device;
     vlc_decoder_device_Release(dec_device);
 }
@@ -115,9 +117,7 @@ Close(vlc_object_t *obj)
 static int
 Open(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *) obj;
-    struct vlc_gl_interop *interop = tc->interop;
-
+    struct vlc_gl_interop *interop = (void *) obj;
     if (interop->vctx == NULL)
         return VLC_EGENERIC;
     vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(interop->vctx);
@@ -126,13 +126,13 @@ Open(vlc_object_t *obj)
       && interop->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_422
       && interop->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444)
      || !vlc_gl_StrHasToken(interop->glexts, "GL_NV_vdpau_interop")
-     || tc->gl->surface->type != VOUT_WINDOW_TYPE_XID)
+     || interop->gl->surface->type != VOUT_WINDOW_TYPE_XID)
     {
         vlc_decoder_device_Release(dec_device);
         return VLC_EGENERIC;
     }
 
-    converter_sys_t *sys = vlc_obj_malloc(VLC_OBJECT(tc), sizeof(*sys));
+    converter_sys_t *sys = vlc_obj_malloc(VLC_OBJECT(interop), sizeof(*sys));
     if (unlikely(sys == NULL))
     {
         vlc_decoder_device_Release(dec_device);
@@ -157,7 +157,7 @@ Open(vlc_object_t *obj)
     }
 
 #define SAFE_GPA(fct) \
-    _##fct = vlc_gl_GetProcAddress(tc->gl, #fct); \
+    _##fct = vlc_gl_GetProcAddress(interop->gl, #fct); \
     if (!_##fct) \
     { \
         vlc_decoder_device_Release(dec_device); \
@@ -176,10 +176,9 @@ Open(vlc_object_t *obj)
 
     INTEROP_CALL(glVDPAUInitNV, (void *)(uintptr_t)device, vdp_gpa);
 
-    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D,
-                                              VLC_CODEC_RGB32,
-                                              COLOR_SPACE_UNDEF);
-    if (!tc->fshader)
+    int ret = opengl_interop_init(interop, GL_TEXTURE_2D, VLC_CODEC_RGB32,
+                                  COLOR_SPACE_UNDEF);
+    if (ret != VLC_SUCCESS)
     {
         Close(obj);
         return VLC_EGENERIC;
diff --git a/modules/video_output/opengl/interop.h b/modules/video_output/opengl/interop.h
index 32bdf3cfd9..3aa19adf71 100644
--- a/modules/video_output/opengl/interop.h
+++ b/modules/video_output/opengl/interop.h
@@ -96,6 +96,8 @@ struct vlc_gl_interop_ops {
 
 struct vlc_gl_interop {
     vlc_object_t obj;
+    module_t *module;
+
     vlc_gl_t *gl;
     const opengl_vtable_t *vt;
     GLenum tex_target;
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index d74e8fefc7..a810404e82 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -507,11 +507,11 @@ opengl_deinit_program(vout_display_opengl_t *vgl, struct prgm *prgm)
 {
     opengl_tex_converter_t *tc = prgm->tc;
     struct vlc_gl_interop *interop = tc->interop;
-    if (tc->p_module != NULL)
-        module_unneed(tc, tc->p_module);
+    if (interop->module != NULL)
+        module_unneed(interop, interop->module);
     else if (interop->priv != NULL)
         opengl_interop_generic_deinit(interop);
-    vlc_object_delete(tc->interop);
+    vlc_object_delete(interop);
     if (prgm->id != 0)
         vgl->vt.DeleteProgram(prgm->id);
 
@@ -613,10 +613,10 @@ opengl_init_program(vout_display_opengl_t *vgl, vlc_video_context *context,
         {
             /* Opaque chroma: load a module to handle it */
             interop->vctx = context;
-            tc->p_module = module_need_var(tc, "glconv", "glconv");
+            interop->module = module_need_var(interop, "glconv", "glconv");
         }
 
-        if (tc->p_module != NULL)
+        if (interop->module != NULL)
             ret = VLC_SUCCESS;
         else
         {
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 01727c1f4f..2497bcbd91 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -60,6 +60,7 @@
 #include "common.h"
 #include "builtin_shaders.h"
 #include "../../video_chroma/copy.h"
+#include "../opengl/interop.h"
 
 #include <assert.h>
 
@@ -1762,8 +1763,8 @@ GLConvAllocateTextures(const struct vlc_gl_interop *interop, GLuint *textures,
 static void
 GLConvClose(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *)obj;
-    struct glpriv *priv = tc->interop->priv;
+    struct vlc_gl_interop *interop = (void *)obj;
+    struct glpriv *priv = interop->priv;
 
     if (priv->gl_handle_d3d)
     {
@@ -1785,8 +1786,7 @@ GLConvClose(vlc_object_t *obj)
 static int
 GLConvOpen(vlc_object_t *obj)
 {
-    opengl_tex_converter_t *tc = (void *) obj;
-    struct vlc_gl_interop *interop = tc->interop;
+    struct vlc_gl_interop *interop = (void *) obj;
 
     if (interop->fmt.i_chroma != VLC_CODEC_D3D9_OPAQUE
      && interop->fmt.i_chroma != VLC_CODEC_D3D9_OPAQUE_10B)
@@ -1864,9 +1864,9 @@ GLConvOpen(vlc_object_t *obj)
     };
     interop->ops = &ops;
 
-    tc->fshader = opengl_fragment_shader_init(tc, GL_TEXTURE_2D, VLC_CODEC_RGB32,
-                                              COLOR_SPACE_UNDEF);
-    if (tc->fshader == 0)
+    int ret = opengl_interop_init(interop, GL_TEXTURE_2D, VLC_CODEC_RGB32,
+                                  COLOR_SPACE_UNDEF);
+    if (ret != VLC_SUCCESS)
         goto error;
 
     return VLC_SUCCESS;



More information about the vlc-commits mailing list