Commit 736be666 authored by Romain Vimont's avatar Romain Vimont
Browse files

opengl: move interop ownership to vgl

The interop instances were owned by the renderers.

To prepare for making the renderers independant of the input picture
(in particular, independant of the interop), make the vgl own the
interop instances.
parent bc009f91
......@@ -415,7 +415,6 @@ vlc_gl_renderer_Delete(struct vlc_gl_renderer *renderer)
if (!interop->handle_texs_gen)
vt->DeleteTextures(interop->tex_count, sampler->textures);
vlc_gl_interop_Delete(interop);
if (renderer->program_id != 0)
vt->DeleteProgram(renderer->program_id);
......@@ -433,8 +432,8 @@ 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,
vlc_video_context *context, const video_format_t *fmt,
bool b_dump_shaders)
struct vlc_gl_interop *interop,
const video_format_t *fmt, bool b_dump_shaders)
{
const opengl_vtable_t *vt = &api->vt;
......@@ -450,16 +449,6 @@ vlc_gl_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
}
renderer->sampler = sampler;
struct vlc_gl_interop *interop =
vlc_gl_interop_New(gl, api, context, fmt, false);
if (!interop)
{
free(renderer);
free(sampler);
return NULL;
}
renderer->interop = interop;
renderer->gl = gl;
......
......@@ -130,13 +130,13 @@ struct vlc_gl_renderer
*
* \param gl the GL context
* \param api the OpenGL API
* \param context the video context
* \param interop the interop
* \param fmt the video format
* \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,
vlc_video_context *context, const video_format_t *fmt,
struct vlc_gl_interop *interop, const video_format_t *fmt,
bool dump_shaders);
/**
......
......@@ -112,7 +112,8 @@ FetchLocations(struct vlc_gl_sub_renderer *sr)
}
struct vlc_gl_sub_renderer *
vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api)
vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
struct vlc_gl_interop *interop)
{
const opengl_vtable_t *vt = &api->vt;
......@@ -122,13 +123,11 @@ vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api)
video_format_t fmt;
video_format_Init(&fmt, VLC_CODEC_RGB32);
sr->interop = vlc_gl_interop_New(gl, api, NULL, &fmt, true);
if (!sr->interop)
goto error_1;
/* Allocates our textures */
assert(!sr->interop->handle_texs_gen);
assert(!interop->handle_texs_gen);
sr->interop = interop;
sr->gl = gl;
sr->api = api;
sr->vt = vt;
......@@ -170,17 +169,17 @@ vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api)
1, (const char **) &VERTEX_SHADER_SRC,
1, (const char **) &FRAGMENT_SHADER_SRC);
if (!sr->program_id)
goto error_2;
goto error_1;
int ret = FetchLocations(sr);
if (ret != VLC_SUCCESS)
goto error_3;
goto error_2;
/* Initial number of allocated buffer objects for subpictures, will grow dynamically. */
static const unsigned INITIAL_BUFFER_OBJECT_COUNT = 8;
sr->buffer_objects = vlc_alloc(INITIAL_BUFFER_OBJECT_COUNT, sizeof(GLuint));
if (!sr->buffer_objects)
goto error_3;
goto error_2;
sr->buffer_object_count = INITIAL_BUFFER_OBJECT_COUNT;
......@@ -188,10 +187,8 @@ vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api)
return sr;
error_3:
vt->DeleteProgram(sr->program_id);
error_2:
vlc_object_delete(sr->interop);
vt->DeleteProgram(sr->program_id);
error_1:
free(sr);
......@@ -212,8 +209,6 @@ vlc_gl_sub_renderer_Delete(struct vlc_gl_sub_renderer *sr)
}
free(sr->regions);
vlc_gl_interop_Delete(sr->interop);
free(sr);
}
......
......@@ -30,6 +30,7 @@
#include "gl_api.h"
#include "gl_common.h"
#include "interop.h"
/**
* A subpictures renderer handles the rendering of RGB subpictures.
......@@ -45,7 +46,8 @@ struct vlc_gl_sub_renderer;
* texture size
*/
struct vlc_gl_sub_renderer *
vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api);
vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
struct vlc_gl_interop *interop);
/**
* Delete a subpictures renderer
......
......@@ -51,7 +51,10 @@ struct vout_display_opengl_t {
vlc_gl_t *gl;
struct vlc_gl_api api;
struct vlc_gl_interop *interop;
struct vlc_gl_renderer *renderer;
struct vlc_gl_interop *sub_interop;
struct vlc_gl_sub_renderer *sub_renderer;
};
......@@ -132,23 +135,45 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
bool b_dump_shaders = var_InheritInteger(gl, "verbose") >= 4;
vgl->interop = vlc_gl_interop_New(gl, &vgl->api, context, fmt, false);
if (!vgl->interop)
{
msg_Err(gl, "Could not create interop");
free(vgl);
return NULL;
}
struct vlc_gl_renderer *renderer = vgl->renderer =
vlc_gl_renderer_New(gl, &vgl->api, context, fmt, b_dump_shaders);
vlc_gl_renderer_New(gl, &vgl->api, vgl->interop, fmt, b_dump_shaders);
if (!vgl->renderer)
{
msg_Warn(gl, "Could not create renderer for %4.4s",
(const char *) &fmt->i_chroma);
vlc_gl_interop_Delete(vgl->interop);
free(vgl);
return NULL;
}
GL_ASSERT_NOERROR(vt);
vgl->sub_renderer = vlc_gl_sub_renderer_New(gl, &vgl->api);
vgl->sub_interop = vlc_gl_interop_New(gl, &vgl->api, NULL, fmt, true);
if (!vgl->sub_interop)
{
msg_Err(gl, "Could not create sub interop");
vlc_gl_renderer_Delete(vgl->renderer);
vlc_gl_interop_Delete(vgl->interop);
free(vgl);
return NULL;
}
vgl->sub_renderer =
vlc_gl_sub_renderer_New(gl, &vgl->api, vgl->sub_interop);
if (!vgl->sub_renderer)
{
msg_Err(gl, "Could not create sub renderer");
vlc_gl_interop_Delete(vgl->sub_interop);
vlc_gl_renderer_Delete(vgl->renderer);
vlc_gl_interop_Delete(vgl->interop);
free(vgl);
return NULL;
}
......@@ -182,7 +207,10 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl)
vt->Flush();
vlc_gl_sub_renderer_Delete(vgl->sub_renderer);
vlc_gl_interop_Delete(vgl->sub_interop);
vlc_gl_renderer_Delete(vgl->renderer);
vlc_gl_interop_Delete(vgl->interop);
GL_ASSERT_NOERROR(vt);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment