[vlc-devel] [PATCH 24/41] opengl: fetch locations from sampler
Romain Vimont
rom1v at videolabs.io
Fri Feb 7 17:42:10 CET 2020
Fetch locations related to sampler from sampler->pf_fetch_locations.
---
.../video_output/opengl/fragment_shaders.c | 19 ++++++++++++++++++-
modules/video_output/opengl/renderer.c | 16 +---------------
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index fdabf3d49d..75ea33f02c 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -218,13 +218,30 @@ 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;
+
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);
diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index fc46fccaaf..df173bf817 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)
--
2.25.0
More information about the vlc-devel
mailing list