[vlc-devel] [PATCH 13/17] opengl: remove alpha parameter from prepare_shader

Romain Vimont rom1v at videolabs.io
Thu Apr 2 14:24:26 CEST 2020


The alpha value was used to render subpictures, which are now drawn by
the subpictures renderer using its own fragment shader.
---
 modules/video_output/opengl/fragment_shaders.c | 17 +++++------------
 modules/video_output/opengl/renderer.c         |  2 +-
 modules/video_output/opengl/sampler.h          |  6 ++----
 3 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index 6efeb4b049..e9465718a3 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -253,10 +253,6 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
         }
     }
 
-    sampler->uloc.FillColor = vt->GetUniformLocation(program, "FillColor");
-    if (sampler->uloc.FillColor == -1)
-        return VLC_EGENERIC;
-
 #ifdef HAVE_LIBPLACEBO
     const struct pl_shader_res *res = sampler->pl_sh_res;
     for (int i = 0; res && i < res->num_variables; i++) {
@@ -282,7 +278,7 @@ GetTransformMatrix(const struct vlc_gl_interop *interop)
 static void
 sampler_base_prepare_shader(const struct vlc_gl_sampler *sampler,
                             const GLsizei *tex_width,
-                            const GLsizei *tex_height, float alpha)
+                            const GLsizei *tex_height)
 {
     (void) tex_width; (void) tex_height;
     const struct vlc_gl_interop *interop = sampler->interop;
@@ -304,8 +300,6 @@ sampler_base_prepare_shader(const struct vlc_gl_sampler *sampler,
                              sampler->var.TexCoordsMap[i]);
     }
 
-    vt->Uniform4f(sampler->uloc.FillColor, 1.0f, 1.0f, 1.0f, alpha);
-
     const GLfloat *tm = GetTransformMatrix(interop);
     vt->UniformMatrix4fv(sampler->uloc.TransformMatrix, 1, GL_FALSE, tm);
 
@@ -383,9 +377,9 @@ sampler_xyz12_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
 static void
 sampler_xyz12_prepare_shader(const struct vlc_gl_sampler *sampler,
                              const GLsizei *tex_width,
-                             const GLsizei *tex_height, float alpha)
+                             const GLsizei *tex_height)
 {
-    (void) tex_width; (void) tex_height; (void) alpha;
+    (void) tex_width; (void) tex_height;
     const struct vlc_gl_interop *interop = sampler->interop;
     const opengl_vtable_t *vt = sampler->vt;
 
@@ -660,8 +654,7 @@ opengl_fragment_shader_init(struct vlc_gl_renderer *renderer, GLenum tex_target,
     if (is_yuv)
         ADD("uniform mat4 ConvMatrix;\n");
 
-    ADD("uniform vec4 FillColor;\n"
-        "vec4 vlc_texture(vec2 pic_coords) {\n"
+    ADD("vec4 vlc_texture(vec2 pic_coords) {\n"
         /* Homogeneous (oriented) coordinates */
         " vec3 pic_hcoords = vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).st, 1.0);\n"
         " vec2 tex_coords;\n");
@@ -711,7 +704,7 @@ opengl_fragment_shader_init(struct vlc_gl_renderer *renderer, GLenum tex_target,
     }
 #endif
 
-    ADD(" return result * FillColor;\n"
+    ADD(" return result;\n"
         "}\n");
 
 #undef ADD
diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index ba450e063c..f544198345 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -832,7 +832,7 @@ static void DrawWithShaders(struct vlc_gl_renderer *renderer)
     struct vlc_gl_sampler *sampler = renderer->sampler;
     const opengl_vtable_t *vt = renderer->vt;
     sampler->pf_prepare_shader(sampler, sampler->tex_width,
-                               sampler->tex_height, 1.0f);
+                               sampler->tex_height);
 
     vt->BindBuffer(GL_ARRAY_BUFFER, renderer->texture_buffer_object);
     assert(renderer->aloc.PicCoordsIn != -1);
diff --git a/modules/video_output/opengl/sampler.h b/modules/video_output/opengl/sampler.h
index c021ce8edf..c295083df2 100644
--- a/modules/video_output/opengl/sampler.h
+++ b/modules/video_output/opengl/sampler.h
@@ -61,7 +61,6 @@ struct vlc_gl_sampler {
         GLint Texture[PICTURE_PLANE_MAX];
         GLint TexSize[PICTURE_PLANE_MAX]; /* for GL_TEXTURE_RECTANGLE */
         GLint ConvMatrix;
-        GLint FillColor;
         GLint *pl_vars; /* for pl_sh_res */
 
         GLint TransformMatrix;
@@ -112,11 +111,10 @@ struct vlc_gl_sampler {
      * \param sampler the sampler
      * \param tex_width array of tex width (one per plane)
      * \param tex_height array of tex height (one per plane)
-     * \param alpha alpha value, used only for RGBA fragment shader
      */
     void (*pf_prepare_shader)(const struct vlc_gl_sampler *sampler,
-                              const GLsizei *tex_width, const GLsizei *tex_height,
-                              float alpha);
+                              const GLsizei *tex_width,
+                              const GLsizei *tex_height);
 };
 
 /**
-- 
2.26.0



More information about the vlc-devel mailing list