[vlc-devel] [PATCH 25/41] opengl: load uniforms from sampler

Romain Vimont rom1v at videolabs.io
Fri Feb 7 17:42:11 CET 2020


Load uniforms related to sampler from sampler->pf_prepare_shader.
---
 .../video_output/opengl/fragment_shaders.c    | 21 +++++++++++++++++++
 modules/video_output/opengl/renderer.c        | 20 ------------------
 2 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index 75ea33f02c..e7eaeb987b 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -33,6 +33,8 @@
 
 #include <vlc_common.h>
 #include <vlc_memstream.h>
+
+#include "gl_util.h"
 #include "interop.h"
 #include "internal.h"
 #include "sampler.h"
@@ -280,10 +282,29 @@ sampler_base_prepare_shader(const struct vlc_gl_sampler *sampler,
                              sampler->conv_matrix);
 
     for (unsigned i = 0; i < interop->tex_count; ++i)
+    {
         vt->Uniform1i(sampler->uloc.Texture[i], i);
 
+        assert(sampler->textures[i] != 0);
+        vt->ActiveTexture(GL_TEXTURE0 + i);
+        vt->BindTexture(interop->tex_target, sampler->textures[i]);
+
+        vt->UniformMatrix3fv(sampler->uloc.TexCoordsMap[i], 1, GL_FALSE,
+                             sampler->var.TexCoordsMap[i]);
+    }
+
     vt->Uniform4f(sampler->uloc.FillColor, 1.0f, 1.0f, 1.0f, alpha);
 
+    const GLfloat *tm = NULL;
+    if (interop->ops && interop->ops->get_transform_matrix)
+        tm = interop->ops->get_transform_matrix(interop);
+    if (!tm)
+        tm = MATRIX4_IDENTITY;
+    vt->UniformMatrix4fv(sampler->uloc.TransformMatrix, 1, GL_FALSE, tm);
+
+    vt->UniformMatrix4fv(sampler->uloc.OrientationMatrix, 1, GL_FALSE,
+                         sampler->var.OrientationMatrix);
+
     if (interop->tex_target == GL_TEXTURE_RECTANGLE)
     {
         for (unsigned i = 0; i < interop->tex_count; ++i)
diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index df173bf817..19d7289508 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -832,21 +832,11 @@ static int SetupCoords(struct vlc_gl_renderer *renderer)
 
 static void DrawWithShaders(struct vlc_gl_renderer *renderer)
 {
-    const struct vlc_gl_interop *interop = renderer->interop;
     struct vlc_gl_sampler *sampler = renderer->sampler;
     const opengl_vtable_t *vt = renderer->vt;
     sampler->pf_prepare_shader(sampler, sampler->tex_width,
                                sampler->tex_height, 1.0f);
 
-    for (unsigned j = 0; j < interop->tex_count; j++) {
-        assert(sampler->textures[j] != 0);
-        vt->ActiveTexture(GL_TEXTURE0+j);
-        vt->BindTexture(interop->tex_target, sampler->textures[j]);
-
-        vt->UniformMatrix3fv(sampler->uloc.TexCoordsMap[j], 1, GL_FALSE,
-                             sampler->var.TexCoordsMap[j]);
-    }
-
     vt->BindBuffer(GL_ARRAY_BUFFER, renderer->texture_buffer_object);
     assert(renderer->aloc.PicCoordsIn != -1);
     vt->EnableVertexAttribArray(renderer->aloc.PicCoordsIn);
@@ -857,16 +847,6 @@ static void DrawWithShaders(struct vlc_gl_renderer *renderer)
     vt->EnableVertexAttribArray(renderer->aloc.VertexPosition);
     vt->VertexAttribPointer(renderer->aloc.VertexPosition, 3, GL_FLOAT, 0, 0, 0);
 
-    const GLfloat *tm = NULL;
-    if (interop->ops && interop->ops->get_transform_matrix)
-        tm = interop->ops->get_transform_matrix(interop);
-    if (!tm)
-        tm = MATRIX4_IDENTITY;
-
-    vt->UniformMatrix4fv(sampler->uloc.TransformMatrix, 1, GL_FALSE, tm);
-
-    vt->UniformMatrix4fv(sampler->uloc.OrientationMatrix, 1, GL_FALSE,
-                         sampler->var.OrientationMatrix);
     vt->UniformMatrix3fv(renderer->uloc.StereoMatrix, 1, GL_FALSE,
                          renderer->var.StereoMatrix);
     vt->UniformMatrix4fv(renderer->uloc.ProjectionMatrix, 1, GL_FALSE,
-- 
2.25.0



More information about the vlc-devel mailing list