[vlc-commits] opengl: extract shader extensions

Romain Vimont git at videolan.org
Mon Apr 12 15:28:43 UTC 2021


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Tue Mar 30 13:14:06 2021 +0200| [83467d43e60985c7bd6a690040e8c02119f51de6] | committer: Alexandre Janniaux

opengl: extract shader extensions

Compute the shader extensions in a separate function, to be able to
reuse it.

Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>

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

 modules/video_output/opengl/sampler.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c
index 6dea5204a0..b30eab6d03 100644
--- a/modules/video_output/opengl/sampler.c
+++ b/modules/video_output/opengl/sampler.c
@@ -737,6 +737,22 @@ GetNames(GLenum tex_target, const char **glsl_sampler, const char **texture)
     }
 }
 
+static int
+InitShaderExtensions(struct vlc_gl_sampler *sampler, GLenum tex_target)
+{
+    if (tex_target == GL_TEXTURE_EXTERNAL_OES)
+    {
+        sampler->shader.extensions =
+            strdup("#extension GL_OES_EGL_image_external : require\n");
+        if (!sampler->shader.extensions)
+            return VLC_EGENERIC;
+    }
+    else
+        sampler->shader.extensions = NULL;
+
+    return VLC_SUCCESS;
+}
+
 static int
 opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
                             const video_format_t *fmt)
@@ -939,15 +955,11 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
     if (vlc_memstream_close(&ms) != 0)
         return VLC_EGENERIC;
 
-    if (tex_target == GL_TEXTURE_EXTERNAL_OES)
+    ret = InitShaderExtensions(sampler, tex_target);
+    if (ret != VLC_SUCCESS)
     {
-        sampler->shader.extensions =
-            strdup("#extension GL_OES_EGL_image_external : require\n");
-        if (!sampler->shader.extensions)
-        {
-            free(ms.ptr);
-            return VLC_EGENERIC;
-        }
+        free(ms.ptr);
+        return VLC_EGENERIC;
     }
     sampler->shader.body = ms.ptr;
 



More information about the vlc-commits mailing list