opengl: interop: add texture deallocate callback

some interop may require resources to be cleanup before the texture is released
This commit is contained in:
Pierre Lamot 2024-01-08 17:21:18 +01:00 committed by Steve Lhomme
parent 3c98b62c10
commit e0a1e90229
2 changed files with 12 additions and 0 deletions

View File

@ -47,6 +47,16 @@ struct vlc_gl_interop_ops {
uint32_t textures[], const int32_t tex_width[],
const int32_t tex_height[]);
/**
* Callback to deallocate data for bound texture
*
* This function pointer can be NULL. it will be called before calling glDeleteTextures
*
* \param interop the OpenGL interop
* \param textures array of textures to bind (one per plane)
*/
void (*deallocate_textures)(const struct vlc_gl_interop *interop, uint32_t textures[]);
/**
* Callback to update a picture
*

View File

@ -98,6 +98,8 @@ vlc_gl_interop_DeleteTextures(const struct vlc_gl_interop *interop,
{
struct vlc_gl_interop_private *priv =
container_of(interop, struct vlc_gl_interop_private, interop);
if (interop->ops->deallocate_textures != NULL)
interop->ops->deallocate_textures(interop, textures);
priv->gl.DeleteTextures(interop->tex_count, textures);
memset(textures, 0, interop->tex_count * sizeof(GLuint));
}