[vlc-commits] opengl: move fields from interop to gl_api

Romain Vimont git at videolan.org
Mon Mar 23 11:37:30 CET 2020


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Jan 30 15:37:00 2020 +0100| [8118fb3fbc7fc3ea8cbc8e084c2a737bc7fab52c] | committer: Jean-Baptiste Kempf

opengl: move fields from interop to gl_api

The fields is_gles and glexts (extensions) are not specific to interop,
and may be useful without an interop instance.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/video_output/opengl/fragment_shaders.c |  2 +-
 modules/video_output/opengl/gl_api.c           | 15 +++++++++++++++
 modules/video_output/opengl/gl_api.h           |  7 +++++++
 modules/video_output/opengl/interop.c          |  9 +--------
 modules/video_output/opengl/interop.h          |  6 ------
 modules/video_output/opengl/interop_sw.c       |  7 ++++---
 modules/video_output/opengl/interop_vaapi.c    |  3 ++-
 modules/video_output/opengl/interop_vdpau.c    |  3 ++-
 8 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index e52e820522..e353e20ac3 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -376,7 +376,7 @@ opengl_init_swizzle(const struct vlc_gl_interop *interop,
                     const vlc_chroma_description_t *desc)
 {
     GLint oneplane_texfmt;
-    if (vlc_gl_StrHasToken(interop->glexts, "GL_ARB_texture_rg"))
+    if (vlc_gl_StrHasToken(interop->api->extensions, "GL_ARB_texture_rg"))
         oneplane_texfmt = GL_RED;
     else
         oneplane_texfmt = GL_LUMINANCE;
diff --git a/modules/video_output/opengl/gl_api.c b/modules/video_output/opengl/gl_api.c
index 69859a815e..9cf2bc2c19 100644
--- a/modules/video_output/opengl/gl_api.c
+++ b/modules/video_output/opengl/gl_api.c
@@ -25,6 +25,7 @@
 
 #include "gl_api.h"
 
+#include <assert.h>
 #include <vlc_common.h>
 #include <vlc_opengl.h>
 
@@ -131,5 +132,19 @@ vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
 
     GL_ASSERT_NOERROR(&api->vt);
 
+    api->extensions = (const char *) api->vt.GetString(GL_EXTENSIONS);
+    assert(api->extensions);
+    if (!api->extensions)
+    {
+        msg_Err(gl, "glGetString returned NULL");
+        return VLC_EGENERIC;
+    }
+
+#ifdef USE_OPENGL_ES2
+    api->is_gles = true;
+#else
+    api->is_gles = false;
+#endif
+
     return VLC_SUCCESS;
 }
diff --git a/modules/video_output/opengl/gl_api.h b/modules/video_output/opengl/gl_api.h
index 86add17ce3..6aba0ea1be 100644
--- a/modules/video_output/opengl/gl_api.h
+++ b/modules/video_output/opengl/gl_api.h
@@ -26,6 +26,7 @@
 # include "config.h"
 #endif
 
+#include <stdbool.h>
 #include <vlc_common.h>
 #include <vlc_opengl.h>
 
@@ -33,6 +34,12 @@
 
 struct vlc_gl_api {
     opengl_vtable_t vt;
+
+    /* True if the current API is OpenGL ES, set by the caller */
+    bool is_gles;
+
+    /* Available gl extensions (from GL_EXTENSIONS) */
+    const char *extensions;
 };
 
 int
diff --git a/modules/video_output/opengl/interop.c b/modules/video_output/opengl/interop.c
index 35c26c6735..a091a88703 100644
--- a/modules/video_output/opengl/interop.c
+++ b/modules/video_output/opengl/interop.c
@@ -46,15 +46,8 @@ vlc_gl_interop_New(struct vlc_gl_t *gl, const struct vlc_gl_api *api,
     if (!interop)
         return NULL;
 
-#ifdef USE_OPENGL_ES2
-    interop->is_gles = true;
-#else
-    interop->is_gles = false;
-#endif
-
     interop->init = opengl_interop_init_impl;
     interop->ops = NULL;
-    interop->glexts = glexts;
     interop->fmt = *fmt;
     /* this is the only allocated field, and we don't need it */
     interop->fmt.p_palette = NULL;
@@ -211,7 +204,7 @@ interop_yuv_base_init(struct vlc_gl_interop *interop, GLenum tex_target,
     GLint oneplane_texfmt, oneplane16_texfmt,
           twoplanes_texfmt, twoplanes16_texfmt;
 
-    if (vlc_gl_StrHasToken(interop->glexts, "GL_ARB_texture_rg"))
+    if (vlc_gl_StrHasToken(interop->api->extensions, "GL_ARB_texture_rg"))
     {
         oneplane_texfmt = GL_RED;
         oneplane16_texfmt = GL_R16;
diff --git a/modules/video_output/opengl/interop.h b/modules/video_output/opengl/interop.h
index 96b34de970..4288da3f25 100644
--- a/modules/video_output/opengl/interop.h
+++ b/modules/video_output/opengl/interop.h
@@ -113,12 +113,6 @@ struct vlc_gl_interop {
     const opengl_vtable_t *vt; /* for convenience, same as &api->vt */
     GLenum tex_target;
 
-    /* True if the current API is OpenGL ES, set by the caller */
-    bool is_gles;
-
-    /* Available gl extensions (from GL_EXTENSIONS) */
-    const char *glexts;
-
     /* Can only be changed from the module open function */
     video_format_t fmt;
 
diff --git a/modules/video_output/opengl/interop_sw.c b/modules/video_output/opengl/interop_sw.c
index 481ebd027e..b872f511eb 100644
--- a/modules/video_output/opengl/interop_sw.c
+++ b/modules/video_output/opengl/interop_sw.c
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 
 #include <vlc_common.h>
+#include "gl_api.h"
 #include "internal.h"
 
 #define PBO_DISPLAY_COUNT 2 /* Double buffering */
@@ -363,7 +364,7 @@ opengl_interop_generic_init(struct vlc_gl_interop *interop, bool allow_dr)
 
     /* OpenGL or OpenGL ES2 with GL_EXT_unpack_subimage ext */
     priv->has_unpack_subimage =
-        !interop->is_gles || vlc_gl_StrHasToken(interop->glexts, "GL_EXT_unpack_subimage");
+        !interop->api->is_gles || vlc_gl_StrHasToken(interop->api->extensions, "GL_EXT_unpack_subimage");
 
     if (allow_dr && priv->has_unpack_subimage)
     {
@@ -372,8 +373,8 @@ opengl_interop_generic_init(struct vlc_gl_interop *interop, bool allow_dr)
         const bool glver_ok = strverscmp((const char *)ogl_version, "3.0") >= 0;
 
         const bool has_pbo = glver_ok &&
-            (vlc_gl_StrHasToken(interop->glexts, "GL_ARB_pixel_buffer_object") ||
-             vlc_gl_StrHasToken(interop->glexts, "GL_EXT_pixel_buffer_object"));
+            (vlc_gl_StrHasToken(interop->api->extensions, "GL_ARB_pixel_buffer_object") ||
+             vlc_gl_StrHasToken(interop->api->extensions, "GL_EXT_pixel_buffer_object"));
 
         const bool supports_pbo = has_pbo && interop->vt->BufferData
             && interop->vt->BufferSubData;
diff --git a/modules/video_output/opengl/interop_vaapi.c b/modules/video_output/opengl/interop_vaapi.c
index b11251135f..27d9e0ec2d 100644
--- a/modules/video_output/opengl/interop_vaapi.c
+++ b/modules/video_output/opengl/interop_vaapi.c
@@ -33,6 +33,7 @@
 #include <vlc_codec.h>
 #include <vlc_plugin.h>
 
+#include "gl_api.h"
 #include "interop.h"
 #include "../../hw/vaapi/vlc_vaapi.h"
 
@@ -353,7 +354,7 @@ Open(vlc_object_t *obj)
         return VLC_EGENERIC;
     }
 
-    if (!vlc_gl_StrHasToken(interop->glexts, "GL_OES_EGL_image"))
+    if (!vlc_gl_StrHasToken(interop->api->extensions, "GL_OES_EGL_image"))
     {
         vlc_decoder_device_Release(dec_device);
         return VLC_EGENERIC;
diff --git a/modules/video_output/opengl/interop_vdpau.c b/modules/video_output/opengl/interop_vdpau.c
index 6625f995a3..35f6222351 100644
--- a/modules/video_output/opengl/interop_vdpau.c
+++ b/modules/video_output/opengl/interop_vdpau.c
@@ -35,6 +35,7 @@
 #include <vlc_codec.h>
 #include <vlc_plugin.h>
 
+#include "gl_api.h"
 #include "../../hw/vdpau/vlc_vdpau.h"
 #include "internal.h"
 #include "interop.h"
@@ -124,7 +125,7 @@ Open(vlc_object_t *obj)
      || (interop->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_420
       && 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")
+     || !vlc_gl_StrHasToken(interop->api->extensions, "GL_NV_vdpau_interop")
      || interop->gl->surface->type != VOUT_WINDOW_TYPE_XID)
     {
         vlc_decoder_device_Release(dec_device);



More information about the vlc-commits mailing list