[vlc-commits] [Git][videolan/vlc][master] 2 commits: opengl: renderer: fix OpenGL CoreProfile compatibility

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Aug 5 11:29:28 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
f479109d by Pierre Lamot at 2025-08-05T11:03:53+00:00
opengl: renderer: fix OpenGL CoreProfile compatibility

In deprecation list in OpenGL 3.0 and in removed feature since OpenGL 3.1.

```
Client vertex arrays - all vertex array attribute pointers must refer to buffer
objects (section 2.9.2). The default vertex array object (the name zero) is
also deprecated. Calling VertexAttribPointer when no buffer object or no
vertex array object is bound will generate an INVALID OPERATION error,
as will calling any array drawing command when no vertex array object is
bound.
```

Available in OpenGLES since 3.0

for older version of OpenGL/OpenGLES we provide a stubbed implementation, as
we're not having usage of more than one (the implicit) vertex array

- - - - -
fbdcb7d6 by Pierre Lamot at 2025-08-05T11:03:53+00:00
opengl: interop: fix OpenGL CoreProfile compatibility

In deprecation list in OpenGL 3.0 and in removed feature since OpenGL 3.1.

```
Fixed-function fragment processing - AreTexturesResident, Pri-
oritizeTextures, and TexParameter target TEXTURE PRIORITY;
TexEnv target TEXTURE ENV, and all associated parameters; Tex-
Env target TEXTURE FILTER CONTROL, and parameter name
TEXTURE LOD BIAS; Enable targets of all dimensionalities (TEXTURE 1D,
TEXTURE 2D, TEXTURE 3D, TEXTURE 1D ARRAY, TEXTURE 2D ARRAY,
and TEXTURE CUBE MAP); Enable target COLOR SUM; Enable target FOG,
Fog, and all associated parameters; and all associated state.
```

- - - - -


5 changed files:

- modules/video_output/opengl/gl_api.c
- modules/video_output/opengl/gl_common.h
- modules/video_output/opengl/interop.c
- modules/video_output/opengl/renderer.c
- modules/video_output/opengl/renderer.h


Changes:

=====================================
modules/video_output/opengl/gl_api.c
=====================================
@@ -32,6 +32,26 @@
 #include "gl_common.h"
 #include "gl_util.h"
 
+/*
+ * OpenGL3.0+ core profile require a non-default vertex array to be binded
+ * to manipulate VertexAttribPointer
+ * OpenGLES 2.0 doesn't support VertexArrays. As we are only using one vertex array
+ * we can just use pretend we support generating and binding it.
+ */
+static void APIENTRY StubGenVertexArrays(GLsizei n, GLuint *arrays) {
+    //OpengGLES 2.0 only use the default VA, trying to generate more than one
+    //means that we are trying to do something unsupported
+    assert(n == 1);
+    arrays[0] = 0;
+}
+static void APIENTRY StubBindVertexArray(GLuint id) {
+    VLC_UNUSED(id);
+}
+static void APIENTRY StubDeleteVertexArrays(GLsizei n, const GLuint * arrays) {
+    VLC_UNUSED(n);
+    VLC_UNUSED(arrays);
+}
+
 int
 vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
 {
@@ -155,7 +175,6 @@ vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
     GET_PROC_ADDR_OPTIONAL(FenceSync);
     GET_PROC_ADDR_OPTIONAL(DeleteSync);
     GET_PROC_ADDR_OPTIONAL(ClientWaitSync);
-#undef GET_PROC_ADDR
 
     GL_ASSERT_NOERROR(&api->vt);
     GLint version;
@@ -212,5 +231,20 @@ vlc_gl_api_Init(struct vlc_gl_api *api, vlc_gl_t *gl)
     else
         api->supports_sampler3D = false;
 
+    //OpenGL 3.0+ / OpenGLES 3.0+ should provide these functions
+    //On OSX, with OpenGL2 compatible profile, loading theses function would succeed
+    //but they are unusable, so we stub them by default with OpenGL 2 /OpenGLES 2 contextes
+    if (version >= 3) {
+        GET_PROC_ADDR(GenVertexArrays);
+        GET_PROC_ADDR(BindVertexArray);
+        GET_PROC_ADDR(DeleteVertexArrays);
+    } else {
+        api->vt.GenVertexArrays = StubGenVertexArrays;
+        api->vt.BindVertexArray = StubBindVertexArray;
+        api->vt.DeleteVertexArrays = StubDeleteVertexArrays;
+    }
+
     return VLC_SUCCESS;
 }
+
+#undef GET_PROC_ADDR


=====================================
modules/video_output/opengl/gl_common.h
=====================================
@@ -268,6 +268,9 @@ typedef void (APIENTRY *PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLi
                                                    GLbitfield mask, GLenum filter);
 typedef void (APIENTRY *PFNGLREADPIXELSPROC) (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *);
 typedef void (APIENTRY *PFNGLGETATTACHEDSHADERPROC)(GLuint, GLsizei, GLsizei*, GLuint*);
+typedef void (APIENTRY *PFNGLBINDVERTEXARRAYPROC) (GLuint array);
+typedef void (APIENTRY *PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRY *PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
 
 /* The following are defined in glext.h but not for GLES2 or on Apple systems */
 #if defined(USE_OPENGL_ES2) || defined(__APPLE__)
@@ -418,6 +421,11 @@ typedef struct {
     PFNGLBUFFERDATAPROC    BufferData;
     PFNGLDELETEBUFFERSPROC DeleteBuffers;
 
+    /* Vertex arrays commands */
+    PFNGLGENVERTEXARRAYSPROC GenVertexArrays;
+    PFNGLBINDVERTEXARRAYPROC BindVertexArray;
+    PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays;
+
     /* Framebuffers commands */
     PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC GetFramebufferAttachmentParameteriv;
     PFNGLGENFRAMEBUFFERSPROC        GenFramebuffers;


=====================================
modules/video_output/opengl/interop.c
=====================================
@@ -63,15 +63,6 @@ vlc_gl_interop_GenerateTextures(const struct vlc_gl_interop *interop,
     {
         priv->gl.BindTexture(interop->tex_target, textures[i]);
 
-#if !defined(USE_OPENGL_ES2)
-        if (interop->gl->api_type == VLC_OPENGL)
-        {
-            /* Set the texture parameters */
-            priv->gl.TexParameterf(interop->tex_target, GL_TEXTURE_PRIORITY, 1.0);
-            priv->gl.TexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-        }
-#endif
-
         priv->gl.TexParameteri(interop->tex_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
         priv->gl.TexParameteri(interop->tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
         priv->gl.TexParameteri(interop->tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);


=====================================
modules/video_output/opengl/renderer.c
=====================================
@@ -306,6 +306,7 @@ Close(struct vlc_gl_filter *filter)
     vt->DeleteBuffers(1, &renderer->vertex_buffer_object);
     vt->DeleteBuffers(1, &renderer->index_buffer_object);
     vt->DeleteBuffers(1, &renderer->texture_buffer_object);
+    vt->DeleteVertexArrays(1, &renderer->vertex_array_object);
 
     if (renderer->program_id != 0)
         vt->DeleteProgram(renderer->program_id);
@@ -774,6 +775,7 @@ Draw(struct vlc_gl_filter *filter, const struct vlc_gl_picture *pic,
     else memcpy(orientation_matrix, MATRIX4_IDENTITY, sizeof(MATRIX4_IDENTITY));
 
     vt->BindBuffer(GL_ARRAY_BUFFER, renderer->texture_buffer_object);
+    vt->BindVertexArray(renderer->vertex_array_object);
     assert(renderer->aloc.PicCoordsIn != -1);
     vt->EnableVertexAttribArray(renderer->aloc.PicCoordsIn);
     vt->VertexAttribPointer(renderer->aloc.PicCoordsIn, 2, GL_FLOAT, 0, 0, 0);
@@ -893,6 +895,8 @@ vlc_gl_renderer_Open(struct vlc_gl_filter *filter,
 
     getViewpointMatrixes(renderer, renderer->projection_mode);
 
+    vt->GenVertexArrays(1, &renderer->vertex_array_object);
+
     vt->GenBuffers(1, &renderer->vertex_buffer_object);
     vt->GenBuffers(1, &renderer->index_buffer_object);
     vt->GenBuffers(1, &renderer->texture_buffer_object);


=====================================
modules/video_output/opengl/renderer.h
=====================================
@@ -85,6 +85,8 @@ struct vlc_gl_renderer
     GLuint index_buffer_object;
     GLuint texture_buffer_object;
 
+    GLuint vertex_array_object;
+
     bool valid_coords;
 
     /* View point */



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f2d969df60a869e1df36b0053fccb483cb7edde4...fbdcb7d6fdbb39ffeeafe5882395988e0a133a2f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f2d969df60a869e1df36b0053fccb483cb7edde4...fbdcb7d6fdbb39ffeeafe5882395988e0a133a2f
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