[vlc-devel] [PATCH v2 08/13] opengl: extract shader extensions
Romain Vimont
rom1v at videolabs.io
Tue Mar 30 11:14:06 UTC 2021
Compute the shader extensions in a separate function, to be able to
reuse it.
---
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;
--
2.31.0
More information about the vlc-devel
mailing list