vlc | branch: master | Romain Vimont <ro...@videolabs.io> | Tue Mar 30 13:14:07 2021 +0200| [f41577d4b430ccd9e31840c4145cc8d8fe99e9ec] | committer: Alexandre Janniaux
opengl: expose texture sizes in sampler The number of input planes and their sizes might be useful to filters implementation. It could be retrieved by vlc_fourcc_GetChromaDescription(), but for convenience, expose them in sampler. Signed-off-by: Alexandre Janniaux <aja...@videolabs.io> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f41577d4b430ccd9e31840c4145cc8d8fe99e9ec --- modules/video_output/opengl/sampler.c | 17 ++++++++++------- modules/video_output/opengl/sampler.h | 7 +++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c index b30eab6d03..39b37c2ca2 100644 --- a/modules/video_output/opengl/sampler.c +++ b/modules/video_output/opengl/sampler.c @@ -78,7 +78,6 @@ struct vlc_gl_sampler_priv { GLuint textures[PICTURE_PLANE_MAX]; - unsigned tex_count; GLenum tex_target; struct { @@ -289,8 +288,8 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program) vt->GetUniformLocation(program, "OrientationMatrix"); assert(priv->uloc.OrientationMatrix != -1); - assert(priv->tex_count < 10); /* to guarantee variable names length */ - for (unsigned int i = 0; i < priv->tex_count; ++i) + assert(sampler->tex_count < 10); /* to guarantee variable names length */ + for (unsigned int i = 0; i < sampler->tex_count; ++i) { char name[sizeof("TexCoordsMaps[X]")]; @@ -341,7 +340,7 @@ sampler_base_load(const struct vlc_gl_sampler *sampler) vt->UniformMatrix4fv(priv->uloc.ConvMatrix, 1, GL_FALSE, priv->conv_matrix); - for (unsigned i = 0; i < priv->tex_count; ++i) + for (unsigned i = 0; i < sampler->tex_count; ++i) { vt->Uniform1i(priv->uloc.Textures[i], i); @@ -362,7 +361,7 @@ sampler_base_load(const struct vlc_gl_sampler *sampler) if (priv->tex_target == GL_TEXTURE_RECTANGLE) { - for (unsigned i = 0; i < priv->tex_count; ++i) + for (unsigned i = 0; i < sampler->tex_count; ++i) vt->Uniform2f(priv->uloc.TexSizes[i], priv->tex_widths[i], priv->tex_heights[i]); } @@ -774,7 +773,7 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target, return VLC_EGENERIC; unsigned tex_count = desc->plane_count; - priv->tex_count = tex_count; + sampler->tex_count = tex_count; InitOrientationMatrix(priv->var.OrientationMatrix, orientation); @@ -1002,6 +1001,10 @@ CreateSampler(struct vlc_gl_interop *interop, struct vlc_gl_t *gl, sampler->shader.extensions = NULL; sampler->shader.body = NULL; + /* Expose the texture sizes publicly */ + sampler->tex_widths = priv->tex_widths; + sampler->tex_heights = priv->tex_heights; + #ifdef HAVE_LIBPLACEBO // Create the main libplacebo context priv->pl_ctx = vlc_placebo_Create(VLC_OBJECT(gl)); @@ -1032,7 +1035,7 @@ CreateSampler(struct vlc_gl_interop *interop, struct vlc_gl_t *gl, return NULL; } - unsigned tex_count = priv->tex_count; + unsigned tex_count = sampler->tex_count; assert(!interop || interop->tex_count == tex_count); for (unsigned i = 0; i < tex_count; ++i) diff --git a/modules/video_output/opengl/sampler.h b/modules/video_output/opengl/sampler.h index c3ddfd7204..95947c72da 100644 --- a/modules/video_output/opengl/sampler.h +++ b/modules/video_output/opengl/sampler.h @@ -53,6 +53,13 @@ struct vlc_gl_sampler { /* Input format */ video_format_t fmt; + /* Number of input planes */ + unsigned tex_count; + + /* Texture sizes (arrays of tex_count values) */ + const GLsizei *tex_widths; + const GLsizei *tex_heights; + struct { /** * Piece of fragment shader code declaration OpenGL extensions. _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits