[vlc-commits] opengl: move sampler initialization to constructor

Romain Vimont git at videolan.org
Thu Jun 4 11:04:37 CEST 2020


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Feb  6 09:56:52 2020 +0100| [1f7e5c0ecf08134e4b7e3adc6bb3bf1f72d63e10] | committer: Alexandre Janniaux

opengl: move sampler initialization to constructor

Move opengl_fragment_shader_init() call from renderer to sampler.

This function initializes parts of the sampler.

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

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

 modules/video_output/opengl/renderer.c | 10 ++--------
 modules/video_output/opengl/sampler.c  | 17 ++++++++++++++---
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index 97653a3ad5..a8f71fea03 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -270,12 +270,6 @@ BuildFragmentShader(struct vlc_gl_renderer *renderer)
 {
     struct vlc_gl_sampler *sampler = renderer->sampler;
     const struct vlc_gl_interop *interop = sampler->interop;
-    int ret =
-        opengl_fragment_shader_init(sampler, interop->tex_target,
-                                    interop->sw_fmt.i_chroma,
-                                    interop->sw_fmt.space);
-    if (ret != VLC_SUCCESS)
-        return NULL;
 
     static const char *template =
         "#version %u\n"
@@ -291,8 +285,8 @@ BuildFragmentShader(struct vlc_gl_renderer *renderer)
                            ? sampler->shader.extensions : "";
 
     char *code;
-    ret = asprintf(&code, template, renderer->glsl_version, extensions,
-                   renderer->glsl_precision_header, sampler->shader.body);
+    int ret = asprintf(&code, template, renderer->glsl_version, extensions,
+                       renderer->glsl_precision_header, sampler->shader.body);
     if (ret < 0)
         return NULL;
 
diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c
index 8b20e4d2e0..a3f1405bd7 100644
--- a/modules/video_output/opengl/sampler.c
+++ b/modules/video_output/opengl/sampler.c
@@ -37,6 +37,7 @@
 #include "gl_api.h"
 #include "gl_common.h"
 #include "gl_util.h"
+#include "internal.h"
 #include "interop.h"
 
 struct vlc_gl_sampler *
@@ -81,6 +82,16 @@ vlc_gl_sampler_New(struct vlc_gl_interop *interop)
     }
 #endif
 
+    int ret =
+        opengl_fragment_shader_init(sampler, interop->tex_target,
+                                    interop->sw_fmt.i_chroma,
+                                    interop->sw_fmt.space);
+    if (ret != VLC_SUCCESS)
+    {
+        free(sampler);
+        return NULL;
+    }
+
     /* Texture size */
     for (unsigned j = 0; j < interop->tex_count; j++) {
         const GLsizei w = interop->fmt.i_visible_width  * interop->texs[j].w.num
@@ -98,9 +109,9 @@ vlc_gl_sampler_New(struct vlc_gl_interop *interop)
 
     if (!interop->handle_texs_gen)
     {
-        int ret = vlc_gl_interop_GenerateTextures(interop, sampler->tex_width,
-                                                  sampler->tex_height,
-                                                  sampler->textures);
+        ret = vlc_gl_interop_GenerateTextures(interop, sampler->tex_width,
+                                              sampler->tex_height,
+                                              sampler->textures);
         if (ret != VLC_SUCCESS)
         {
             free(sampler);



More information about the vlc-commits mailing list