[vlc-commits] opengl: fetch locations from sampler
Romain Vimont
git at videolan.org
Wed May 20 14:55:48 CEST 2020
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Mon Feb 3 16:45:08 2020 +0100| [6dc6c4b667244fb7e6485107da692ecfd58b897a] | committer: Alexandre Janniaux
opengl: fetch locations from sampler
Fetch locations related to sampler from sampler->pf_fetch_locations.
Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6dc6c4b667244fb7e6485107da692ecfd58b897a
---
modules/video_output/opengl/fragment_shaders.c | 40 ++++++++++++++++++++++++--
modules/video_output/opengl/renderer.c | 16 +----------
2 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index 298837c263..eca4e7bfcd 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -218,13 +218,31 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
return VLC_EGENERIC;
}
+ sampler->uloc.TransformMatrix =
+ vt->GetUniformLocation(program, "TransformMatrix");
+ if (sampler->uloc.TransformMatrix == -1)
+ return VLC_EGENERIC;
+
+ sampler->uloc.OrientationMatrix =
+ vt->GetUniformLocation(program, "OrientationMatrix");
+ if (sampler->uloc.OrientationMatrix == -1)
+ return VLC_EGENERIC;
+
+ assert(interop->tex_count < 10); /* to guarantee variable names length */
for (unsigned int i = 0; i < interop->tex_count; ++i)
{
- char name[sizeof("TextureX")];
+ char name[sizeof("TexCoordsMapX")];
+
snprintf(name, sizeof(name), "Texture%1u", i);
sampler->uloc.Texture[i] = vt->GetUniformLocation(program, name);
if (sampler->uloc.Texture[i] == -1)
return VLC_EGENERIC;
+
+ snprintf(name, sizeof(name), "TexCoordsMap%1u", i);
+ sampler->uloc.TexCoordsMap[i] = vt->GetUniformLocation(program, name);
+ if (sampler->uloc.TexCoordsMap[i] == -1)
+ return VLC_EGENERIC;
+
if (interop->tex_target == GL_TEXTURE_RECTANGLE)
{
snprintf(name, sizeof(name), "TexSize%1u", i);
@@ -314,7 +332,25 @@ sampler_xyz12_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
const opengl_vtable_t *vt = sampler->vt;
sampler->uloc.Texture[0] = vt->GetUniformLocation(program, "Texture0");
- return sampler->uloc.Texture[0] != -1 ? VLC_SUCCESS : VLC_EGENERIC;
+ if (sampler->uloc.Texture[0] == -1)
+ return VLC_EGENERIC;
+
+ sampler->uloc.TransformMatrix =
+ vt->GetUniformLocation(program, "TransformMatrix");
+ if (sampler->uloc.TransformMatrix == -1)
+ return VLC_EGENERIC;
+
+ sampler->uloc.OrientationMatrix =
+ vt->GetUniformLocation(program, "OrientationMatrix");
+ if (sampler->uloc.OrientationMatrix == -1)
+ return VLC_EGENERIC;
+
+ sampler->uloc.TexCoordsMap[0] =
+ vt->GetUniformLocation(program, "TexCoordsMap0");
+ if (sampler->uloc.TexCoordsMap[0] == -1)
+ return VLC_EGENERIC;
+
+ return VLC_SUCCESS;
}
static void
diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index 81655b92ea..5fb4f85104 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -357,24 +357,10 @@ opengl_link_program(struct vlc_gl_renderer *renderer)
GET_ALOC(PicCoordsIn, "PicCoordsIn");
GET_ALOC(VertexPosition, "VertexPosition");
-
-#define GET_SAMPLER_ULOC(x, str) GET_LOC(Uniform, sampler->uloc.x, str)
- GET_SAMPLER_ULOC(TransformMatrix, "TransformMatrix");
- GET_SAMPLER_ULOC(OrientationMatrix, "OrientationMatrix");
- GET_SAMPLER_ULOC(TexCoordsMap[0], "TexCoordsMap0");
- /* MultiTexCoord 1 and 2 can be optimized out if not used */
- if (interop->tex_count > 1)
- GET_SAMPLER_ULOC(TexCoordsMap[1], "TexCoordsMap1");
- else
- sampler->uloc.TexCoordsMap[1] = -1;
- if (interop->tex_count > 2)
- GET_SAMPLER_ULOC(TexCoordsMap[2], "TexCoordsMap2");
- else
- sampler->uloc.TexCoordsMap[2] = -1;
#undef GET_LOC
#undef GET_ULOC
#undef GET_ALOC
-#undef GET_SAMPLER_ULOC
+
int ret = sampler->pf_fetch_locations(sampler, program_id);
assert(ret == VLC_SUCCESS);
if (ret != VLC_SUCCESS)
More information about the vlc-commits
mailing list