[vlc-devel] [PATCH 26/41] opengl: remove alpha parameter from prepare_shader

Romain Vimont rom1v at videolabs.io
Fri Feb 7 17:42:12 CET 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 e7eaeb987b..aed5844a4c 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++) {
@@ -271,7 +267,7 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
 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;
@@ -293,8 +289,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 = NULL;
     if (interop->ops && interop->ops->get_transform_matrix)
         tm = interop->ops->get_transform_matrix(interop);
@@ -358,9 +352,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 opengl_vtable_t *vt = sampler->vt;
 
     vt->Uniform1i(sampler->uloc.Texture[0], 0);
@@ -615,8 +609,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"
         /* Oriented picture coordinates */
         " vec2 pic_txcoords = (TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).st;\n"
         /* Homogeneous coords */
@@ -672,7 +665,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 19d7289508..c4b137d455 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -835,7 +835,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 824703a7da..25b818cbe0 100644
--- a/modules/video_output/opengl/sampler.h
+++ b/modules/video_output/opengl/sampler.h
@@ -62,7 +62,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;
@@ -113,11 +112,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.25.0



More information about the vlc-devel mailing list