[vlc-commits] opengl: remove tex converter usages
Romain Vimont
git at videolan.org
Mon Jan 13 11:44:11 CET 2020
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Fri Dec 6 17:16:42 2019 +0100| [c805b3dfc4a754f18814953b1291476f41fc892f] | committer: Thomas Guillem
opengl: remove tex converter usages
Use interop instance directly where possible.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c805b3dfc4a754f18814953b1291476f41fc892f
---
modules/video_output/opengl/converter_sw.c | 47 +++++++++++++-------------
modules/video_output/opengl/converter_vaapi.c | 12 +++----
modules/video_output/opengl/fragment_shaders.c | 20 +++++------
modules/video_output/opengl/vout_helper.c | 37 ++++++++++----------
4 files changed, 55 insertions(+), 61 deletions(-)
diff --git a/modules/video_output/opengl/converter_sw.c b/modules/video_output/opengl/converter_sw.c
index 2b6b9612bb..5c59a53bfa 100644
--- a/modules/video_output/opengl/converter_sw.c
+++ b/modules/video_output/opengl/converter_sw.c
@@ -70,10 +70,8 @@ pbo_picture_destroy(picture_t *pic)
}
static picture_t *
-pbo_picture_create(const opengl_tex_converter_t *tc)
+pbo_picture_create(const struct vlc_gl_interop *interop)
{
- const struct vlc_gl_interop *interop = &tc->interop;
-
picture_sys_t *picsys = calloc(1, sizeof(*picsys));
if (unlikely(picsys == NULL))
return NULL;
@@ -89,8 +87,8 @@ pbo_picture_create(const opengl_tex_converter_t *tc)
return NULL;
}
- tc->vt->GenBuffers(pic->i_planes, picsys->buffers);
- picsys->DeleteBuffers = tc->vt->DeleteBuffers;
+ interop->vt->GenBuffers(pic->i_planes, picsys->buffers);
+ picsys->DeleteBuffers = interop->vt->DeleteBuffers;
/* XXX: needed since picture_NewFromResource override pic planes */
if (picture_Setup(pic, &interop->fmt))
@@ -118,22 +116,22 @@ pbo_picture_create(const opengl_tex_converter_t *tc)
}
static int
-pbo_data_alloc(const opengl_tex_converter_t *tc, picture_t *pic)
+pbo_data_alloc(const struct vlc_gl_interop *interop, picture_t *pic)
{
picture_sys_t *picsys = pic->p_sys;
- tc->vt->GetError();
+ interop->vt->GetError();
for (int i = 0; i < pic->i_planes; ++i)
{
- tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
- tc->vt->BufferData(GL_PIXEL_UNPACK_BUFFER, picsys->bytes[i], NULL,
- GL_DYNAMIC_DRAW);
+ interop->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
+ interop->vt->BufferData(GL_PIXEL_UNPACK_BUFFER, picsys->bytes[i], NULL,
+ GL_DYNAMIC_DRAW);
- if (tc->vt->GetError() != GL_NO_ERROR)
+ if (interop->vt->GetError() != GL_NO_ERROR)
{
- msg_Err(tc->gl, "could not alloc PBO buffers");
- tc->vt->DeleteBuffers(i, picsys->buffers);
+ msg_Err(interop->gl, "could not alloc PBO buffers");
+ interop->vt->DeleteBuffers(i, picsys->buffers);
return VLC_EGENERIC;
}
}
@@ -141,21 +139,22 @@ pbo_data_alloc(const opengl_tex_converter_t *tc, picture_t *pic)
}
static int
-pbo_pics_alloc(const opengl_tex_converter_t *tc)
+pbo_pics_alloc(const struct vlc_gl_interop *interop)
{
- struct priv *priv = tc->interop.priv;
+ struct priv *priv = interop->priv;
for (size_t i = 0; i < PBO_DISPLAY_COUNT; ++i)
{
- picture_t *pic = priv->pbo.display_pics[i] = pbo_picture_create(tc);
+ picture_t *pic = priv->pbo.display_pics[i] =
+ pbo_picture_create(interop);
if (pic == NULL)
goto error;
- if (pbo_data_alloc(tc, pic) != VLC_SUCCESS)
+ if (pbo_data_alloc(interop, pic) != VLC_SUCCESS)
goto error;
}
/* turn off pbo */
- tc->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+ interop->vt->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
return VLC_SUCCESS;
error:
@@ -308,7 +307,7 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
if (vlc_fourcc_IsYUV(interop->fmt.i_chroma))
{
GLint max_texture_units = 0;
- tc->vt->GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
+ interop->vt->GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
if (max_texture_units < 3)
return VLC_EGENERIC;
@@ -358,7 +357,7 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
struct priv *priv = interop->priv = calloc(1, sizeof(struct priv));
if (unlikely(priv == NULL))
{
- tc->vt->DeleteShader(fragment_shader);
+ interop->vt->DeleteShader(fragment_shader);
return VLC_ENOMEM;
}
@@ -375,16 +374,16 @@ opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool allow_dr)
if (allow_dr && priv->has_unpack_subimage)
{
/* Ensure we do direct rendering / PBO with OpenGL 3.0 or higher. */
- const unsigned char *ogl_version = tc->vt->GetString(GL_VERSION);
+ const unsigned char *ogl_version = interop->vt->GetString(GL_VERSION);
const bool glver_ok = strverscmp((const char *)ogl_version, "3.0") >= 0;
const bool has_pbo = glver_ok &&
(vlc_gl_StrHasToken(interop->glexts, "GL_ARB_pixel_buffer_object") ||
vlc_gl_StrHasToken(interop->glexts, "GL_EXT_pixel_buffer_object"));
- const bool supports_pbo = has_pbo && tc->vt->BufferData
- && tc->vt->BufferSubData;
- if (supports_pbo && pbo_pics_alloc(tc) == VLC_SUCCESS)
+ const bool supports_pbo = has_pbo && interop->vt->BufferData
+ && interop->vt->BufferSubData;
+ if (supports_pbo && pbo_pics_alloc(interop) == VLC_SUCCESS)
{
static const struct vlc_gl_interop_ops pbo_ops = {
.allocate_textures = tc_common_allocate_textures,
diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/video_output/opengl/converter_vaapi.c
index ab07b4a73d..e33e882aee 100644
--- a/modules/video_output/opengl/converter_vaapi.c
+++ b/modules/video_output/opengl/converter_vaapi.c
@@ -101,10 +101,8 @@ vaegl_release_last_pic(const struct vlc_gl_interop *interop, struct priv *priv)
}
static int
-vaegl_init_fourcc(const opengl_tex_converter_t *tc, struct priv *priv,
- unsigned va_fourcc)
+vaegl_init_fourcc(struct priv *priv, unsigned va_fourcc)
{
- (void) tc;
switch (va_fourcc)
{
case VA_FOURCC_NV12:
@@ -245,7 +243,7 @@ static int strcasecmp_void(const void *a, const void *b)
}
static int
-tc_va_check_interop_blacklist(opengl_tex_converter_t *tc, VADisplay *vadpy)
+tc_va_check_interop_blacklist(const struct vlc_gl_interop *interop, VADisplay *vadpy)
{
const char *vendor = vaQueryVendorString(vadpy);
if (vendor == NULL)
@@ -266,7 +264,7 @@ tc_va_check_interop_blacklist(opengl_tex_converter_t *tc, VADisplay *vadpy)
BL_SIZE_MAX, strcasecmp_void);
if (found != NULL)
{
- msg_Warn(tc->gl, "The '%s' driver is blacklisted: no interop", found);
+ msg_Warn(interop->gl, "The '%s' driver is blacklisted: no interop", found);
return VLC_EGENERIC;
}
@@ -390,7 +388,7 @@ Open(vlc_object_t *obj)
vlc_assert_unreachable();
}
- if (vaegl_init_fourcc(tc, priv, va_fourcc))
+ if (vaegl_init_fourcc(priv, va_fourcc))
goto error;
priv->glEGLImageTargetTexture2DOES =
@@ -401,7 +399,7 @@ Open(vlc_object_t *obj)
priv->vadpy = dec_device->opaque;
assert(priv->vadpy != NULL);
- if (tc_va_check_interop_blacklist(tc, priv->vadpy))
+ if (tc_va_check_interop_blacklist(interop, priv->vadpy))
goto error;
if (tc_va_check_derive_image(interop))
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index 1d5b455416..7edf4d2f74 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -62,10 +62,10 @@
# define GL_TEXTURE_LUMINANCE_SIZE 0x8060
#endif
-static int GetTexFormatSize(opengl_tex_converter_t *tc, int target,
+static int GetTexFormatSize(const opengl_vtable_t *vt, int target,
int tex_format, int tex_internal, int tex_type)
{
- if (!tc->vt->GetTexLevelParameteriv)
+ if (!vt->GetTexLevelParameteriv)
return -1;
GLint tex_param_size;
@@ -87,13 +87,13 @@ static int GetTexFormatSize(opengl_tex_converter_t *tc, int target,
}
GLuint texture;
- tc->vt->GenTextures(1, &texture);
- tc->vt->BindTexture(target, texture);
- tc->vt->TexImage2D(target, 0, tex_internal, 64, 64, 0, tex_format, tex_type, NULL);
+ vt->GenTextures(1, &texture);
+ vt->BindTexture(target, texture);
+ vt->TexImage2D(target, 0, tex_internal, 64, 64, 0, tex_format, tex_type, NULL);
GLint size = 0;
- tc->vt->GetTexLevelParameteriv(target, 0, tex_param_size, &size);
+ vt->GetTexLevelParameteriv(target, 0, tex_param_size, &size);
- tc->vt->DeleteTextures(1, &texture);
+ vt->DeleteTextures(1, &texture);
return size > 0 ? size * mul : size;
}
@@ -126,7 +126,7 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
float yuv_range_correction = 1.0;
if (desc->pixel_size == 2)
{
- if (GetTexFormatSize(tc, tex_target, oneplane_texfmt,
+ if (GetTexFormatSize(tc->vt, tex_target, oneplane_texfmt,
oneplane16_texfmt, GL_UNSIGNED_SHORT) != 16)
return VLC_EGENERIC;
@@ -187,7 +187,7 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
else if (desc->pixel_size == 2)
{
if (twoplanes16_texfmt == 0
- || GetTexFormatSize(tc, tex_target, twoplanes_texfmt,
+ || GetTexFormatSize(tc->vt, tex_target, twoplanes_texfmt,
twoplanes16_texfmt, GL_UNSIGNED_SHORT) != 16)
return VLC_EGENERIC;
interop->texs[0] = (struct vlc_gl_tex_cfg) {
@@ -316,7 +316,7 @@ tc_rgb_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
};
break;
case VLC_CODEC_BGRA: {
- if (GetTexFormatSize(tc, tex_target, GL_BGRA, GL_RGBA,
+ if (GetTexFormatSize(tc->vt, tex_target, GL_BGRA, GL_RGBA,
GL_UNSIGNED_BYTE) != 32)
return VLC_EGENERIC;
interop->texs[0] = (struct vlc_gl_tex_cfg) {
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 0bac994067..9b5e807d8c 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -353,36 +353,34 @@ static GLuint BuildVertexShader(const opengl_tex_converter_t *tc,
}
static int
-GenTextures(const opengl_tex_converter_t *tc,
+GenTextures(const struct vlc_gl_interop *interop,
const GLsizei *tex_width, const GLsizei *tex_height,
GLuint *textures)
{
- const struct vlc_gl_interop *interop = &tc->interop;
-
- tc->vt->GenTextures(interop->tex_count, textures);
+ interop->vt->GenTextures(interop->tex_count, textures);
for (unsigned i = 0; i < interop->tex_count; i++)
{
- tc->vt->BindTexture(interop->tex_target, textures[i]);
+ interop->vt->BindTexture(interop->tex_target, textures[i]);
#if !defined(USE_OPENGL_ES2)
/* Set the texture parameters */
- tc->vt->TexParameterf(interop->tex_target, GL_TEXTURE_PRIORITY, 1.0);
- tc->vt->TexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ interop->vt->TexParameterf(interop->tex_target, GL_TEXTURE_PRIORITY, 1.0);
+ interop->vt->TexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#endif
- tc->vt->TexParameteri(interop->tex_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- tc->vt->TexParameteri(interop->tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- tc->vt->TexParameteri(interop->tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- tc->vt->TexParameteri(interop->tex_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ interop->vt->TexParameteri(interop->tex_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ interop->vt->TexParameteri(interop->tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ interop->vt->TexParameteri(interop->tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ interop->vt->TexParameteri(interop->tex_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
if (interop->ops->allocate_textures != NULL)
{
- int ret = interop->ops->allocate_textures(&tc->interop, textures, tex_width, tex_height);
+ int ret = interop->ops->allocate_textures(interop, textures, tex_width, tex_height);
if (ret != VLC_SUCCESS)
{
- tc->vt->DeleteTextures(interop->tex_count, textures);
+ interop->vt->DeleteTextures(interop->tex_count, textures);
memset(textures, 0, interop->tex_count * sizeof(GLuint));
return ret;
}
@@ -391,10 +389,9 @@ GenTextures(const opengl_tex_converter_t *tc,
}
static void
-DelTextures(const opengl_tex_converter_t *tc, GLuint *textures)
+DelTextures(const struct vlc_gl_interop *interop, GLuint *textures)
{
- const struct vlc_gl_interop *interop = &tc->interop;
- tc->vt->DeleteTextures(interop->tex_count, textures);
+ interop->vt->DeleteTextures(interop->tex_count, textures);
memset(textures, 0, interop->tex_count * sizeof(GLuint));
}
@@ -881,7 +878,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
if (!interop->handle_texs_gen)
{
- ret = GenTextures(vgl->prgm->tc, vgl->tex_width, vgl->tex_height,
+ ret = GenTextures(&vgl->prgm->tc->interop, vgl->tex_width, vgl->tex_height,
vgl->texture);
if (ret != VLC_SUCCESS)
{
@@ -1052,7 +1049,7 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
GL_ASSERT_NOERROR();
opengl_tex_converter_t *tc = vgl->prgm->tc;
- struct vlc_gl_interop *interop = &tc->interop;
+ const struct vlc_gl_interop *interop = &tc->interop;
/* Update the texture */
int ret = interop->ops->update_textures(interop, vgl->texture, vgl->tex_width, vgl->tex_height,
@@ -1118,7 +1115,7 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
if (!glr->texture)
{
/* Could not recycle a previous texture, generate a new one. */
- ret = GenTextures(tc, &glr->width, &glr->height, &glr->texture);
+ ret = GenTextures(interop, &glr->width, &glr->height, &glr->texture);
if (ret != VLC_SUCCESS)
continue;
}
@@ -1132,7 +1129,7 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
}
for (int i = 0; i < last_count; i++) {
if (last[i].texture)
- DelTextures(tc, &last[i].texture);
+ DelTextures(interop, &last[i].texture);
}
free(last);
More information about the vlc-commits
mailing list