[vlc-commits] opengl: fix npot support

Romain Vimont git at videolan.org
Thu Mar 4 18:48:41 UTC 2021


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Mar  4 14:30:23 2021 +0100| [004dde589e39a6bb200feb5062be7c84e8dd106c] | committer: Alexandre Janniaux

opengl: fix npot support

If npot (non-power-of-two) textures are not supported, then the picture
visible dimensions is not the same as the texture dimensions.

When updating a picture, the interop (which calls glTexSubImage2D() or
similar) expects picture dimensions.

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

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

 modules/video_output/opengl/sampler.c      | 9 +++++++--
 modules/video_output/opengl/sub_renderer.c | 5 ++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c
index 8588cd883c..bc76fec97b 100644
--- a/modules/video_output/opengl/sampler.c
+++ b/modules/video_output/opengl/sampler.c
@@ -72,6 +72,9 @@ struct vlc_gl_sampler_priv {
     GLsizei tex_widths[PICTURE_PLANE_MAX];
     GLsizei tex_heights[PICTURE_PLANE_MAX];
 
+    GLsizei visible_widths[PICTURE_PLANE_MAX];
+    GLsizei visible_heights[PICTURE_PLANE_MAX];
+
     GLuint textures[PICTURE_PLANE_MAX];
 
     struct {
@@ -1011,6 +1014,8 @@ vlc_gl_sampler_NewFromInterop(struct vlc_gl_interop *interop)
                         / interop->texs[j].w.den;
         const GLsizei h = interop->fmt_out.i_visible_height * interop->texs[j].h.num
                         / interop->texs[j].h.den;
+        priv->visible_widths[j] = w;
+        priv->visible_heights[j] = h;
         if (interop->api->supports_npot) {
             priv->tex_widths[j]  = w;
             priv->tex_heights[j] = h;
@@ -1220,8 +1225,8 @@ vlc_gl_sampler_UpdatePicture(struct vlc_gl_sampler *sampler, picture_t *picture)
 
     /* Update the texture */
     return interop->ops->update_textures(interop, priv->textures,
-                                         priv->tex_widths, priv->tex_heights,
-                                         picture, NULL);
+                                         priv->visible_widths,
+                                         priv->visible_heights, picture, NULL);
 }
 
 int
diff --git a/modules/video_output/opengl/sub_renderer.c b/modules/video_output/opengl/sub_renderer.c
index 970067ce82..033df9989b 100644
--- a/modules/video_output/opengl/sub_renderer.c
+++ b/modules/video_output/opengl/sub_renderer.c
@@ -284,8 +284,11 @@ vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr, subpicture_t *subpic
             /* Use the visible pitch of the region */
             r->p_picture->p[0].i_visible_pitch = r->fmt.i_visible_width
                                                * r->p_picture->p[0].i_pixel_pitch;
+
+            GLsizei width = r->fmt.i_visible_width;
+            GLsizei height = r->fmt.i_visible_height;
             int ret = interop->ops->update_textures(interop, &glr->texture,
-                                                    &glr->width, &glr->height,
+                                                    &width, &height,
                                                     r->p_picture, &pixels_offset);
             if (ret != VLC_SUCCESS)
                 break;



More information about the vlc-commits mailing list