[vlc-commits] opengl: make FetchLocations() infaillible
Romain Vimont
git at videolan.org
Mon Jun 15 17:39:06 CEST 2020
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Jun 4 11:52:13 2020 +0200| [4d6c5827df7b748575acbe288363b80f09e4eac1] | committer: Alexandre Janniaux
opengl: make FetchLocations() infaillible
If GetUniformLocation() returns -1, then this is an implementation
error.
Assert instead of reporting the error to the caller.
Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4d6c5827df7b748575acbe288363b80f09e4eac1
---
modules/video_output/opengl/renderer.c | 8 +------
modules/video_output/opengl/sampler.c | 38 +++++++++++-----------------------
modules/video_output/opengl/sampler.h | 7 +++----
3 files changed, 16 insertions(+), 37 deletions(-)
diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index c98d2f4b76..0f6a7ba73f 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -281,13 +281,7 @@ opengl_link_program(struct vlc_gl_renderer *renderer)
#undef GET_ULOC
#undef GET_ALOC
- int ret = vlc_gl_sampler_FetchLocations(sampler, program_id);
- assert(ret == VLC_SUCCESS);
- if (ret != VLC_SUCCESS)
- {
- msg_Err(renderer->gl, "Unable to get locations from tex_conv");
- goto error;
- }
+ vlc_gl_sampler_FetchLocations(sampler, program_id);
renderer->program_id = program_id;
diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c
index 1028c5103a..e7e4d0b49e 100644
--- a/modules/video_output/opengl/sampler.c
+++ b/modules/video_output/opengl/sampler.c
@@ -252,7 +252,7 @@ sampler_yuv_base_init(struct vlc_gl_sampler *sampler, vlc_fourcc_t chroma,
return VLC_SUCCESS;
}
-static int
+static void
sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
{
struct vlc_gl_sampler_priv *priv = PRIV(sampler);
@@ -263,19 +263,16 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
if (priv->yuv_color)
{
priv->uloc.ConvMatrix = vt->GetUniformLocation(program, "ConvMatrix");
- if (priv->uloc.ConvMatrix == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.ConvMatrix != -1);
}
priv->uloc.TransformMatrix =
vt->GetUniformLocation(program, "TransformMatrix");
- if (priv->uloc.TransformMatrix == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.TransformMatrix != -1);
priv->uloc.OrientationMatrix =
vt->GetUniformLocation(program, "OrientationMatrix");
- if (priv->uloc.OrientationMatrix == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.OrientationMatrix != -1);
assert(interop->tex_count < 10); /* to guarantee variable names length */
for (unsigned int i = 0; i < interop->tex_count; ++i)
@@ -284,20 +281,17 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
snprintf(name, sizeof(name), "Texture%1u", i);
priv->uloc.Texture[i] = vt->GetUniformLocation(program, name);
- if (priv->uloc.Texture[i] == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.Texture[i] != -1);
snprintf(name, sizeof(name), "TexCoordsMap%1u", i);
priv->uloc.TexCoordsMap[i] = vt->GetUniformLocation(program, name);
- if (priv->uloc.TexCoordsMap[i] == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.TexCoordsMap[i] != -1);
if (interop->tex_target == GL_TEXTURE_RECTANGLE)
{
snprintf(name, sizeof(name), "TexSize%1u", i);
priv->uloc.TexSize[i] = vt->GetUniformLocation(program, name);
- if (priv->uloc.TexSize[i] == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.TexSize[i] != -1);
}
}
@@ -308,8 +302,6 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
priv->uloc.pl_vars[i] = vt->GetUniformLocation(program, sv.var.name);
}
#endif
-
- return VLC_SUCCESS;
}
static const GLfloat *
@@ -394,32 +386,26 @@ sampler_base_prepare_shader(const struct vlc_gl_sampler *sampler)
#endif
}
-static int
+static void
sampler_xyz12_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
{
struct vlc_gl_sampler_priv *priv = PRIV(sampler);
const opengl_vtable_t *vt = priv->vt;
priv->uloc.Texture[0] = vt->GetUniformLocation(program, "Texture0");
- if (priv->uloc.Texture[0] == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.Texture[0] != -1);
priv->uloc.TransformMatrix =
vt->GetUniformLocation(program, "TransformMatrix");
- if (priv->uloc.TransformMatrix == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.TransformMatrix != -1);
priv->uloc.OrientationMatrix =
vt->GetUniformLocation(program, "OrientationMatrix");
- if (priv->uloc.OrientationMatrix == -1)
- return VLC_EGENERIC;
+ assert(priv->uloc.OrientationMatrix != -1);
priv->uloc.TexCoordsMap[0] =
vt->GetUniformLocation(program, "TexCoordsMap0");
- if (priv->uloc.TexCoordsMap[0] == -1)
- return VLC_EGENERIC;
-
- return VLC_SUCCESS;
+ assert(priv->uloc.TexCoordsMap[0] != -1);
}
static void
diff --git a/modules/video_output/opengl/sampler.h b/modules/video_output/opengl/sampler.h
index 4b0c305c4e..f26820bfab 100644
--- a/modules/video_output/opengl/sampler.h
+++ b/modules/video_output/opengl/sampler.h
@@ -85,9 +85,8 @@ struct vlc_gl_sampler {
*
* \param sampler the sampler
* \param program linked program that will be used by this sampler
- * \return VLC_SUCCESS or a VLC error
*/
- int (*pf_fetch_locations)(struct vlc_gl_sampler *sampler, GLuint program);
+ void (*pf_fetch_locations)(struct vlc_gl_sampler *sampler, GLuint program);
/**
* Callback to prepare the fragment shader
@@ -100,10 +99,10 @@ struct vlc_gl_sampler {
void (*pf_prepare_shader)(const struct vlc_gl_sampler *sampler);
};
-static inline int
+static inline void
vlc_gl_sampler_FetchLocations(struct vlc_gl_sampler *sampler, GLuint program)
{
- return sampler->pf_fetch_locations(sampler, program);
+ sampler->pf_fetch_locations(sampler, program);
}
static inline void
More information about the vlc-commits
mailing list