[vlc-commits] opengl: move sampler ownership to vgl
Romain Vimont
git at videolan.org
Thu Jun 4 11:04:42 CEST 2020
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Feb 6 12:04:05 2020 +0100| [9be98ad93cd3fb4a03343e2f11ae309115176712] | committer: Alexandre Janniaux
opengl: move sampler ownership to vgl
The sampler were owned by the renderer.
Move it to vgl, so that the renderer never have to handle an interop
instance directly.
Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9be98ad93cd3fb4a03343e2f11ae309115176712
---
modules/video_output/opengl/renderer.c | 13 ++-----------
modules/video_output/opengl/renderer.h | 4 ++--
modules/video_output/opengl/vout_helper.c | 17 ++++++++++++++++-
3 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index b6c13ba559..cff178f63c 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -314,8 +314,6 @@ vlc_gl_renderer_Delete(struct vlc_gl_renderer *renderer)
vt->DeleteBuffers(1, &renderer->index_buffer_object);
vt->DeleteBuffers(1, &renderer->texture_buffer_object);
- vlc_gl_sampler_Delete(renderer->sampler);
-
if (renderer->program_id != 0)
vt->DeleteProgram(renderer->program_id);
@@ -326,21 +324,14 @@ static int SetupCoords(struct vlc_gl_renderer *renderer);
struct vlc_gl_renderer *
vlc_gl_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
- struct vlc_gl_interop *interop, bool b_dump_shaders)
+ struct vlc_gl_sampler *sampler, bool b_dump_shaders)
{
const opengl_vtable_t *vt = &api->vt;
- const video_format_t *fmt = &interop->fmt;
-
- struct vlc_gl_sampler *sampler = vlc_gl_sampler_New(interop);
- if (!sampler)
- return NULL;
+ const video_format_t *fmt = sampler->fmt;
struct vlc_gl_renderer *renderer = calloc(1, sizeof(*renderer));
if (!renderer)
- {
- free(sampler);
return NULL;
- }
renderer->sampler = sampler;
diff --git a/modules/video_output/opengl/renderer.h b/modules/video_output/opengl/renderer.h
index 23017a5428..d17e5299dd 100644
--- a/modules/video_output/opengl/renderer.h
+++ b/modules/video_output/opengl/renderer.h
@@ -102,12 +102,12 @@ struct vlc_gl_renderer
*
* \param gl the GL context
* \param api the OpenGL API
- * \param interop the interop
+ * \param sampler the OpenGL sampler
* \param dump_shaders indicate if the shaders must be dumped in logs
*/
struct vlc_gl_renderer *
vlc_gl_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
- struct vlc_gl_interop *interop, bool dump_shaders);
+ struct vlc_gl_sampler *sampler, bool dump_shaders);
/**
* Delete a renderer
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index c34cf20dc0..e2bb9e0f45 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -44,6 +44,7 @@
#include "vout_helper.h"
#include "internal.h"
#include "renderer.h"
+#include "sampler.h"
#include "sub_renderer.h"
struct vout_display_opengl_t {
@@ -52,6 +53,7 @@ struct vout_display_opengl_t {
struct vlc_gl_api api;
struct vlc_gl_interop *interop;
+ struct vlc_gl_sampler *sampler;
struct vlc_gl_renderer *renderer;
struct vlc_gl_interop *sub_interop;
@@ -143,12 +145,22 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
return NULL;
}
+ vgl->sampler = vlc_gl_sampler_New(vgl->interop);
+ if (!vgl->sampler)
+ {
+ msg_Err(gl, "Could not create sampler");
+ vlc_gl_interop_Delete(vgl->interop);
+ free(vgl);
+ return NULL;
+ }
+
vgl->renderer =
- vlc_gl_renderer_New(gl, &vgl->api, vgl->interop, b_dump_shaders);
+ vlc_gl_renderer_New(gl, &vgl->api, vgl->sampler, b_dump_shaders);
if (!vgl->renderer)
{
msg_Warn(gl, "Could not create renderer for %4.4s",
(const char *) &fmt->i_chroma);
+ vlc_gl_sampler_Delete(vgl->sampler);
vlc_gl_interop_Delete(vgl->interop);
free(vgl);
return NULL;
@@ -161,6 +173,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
{
msg_Err(gl, "Could not create sub interop");
vlc_gl_renderer_Delete(vgl->renderer);
+ vlc_gl_sampler_Delete(vgl->sampler);
vlc_gl_interop_Delete(vgl->interop);
free(vgl);
return NULL;
@@ -173,6 +186,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
msg_Err(gl, "Could not create sub renderer");
vlc_gl_interop_Delete(vgl->sub_interop);
vlc_gl_renderer_Delete(vgl->renderer);
+ vlc_gl_sampler_Delete(vgl->sampler);
vlc_gl_interop_Delete(vgl->interop);
free(vgl);
return NULL;
@@ -215,6 +229,7 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
vlc_gl_interop_Delete(vgl->sub_interop);
vlc_gl_renderer_Delete(vgl->renderer);
+ vlc_gl_sampler_Delete(vgl->sampler);
vlc_gl_interop_Delete(vgl->interop);
GL_ASSERT_NOERROR(vt);
More information about the vlc-commits
mailing list