[vlc-devel] [PATCH v2 11/13] opengl: make direct sampler support multi-texture

Romain Vimont rom1v at videolabs.io
Tue Mar 30 11:14:09 UTC 2021


A "direct" sampler (i.e. a sampler without interop) only supported one
texture, because the output of the previous filter was assumed to be
RGBA in a single plane.

A deinterlace filter will output several planes, so the sampler of the
next filter must be able to receive all of them.
---
 modules/video_output/opengl/filters.c      |  9 +++++----
 modules/video_output/opengl/sampler.c      | 13 +++++++------
 modules/video_output/opengl/sampler_priv.h | 12 ++++++------
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/modules/video_output/opengl/filters.c b/modules/video_output/opengl/filters.c
index 6795af3321..7db8b5a685 100644
--- a/modules/video_output/opengl/filters.c
+++ b/modules/video_output/opengl/filters.c
@@ -478,10 +478,11 @@ vlc_gl_filters_Draw(struct vlc_gl_filters *filters)
         if (previous)
         {
             /* Read from the output of the previous filter */
-            int ret = vlc_gl_sampler_UpdateTexture(priv->sampler,
-                                                   previous->texture_out,
-                                                   previous->size_out.width,
-                                                   previous->size_out.height);
+            GLuint tex = previous->texture_out;
+            GLsizei width = previous->size_out.width;
+            GLsizei height = previous->size_out.height;
+            int ret = vlc_gl_sampler_UpdateTextures(priv->sampler, &tex, &width,
+                                                    &height);
             if (ret != VLC_SUCCESS)
             {
                 msg_Err(filters->gl, "Could not update sampler texture");
diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c
index 42550a5a24..1c04935292 100644
--- a/modules/video_output/opengl/sampler.c
+++ b/modules/video_output/opengl/sampler.c
@@ -91,7 +91,7 @@ struct vlc_gl_sampler_priv {
      *  - created with _NewFromInterop(), it receives input pictures from VLC
      *    (picture_t) via _UpdatePicture();
      *  - created with _NewFromTexture2D() (interop is NULL), it receives
-     *    directly OpenGL textures via _UpdateTexture().
+     *    directly OpenGL textures via _UpdateTextures().
      */
     struct vlc_gl_interop *interop;
 
@@ -1351,15 +1351,16 @@ vlc_gl_sampler_UpdatePicture(struct vlc_gl_sampler *sampler, picture_t *picture)
 }
 
 int
-vlc_gl_sampler_UpdateTexture(struct vlc_gl_sampler *sampler, GLuint texture,
-                             GLsizei tex_width, GLsizei tex_height)
+vlc_gl_sampler_UpdateTextures(struct vlc_gl_sampler *sampler, GLuint textures[],
+                              GLsizei tex_widths[], GLsizei tex_heights[])
 {
     struct vlc_gl_sampler_priv *priv = PRIV(sampler);
     assert(!priv->interop);
 
-    priv->textures[0] = texture;
-    priv->tex_widths[0] = tex_width;
-    priv->tex_heights[0] = tex_height;
+    unsigned tex_count = sampler->tex_count;
+    memcpy(priv->textures, textures, tex_count * sizeof(textures[0]));
+    memcpy(priv->tex_widths, tex_widths, tex_count * sizeof(tex_widths[0]));
+    memcpy(priv->tex_heights, tex_heights, tex_count * sizeof(tex_heights[0]));
 
     return VLC_SUCCESS;
 }
diff --git a/modules/video_output/opengl/sampler_priv.h b/modules/video_output/opengl/sampler_priv.h
index 0fcb99e9c3..d115c6bb08 100644
--- a/modules/video_output/opengl/sampler_priv.h
+++ b/modules/video_output/opengl/sampler_priv.h
@@ -82,18 +82,18 @@ vlc_gl_sampler_UpdatePicture(struct vlc_gl_sampler *sampler,
                              picture_t *picture);
 
 /**
- * Update the input texture
+ * Update the input textures
  *
  * Warning: only call on sampler created by vlc_gl_sampler_NewFromTexture2D().
  *
  * \param sampler the sampler
- * \param texture the new texture, with target GL_TEXTURE_2D
- * \param tex_width the texture width
- * \param tex_height the texture height
+ * \param textures the new textures, with target GL_TEXTURE_2D
+ * \param tex_widths the textures width
+ * \param tex_heights the textures height
  */
 int
-vlc_gl_sampler_UpdateTexture(struct vlc_gl_sampler *sampler, GLuint texture,
-                             GLsizei tex_width, GLsizei tex_height);
+vlc_gl_sampler_UpdateTextures(struct vlc_gl_sampler *sampler, GLuint textures[],
+                              GLsizei tex_widths[], GLsizei tex_heights[]);
 
 /**
  * Select the plane to expose
-- 
2.31.0



More information about the vlc-devel mailing list