[vlc-commits] [Git][videolan/vlc][master] 2 commits: opengl: remove reference counting

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Feb 18 10:07:59 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
f93738a6 by Alexandre Janniaux at 2022-02-18T10:30:34+01:00
opengl: remove reference counting

The API is not used anymore, and with the removal of the reference
counting pattern in objects, not required.

Indeed, the OpenGL providers are neither multi-thread nor reentrant
so it needs a locked stated when multiple clients needs to use it,
which will also needs to be reference counted across the clients, so
the whole reference counting can be done there.

In addition, if the context was given from module to other module, like
in the filter chain, the video contexts forwarded in those chains would
already be doing the reference counting. As a side note, there would
probably be few reasons to implement such forwarding currently anyway
since it would means that the beginning of the chain would lose usage
of the context, which also encompass a pool of output picture too
currently.

- - - - -
a162a177 by Alexandre Janniaux at 2022-02-18T10:30:34+01:00
opengl: implement vlc_gl_HasExtension in modules

Remove vlc_gl_HasExtension helper from the public API and implement it
as a private helper in modules. The reason for such helper was to help
ensuring the core stays compatible with Core OpenGL profile, which is
broken as soon as glGetString(GL_EXTENSIONS) is called instead of the
glGetStringi(GL_EXTENSION, i) variant.

Having the helper in the core led to issues against the MacOSX
implementation.

The extension store in gl_util.h prevents reloading the functions
across multiple calls from vlc_gl_HasExtension, and the helper can
easily be used in any OpenGL client which needs access to the extension
list.

Fix #26606 regression as a side effect

Co-Authored-by: Zhao Zhili <quinkblack at foxmail.com>

- - - - -


19 changed files:

- include/vlc_opengl.h
- modules/video_filter/egl_surfacetexture.c
- modules/video_filter/opengl.c
- modules/video_output/android/display.c
- modules/video_output/libplacebo/instance_opengl.c
- modules/video_output/opengl/display.c
- modules/video_output/opengl/gl_api.c
- modules/video_output/opengl/gl_common.h
- modules/video_output/opengl/gl_util.h
- modules/video_output/opengl/importer.c
- modules/video_output/opengl/interop.c
- modules/video_output/opengl/interop_android.c
- modules/video_output/opengl/interop_sw.c
- modules/video_output/opengl/interop_vaapi.c
- modules/video_output/opengl/interop_vdpau.c
- modules/video_output/opengl/sampler.c
- modules/video_output/win32/glwin32.c
- src/libvlccore.sym
- src/video_output/opengl.c


Changes:

=====================================
include/vlc_opengl.h
=====================================
@@ -97,10 +97,7 @@ VLC_API vlc_gl_t *vlc_gl_CreateOffscreen(vlc_object_t *parent,
                                          unsigned width, unsigned height,
                                          unsigned flags, const char *name);
 
-VLC_API void vlc_gl_Release(vlc_gl_t *);
-VLC_API void vlc_gl_Hold(vlc_gl_t *);
-
-VLC_API bool vlc_gl_HasExtension(vlc_gl_t *gl, const char *extension);
+VLC_API void vlc_gl_Delete(vlc_gl_t *);
 
 static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
 {


=====================================
modules/video_filter/egl_surfacetexture.c
=====================================
@@ -34,6 +34,7 @@
 
 #include "../video_output/android/utils.h"
 #include "../video_output/opengl/gl_api.h"
+#include "../video_output/opengl/gl_util.h"
 
 #define BUFFER_COUNT 3
 
@@ -400,9 +401,11 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
         goto error4;
     }
 
+    struct vlc_gl_extension_vt extension_vt;
+    vlc_gl_LoadExtensionFunctions(gl, &extension_vt);
 
     bool has_image_external =
-        vlc_gl_HasExtension(gl, "GL_OES_EGL_image_external");
+        vlc_gl_HasExtension(&extension_vt, "GL_OES_EGL_image_external");
     vlc_gl_ReleaseCurrent(gl);
 
     if (!has_image_external)


=====================================
modules/video_filter/opengl.c
=====================================
@@ -156,7 +156,7 @@ static void Close( filter_t *filter )
         vlc_gl_interop_Delete(sys->interop);
         vlc_gl_ReleaseCurrent(sys->gl);
 
-        vlc_gl_Release(sys->gl);
+        vlc_gl_Delete(sys->gl);
         free(sys);
     }
 }
@@ -295,7 +295,7 @@ gl_api_failure:
     vlc_gl_ReleaseCurrent(sys->gl);
 
 make_current_failure:
-    vlc_gl_Release(sys->gl);
+    vlc_gl_Delete(sys->gl);
 
 gl_create_failure:
     free(sys);


=====================================
modules/video_output/android/display.c
=====================================
@@ -624,7 +624,7 @@ static void ClearSurface(vout_display_t *vd)
         vlc_gl_ReleaseCurrent(gl);
 
 end:
-        vlc_gl_Release(gl);
+        vlc_gl_Delete(gl);
     }
     else
     {


=====================================
modules/video_output/libplacebo/instance_opengl.c
=====================================
@@ -153,7 +153,7 @@ static void CloseInstance(vlc_placebo_t *pl)
             vlc_gl_ReleaseCurrent(sys->gl);
         }
 
-        vlc_gl_Release(sys->gl);
+        vlc_gl_Delete(sys->gl);
     }
 
     vlc_obj_free(VLC_OBJECT(pl), sys);


=====================================
modules/video_output/opengl/display.c
=====================================
@@ -181,7 +181,7 @@ static int Open(vout_display_t *vd,
 
 error:
     if (sys->gl != NULL)
-        vlc_gl_Release (sys->gl);
+        vlc_gl_Delete(sys->gl);
     free (sys);
     return VLC_EGENERIC;
 }
@@ -198,7 +198,7 @@ static void Close(vout_display_t *vd)
     vout_display_opengl_Delete (sys->vgl);
     vlc_gl_ReleaseCurrent (gl);
 
-    vlc_gl_Release (gl);
+    vlc_gl_Delete(gl);
     free (sys);
 }
 


=====================================
modules/video_output/opengl/gl_api.c
=====================================
@@ -30,6 +30,7 @@
 #include <vlc_opengl.h>
 
 #include "gl_common.h"
+#include "gl_util.h"
 
 int
 vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
@@ -167,6 +168,9 @@ vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
     while (error != GL_NO_ERROR)
         error = api->vt.GetError();
 
+    struct vlc_gl_extension_vt extension_vt;
+    vlc_gl_LoadExtensionFunctions(gl, &extension_vt);
+
     if (gl->api_type == VLC_OPENGL_ES2)
     {
         api->is_gles = true;
@@ -177,8 +181,8 @@ vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
     else
     {
         api->is_gles = false;
-        api->supports_npot = vlc_gl_HasExtension(gl, "GL_ARB_texture_non_power_of_two") ||
-                             vlc_gl_HasExtension(gl, "GL_APPLE_texture_2D_limited_npot");
+        api->supports_npot = vlc_gl_HasExtension(&extension_vt, "GL_ARB_texture_non_power_of_two") ||
+                             vlc_gl_HasExtension(&extension_vt, "GL_APPLE_texture_2D_limited_npot");
     }
 
     return VLC_SUCCESS;


=====================================
modules/video_output/opengl/gl_common.h
=====================================
@@ -168,6 +168,10 @@
 # define GL_STREAM_READ 0x88E1
 #endif
 
+#if !defined(GL_NUM_EXTENSIONS)
+# define GL_NUM_EXTENSIONS 0x821D
+#endif
+
 #ifndef APIENTRY
 # define APIENTRY
 #endif
@@ -289,6 +293,7 @@ typedef GLsync (APIENTRY *PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flag
 typedef void (APIENTRY *PFNGLDELETESYNCPROC) (GLsync sync);
 typedef GLenum (APIENTRY *PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
 typedef void *(APIENTRY *PFNGLMAPBUFFERPROC)(GLenum, GLbitfield);
+typedef const GLubyte *(APIENTRY *PFNGLGETSTRINGIPROC) (GLenum name, GLint i);
 #endif
 
 /**


=====================================
modules/video_output/opengl/gl_util.h
=====================================
@@ -27,6 +27,7 @@
 #endif
 
 #include <vlc_common.h>
+#include <vlc_opengl.h>
 #include "gl_common.h"
 
 static const float MATRIX4_IDENTITY[4*4] = {
@@ -89,4 +90,60 @@ vlc_gl_BuildProgram(vlc_object_t *obj, const opengl_vtable_t *vt,
 module_t *
 vlc_gl_WrapOpenGLFilter(filter_t *filter, const char *opengl_filter_name);
 
+struct vlc_gl_extension_vt {
+    PFNGLGETSTRINGPROC      GetString;
+    PFNGLGETSTRINGIPROC     GetStringi;
+    PFNGLGETINTEGERVPROC    GetIntegerv;
+    PFNGLGETERRORPROC       GetError;
+};
+
+static inline void
+vlc_gl_LoadExtensionFunctions(vlc_gl_t *gl, struct vlc_gl_extension_vt *vt)
+{
+    vt->GetString = vlc_gl_GetProcAddress(gl, "glGetString");
+    vt->GetIntegerv = vlc_gl_GetProcAddress(gl, "glGetIntegerv");
+    vt->GetError = vlc_gl_GetProcAddress(gl, "glGetError");
+    vt->GetStringi = NULL;
+
+    GLint version;
+    vt->GetIntegerv(GL_MAJOR_VERSION, &version);
+    uint32_t error = vt->GetError();
+
+    if (error != GL_NO_ERROR)
+        version = 2;
+
+    /* Drain the errors before continuing. */
+    while (error != GL_NO_ERROR)
+        error = vt->GetError();
+
+    /* glGetStringi is available in OpenGL>=3 and GLES>=3.
+     * https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetString.xhtml
+     * https://www.khronos.org/registry/OpenGL-Refpages/es3/html/glGetString.xhtml
+     */
+    if (version >= 3)
+        vt->GetStringi = vlc_gl_GetProcAddress(gl, "glGetStringi");
+}
+
+static inline bool
+vlc_gl_HasExtension(
+    struct vlc_gl_extension_vt *vt,
+    const char *name
+){
+    if (vt->GetStringi == NULL)
+    {
+        const GLubyte *extensions = vt->GetString(GL_EXTENSIONS);
+        return vlc_gl_StrHasToken((const char *)extensions, name);
+    }
+
+    int32_t count = 0;
+    vt->GetIntegerv(GL_NUM_EXTENSIONS, &count);
+    for (int i = 0; i < count; ++i)
+    {
+        const uint8_t *extension = vt->GetStringi(GL_EXTENSIONS, i);
+        if (strcmp((const char *)extension, name) == 0)
+            return true;
+    }
+    return false;
+}
+
 #endif


=====================================
modules/video_output/opengl/importer.c
=====================================
@@ -226,10 +226,13 @@ vlc_gl_importer_New(struct vlc_gl_interop *interop)
 
     InitOrientationMatrix(importer->mtx_orientation, glfmt->fmt.orientation);
 
+    struct vlc_gl_extension_vt extension_vt;
+    vlc_gl_LoadExtensionFunctions(interop->gl, &extension_vt);
+
     /* OpenGL ES 2 includes support for non-power of 2 textures by specification. */
     bool supports_npot = interop->gl->api_type == VLC_OPENGL_ES2
-        || vlc_gl_HasExtension(interop->gl, "GL_ARB_texture_non_power_of_two")
-        || vlc_gl_HasExtension(interop->gl, "GL_APPLE_texture_2D_limited_npot");
+        || vlc_gl_HasExtension(&extension_vt, "GL_ARB_texture_non_power_of_two")
+        || vlc_gl_HasExtension(&extension_vt, "GL_APPLE_texture_2D_limited_npot");
 
     /* Texture size */
     for (unsigned j = 0; j < interop->tex_count; j++) {


=====================================
modules/video_output/opengl/interop.c
=====================================
@@ -25,7 +25,7 @@
 #include <vlc_common.h>
 #include <vlc_modules.h>
 
-#include "gl_api.h"
+#include "gl_util.h"
 #include "interop.h"
 #include "interop_sw.h"
 #include "vout_helper.h"
@@ -49,6 +49,8 @@ struct vlc_gl_interop_private
 #define DECLARE_SYMBOL(type, name) type name;
         OPENGL_VTABLE_F(DECLARE_SYMBOL)
     } gl;
+
+    struct vlc_gl_extension_vt extension_vt;
 };
 
 int
@@ -161,12 +163,15 @@ interop_yuv_base_init(struct vlc_gl_interop *interop, GLenum tex_target,
                       vlc_fourcc_t chroma,
                       const vlc_chroma_description_t *desc)
 {
+    struct vlc_gl_interop_private *priv =
+        container_of(interop, struct vlc_gl_interop_private, interop);
+
     (void) chroma;
 
     GLint oneplane_texfmt, oneplane16_texfmt,
           twoplanes_texfmt, twoplanes16_texfmt;
 
-    if (vlc_gl_HasExtension(interop->gl, "GL_ARB_texture_rg"))
+    if (vlc_gl_HasExtension(&priv->extension_vt, "GL_ARB_texture_rg"))
     {
         oneplane_texfmt = GL_RED;
         oneplane16_texfmt = GL_R16;
@@ -396,6 +401,8 @@ vlc_gl_interop_New(struct vlc_gl_t *gl, vlc_video_context *context,
     OPENGL_VTABLE_F(LOAD_SYMBOL);
 #undef LOAD_SYMBOL
 
+    vlc_gl_LoadExtensionFunctions(interop->gl, &priv->extension_vt);
+
     if (desc->plane_count == 0)
     {
         /* Opaque chroma: load a module to handle it */


=====================================
modules/video_output/opengl/interop_android.c
=====================================
@@ -31,6 +31,7 @@
 #include "interop.h"
 #include "../android/utils.h"
 #include "gl_api.h"
+#include "gl_util.h"
 
 struct priv
 {
@@ -197,7 +198,10 @@ Open(vlc_object_t *obj)
      || !interop->vctx)
         return VLC_EGENERIC;
 
-    if (!vlc_gl_HasExtension(interop->gl, "GL_OES_EGL_image_external"))
+    struct vlc_gl_extension_vt extension_vt;
+    vlc_gl_LoadExtensionFunctions(interop->gl, &extension_vt);
+
+    if (!vlc_gl_HasExtension(&extension_vt, "GL_OES_EGL_image_external"))
     {
         msg_Warn(&interop->obj, "GL_OES_EGL_image_external is not available,"
                 " disabling android interop.");


=====================================
modules/video_output/opengl/interop_sw.c
=====================================
@@ -29,7 +29,7 @@
 #include "interop_sw.h"
 
 #include <vlc_common.h>
-#include "gl_api.h"
+#include "gl_util.h"
 
 #define PBO_DISPLAY_COUNT 2 /* Double buffering */
 typedef struct
@@ -409,9 +409,12 @@ interop_init:
     interop->ops = &ops;
     interop->fmt_in.i_chroma = i_chroma;
 
+    struct vlc_gl_extension_vt extension_vt;
+    vlc_gl_LoadExtensionFunctions(interop->gl, &extension_vt);
+
     /* OpenGL or OpenGL ES2 with GL_EXT_unpack_subimage ext */
     priv->has_unpack_subimage = interop->gl->api_type == VLC_OPENGL
-        || vlc_gl_HasExtension(interop->gl, "GL_EXT_unpack_subimage");
+        || vlc_gl_HasExtension(&extension_vt, "GL_EXT_unpack_subimage");
 
     if (allow_dr && priv->has_unpack_subimage)
     {
@@ -420,8 +423,8 @@ interop_init:
         const bool glver_ok = strverscmp((const char *)ogl_version, "3.0") >= 0;
 
         const bool has_pbo = glver_ok &&
-            (vlc_gl_HasExtension(interop->gl, "GL_ARB_pixel_buffer_object") ||
-             vlc_gl_HasExtension(interop->gl, "GL_EXT_pixel_buffer_object"));
+            (vlc_gl_HasExtension(&extension_vt, "GL_ARB_pixel_buffer_object") ||
+             vlc_gl_HasExtension(&extension_vt, "GL_EXT_pixel_buffer_object"));
 
         const bool supports_pbo = has_pbo && priv->gl.BufferData
             && priv->gl.BufferSubData;


=====================================
modules/video_output/opengl/interop_vaapi.c
=====================================
@@ -33,7 +33,7 @@
 #include <vlc_codec.h>
 #include <vlc_plugin.h>
 
-#include "gl_api.h"
+#include "gl_util.h"
 #include "interop.h"
 #include "../../hw/vaapi/vlc_vaapi.h"
 
@@ -446,7 +446,10 @@ Open(vlc_object_t *obj)
         goto error;
     }
 
-    if (!vlc_gl_HasExtension(interop->gl, "GL_OES_EGL_image"))
+    struct vlc_gl_extension_vt extension_vt;
+    vlc_gl_LoadExtensionFunctions(interop->gl, &extension_vt);
+
+    if (!vlc_gl_HasExtension(&extension_vt, "GL_OES_EGL_image"))
         goto error;
 
     priv = interop->priv = calloc(1, sizeof(struct priv));


=====================================
modules/video_output/opengl/interop_vdpau.c
=====================================
@@ -36,6 +36,7 @@
 #include <vlc_plugin.h>
 
 #include "gl_api.h"
+#include "gl_util.h"
 #include "../../hw/vdpau/vlc_vdpau.h"
 #include "interop.h"
 
@@ -125,12 +126,16 @@ Open(vlc_object_t *obj)
     struct vlc_gl_interop *interop = (void *) obj;
     if (interop->vctx == NULL)
         return VLC_EGENERIC;
+
+    struct vlc_gl_extension_vt extension_vt;
+    vlc_gl_LoadExtensionFunctions(interop->gl, &extension_vt);
+
     vlc_decoder_device *dec_device = vlc_video_context_HoldDevice(interop->vctx);
     if (GetVDPAUOpaqueDevice(dec_device) == NULL
      || (interop->fmt_in.i_chroma != VLC_CODEC_VDPAU_VIDEO_420
       && interop->fmt_in.i_chroma != VLC_CODEC_VDPAU_VIDEO_422
       && interop->fmt_in.i_chroma != VLC_CODEC_VDPAU_VIDEO_444)
-     || !vlc_gl_HasExtension(interop->gl, "GL_NV_vdpau_interop"))
+     || !vlc_gl_HasExtension(&extension_vt, "GL_NV_vdpau_interop"))
     {
         vlc_decoder_device_Release(dec_device);
         return VLC_EGENERIC;


=====================================
modules/video_output/opengl/sampler.c
=====================================
@@ -66,6 +66,8 @@ struct vlc_gl_sampler_priv {
      * conversion), selected by vlc_gl_sampler_SetCurrentPlane(). */
     bool expose_planes;
     unsigned plane;
+
+    struct vlc_gl_extension_vt extension_vt;
 };
 
 static inline struct vlc_gl_sampler_priv *
@@ -424,7 +426,7 @@ opengl_init_swizzle(struct vlc_gl_sampler *sampler,
     struct vlc_gl_sampler_priv *priv = PRIV(sampler);
 
     GLint oneplane_texfmt;
-    if (vlc_gl_HasExtension(priv->gl, "GL_ARB_texture_rg"))
+    if (vlc_gl_HasExtension(&priv->extension_vt, "GL_ARB_texture_rg"))
         oneplane_texfmt = GL_RED;
     else
         oneplane_texfmt = GL_LUMINANCE;
@@ -829,6 +831,7 @@ vlc_gl_sampler_New(struct vlc_gl_t *gl, const struct vlc_gl_api *api,
         return NULL;
 
     struct vlc_gl_sampler *sampler = &priv->sampler;
+    vlc_gl_LoadExtensionFunctions(gl, &priv->extension_vt);
 
     priv->uloc.pl_vars = NULL;
     priv->pl_ctx = NULL;


=====================================
modules/video_output/win32/glwin32.c
=====================================
@@ -195,7 +195,7 @@ static void Close(vout_display_t *vd)
             vout_display_opengl_Delete(sys->vgl);
             vlc_gl_ReleaseCurrent (gl);
         }
-        vlc_gl_Release (gl);
+        vlc_gl_Delete(gl);
         vlc_object_delete(surface);
     }
 


=====================================
src/libvlccore.sym
=====================================
@@ -708,9 +708,7 @@ vlc_queue_Dequeue
 vlc_queue_DequeueAll
 vlc_gl_Create
 vlc_gl_CreateOffscreen
-vlc_gl_Release
-vlc_gl_Hold
-vlc_gl_HasExtension
+vlc_gl_Delete
 vlc_gl_surface_Create
 vlc_gl_surface_CheckSize
 vlc_gl_surface_Destroy


=====================================
src/video_output/opengl.c
=====================================
@@ -36,14 +36,6 @@
 struct vlc_gl_priv_t
 {
     vlc_gl_t gl;
-    vlc_atomic_rc_t rc;
-
-    struct {
-        const uint8_t* (*GetString)(uint32_t);
-        const uint8_t* (*GetStringi)(uint32_t, uint32_t);
-        void (*GetIntegerv)(uint32_t, int32_t *);
-        uint32_t (*GetError)();
-    } vt;
 };
 
 static int vlc_gl_start(void *func, bool forced, va_list ap)
@@ -91,9 +83,6 @@ vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *restrict cfg,
     gl->api_type = api_type;
     gl->surface = wnd;
     gl->device = NULL;
-    glpriv->vt.GetString = NULL;
-    glpriv->vt.GetStringi = NULL;
-    glpriv->vt.GetIntegerv = NULL;
 
     gl->module = vlc_module_load(gl, type, name, true, vlc_gl_start, gl,
                                  cfg->display.width, cfg->display.height);
@@ -104,7 +93,6 @@ vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *restrict cfg,
     }
     assert(gl->make_current && gl->release_current && gl->swap
         && gl->get_proc_address);
-    vlc_atomic_rc_init(&glpriv->rc);
 
     return &glpriv->gl;
 }
@@ -158,8 +146,6 @@ vlc_gl_t *vlc_gl_CreateOffscreen(vlc_object_t *parent,
     /* The implementation must initialize the output chroma */
     assert(gl->offscreen_chroma_out != VLC_CODEC_UNKNOWN);
 
-    vlc_atomic_rc_init(&glpriv->rc);
-
     assert(gl->make_current);
     assert(gl->release_current);
     assert(gl->swap_offscreen);
@@ -168,18 +154,8 @@ vlc_gl_t *vlc_gl_CreateOffscreen(vlc_object_t *parent,
     return &glpriv->gl;
 }
 
-void vlc_gl_Hold(vlc_gl_t *gl)
-{
-    struct vlc_gl_priv_t *glpriv = (struct vlc_gl_priv_t *)gl;
-    vlc_atomic_rc_inc(&glpriv->rc);
-}
-
-void vlc_gl_Release(vlc_gl_t *gl)
+void vlc_gl_Delete(vlc_gl_t *gl)
 {
-    struct vlc_gl_priv_t *glpriv = (struct vlc_gl_priv_t *)gl;
-    if (!vlc_atomic_rc_dec(&glpriv->rc))
-        return;
-
     if (gl->destroy != NULL)
         gl->destroy(gl);
 
@@ -190,69 +166,6 @@ void vlc_gl_Release(vlc_gl_t *gl)
     vlc_object_delete(gl);
 }
 
-bool vlc_gl_HasExtension(vlc_gl_t *gl, const char *extension)
-{
-#define GL_NO_ERROR 0
-#define GL_VERSION 0x1F02
-#define GL_MAJOR_VERSION 0x821B
-#define GL_EXTENSIONS 0x1F03
-#define GL_NUM_EXTENSIONS 0x821D
-    struct vlc_gl_priv_t *glpriv = (struct vlc_gl_priv_t *)gl;
-    /* Cache the OpenGL function before checking. It's not done at OpenGL
-     * provider creation because the context might not be current, and it is
-     * not done at MakeCurrent because MakeCurrent is currently called at each
-     * frames, whereas vlc_gl_HasExtension can be called only during the
-     * client code initialization. */
-    if (glpriv->vt.GetString == NULL && glpriv->vt.GetStringi == NULL)
-    {
-        glpriv->vt.GetString = vlc_gl_GetProcAddress(gl, "glGetString");
-        glpriv->vt.GetIntegerv = vlc_gl_GetProcAddress(gl, "glGetIntegerv");
-        glpriv->vt.GetError = vlc_gl_GetProcAddress(gl, "glGetError");
-
-        int32_t version;
-        /* GL_MAJOR_VERSION is available in every OpenGL and GLES>=3.
-         * https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGet.xhtml
-         * https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glGet.xhtml
-         * It will return a GL_INVALID_ENUM error on GLES<3
-         */
-        glpriv->vt.GetIntegerv(GL_MAJOR_VERSION, &version);
-        uint32_t error = glpriv->vt.GetError();
-
-        if (error != GL_NO_ERROR)
-            version = 2;
-
-        /* Drain the errors before continuing. */
-        while (error != GL_NO_ERROR)
-            error = glpriv->vt.GetError();
-
-        /* glGetStringi is available in OpenGL>=3 and GLES>=3.
-         * https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetString.xhtml
-         * https://www.khronos.org/registry/OpenGL-Refpages/es3/html/glGetString.xhtml
-         */
-        if (version >= 3)
-            glpriv->vt.GetStringi = vlc_gl_GetProcAddress(gl, "glGetStringi");
-    }
-
-    /* Fallback to legacy checking mode. */
-    if (glpriv->vt.GetStringi == NULL)
-    {
-        const uint8_t *extensions = glpriv->vt.GetString(GL_EXTENSIONS);
-        return vlc_gl_StrHasToken((const char *)extensions, extension);
-    }
-
-    /* Unfortunately, no order is defined by the standard, so just loop over
-     * the different extensions linearily. */
-    int32_t count = 0;
-    glpriv->vt.GetIntegerv(GL_NUM_EXTENSIONS, &count);
-    for (int i = 0; i < count; ++i)
-    {
-        const uint8_t *name = glpriv->vt.GetStringi(GL_EXTENSIONS, i);
-        if (strcmp((const char *)name, extension) == 0)
-            return true;
-    }
-    return false;
-}
-
 #include <vlc_vout_window.h>
 
 typedef struct vlc_gl_surface
@@ -375,7 +288,7 @@ void vlc_gl_surface_Destroy(vlc_gl_t *gl)
     vout_window_t *surface = gl->surface;
     vlc_gl_surface_t *sys = surface->owner.sys;
 
-    vlc_gl_Release(gl);
+    vlc_gl_Delete(gl);
     vout_window_Disable(surface);
     vout_window_Delete(surface);
     free(sys);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/89e20ea0d87f414f763ce38ff5579aec61f71b42...a162a17762b99c7fa9ed75f0da704750156b5b6b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/89e20ea0d87f414f763ce38ff5579aec61f71b42...a162a17762b99c7fa9ed75f0da704750156b5b6b
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list