Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
3c98b62c by Pierre Lamot at 2024-01-10T19:21:55+00:00
opengl: importer: release interop allocated textures using interop function
- - - - -
e0a1e902 by Pierre Lamot at 2024-01-10T19:21:55+00:00
opengl: interop: add texture deallocate callback
some interop may require resources to be cleanup before the texture is released
- - - - -
580f0b44 by Pierre Lamot at 2024-01-10T19:21:55+00:00
interop_dxva2: fix crash with AMD driver
Texture "object" can't be accessed after the texture has been
deleted
- - - - -
4 changed files:
- include/vlc_opengl_interop.h
- modules/video_output/opengl/importer.c
- modules/video_output/opengl/interop.c
- modules/video_output/opengl/interop_dxva2.c
Changes:
=====================================
include/vlc_opengl_interop.h
=====================================
@@ -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
*
=====================================
modules/video_output/opengl/importer.c
=====================================
@@ -274,9 +274,7 @@ vlc_gl_importer_Delete(struct vlc_gl_importer *importer)
if (interop && !interop->handle_texs_gen)
{
- void (*DeleteTextures)(uint32_t, uint32_t*) =
- vlc_gl_GetProcAddress(interop->gl, "glDeleteTextures");
- (*DeleteTextures)(interop->tex_count, importer->pic.textures);
+ vlc_gl_interop_DeleteTextures(interop, importer->pic.textures);
}
free(importer);
=====================================
modules/video_output/opengl/interop.c
=====================================
@@ -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));
}
=====================================
modules/video_output/opengl/interop_dxva2.c
=====================================
@@ -180,6 +180,19 @@ GLConvAllocateTextures(const struct vlc_gl_interop
*interop, uint32_t textures[]
return VLC_SUCCESS;
}
+static void
+GLConvDeallocateTextures(const struct vlc_gl_interop *interop, uint32_t
textures[])
+{
+ struct glpriv *priv = interop->priv;
+
+ if (priv->gl_handle_d3d && priv->gl_render)
+ {
+ priv->vt.DXUnlockObjectsNV(priv->gl_handle_d3d, 1, &priv->gl_render);
+ priv->vt.DXUnregisterObjectNV(priv->gl_handle_d3d, priv->gl_render);
+ priv->gl_render = NULL;
+ }
+}
+
static void
GLConvClose(struct vlc_gl_interop *interop)
{
@@ -187,12 +200,6 @@ GLConvClose(struct vlc_gl_interop *interop)
if (priv->gl_handle_d3d)
{
- if (priv->gl_render)
- {
- priv->vt.DXUnlockObjectsNV(priv->gl_handle_d3d, 1,
&priv->gl_render);
- priv->vt.DXUnregisterObjectNV(priv->gl_handle_d3d,
priv->gl_render);
- }
-
priv->vt.DXCloseDeviceNV(priv->gl_handle_d3d);
}
if (priv->processor.proc)
@@ -516,6 +523,7 @@ GLConvOpen(struct vlc_gl_interop *interop)
static const struct vlc_gl_interop_ops ops = {
.allocate_textures = GLConvAllocateTextures,
+ .deallocate_textures = GLConvDeallocateTextures,
.update_textures = GLConvUpdate,
.close = GLConvClose,
};
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/03507dbd8ffff9fef4dd9e25988adcff6804d88e...580f0b44836672ebae54163d5db0fbf97ec4891a
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/03507dbd8ffff9fef4dd9e25988adcff6804d88e...580f0b44836672ebae54163d5db0fbf97ec4891a
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits