[vlc-devel] [PATCH] opengl: fix npot support

Alexandre Janniaux ajanni at videolabs.io
Thu Mar 4 18:49:48 UTC 2021


Merged, thanks !

Regards,
--
Alexandre Janniaux
Videolabs

On Thu, Mar 04, 2021 at 02:30:23PM +0100, Romain Vimont wrote:
> 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.
> ---
>
> Just force api->supports_npot to false in gl_api.c to test easily.
>
>  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;
> --
> 2.30.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list