[vlc-commits] opengl: extract sampler and texture lookup names

Romain Vimont git at videolan.org
Mon Apr 12 15:28:42 UTC 2021


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Tue Mar 30 13:14:05 2021 +0200| [25979d17b42df49fdcd619a2545fa0d66084d881] | committer: Alexandre Janniaux

opengl: extract sampler and texture lookup names

The type and function to use depends on the texture target.

Extract the mapping to a separate function to be able to reuse it.

Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=25979d17b42df49fdcd619a2545fa0d66084d881
---

 modules/video_output/opengl/sampler.c | 40 ++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/modules/video_output/opengl/sampler.c b/modules/video_output/opengl/sampler.c
index 4a928690bc..6dea5204a0 100644
--- a/modules/video_output/opengl/sampler.c
+++ b/modules/video_output/opengl/sampler.c
@@ -715,6 +715,28 @@ InitOrientationMatrix(GLfloat matrix[static 4*4],
     }
 }
 
+static void
+GetNames(GLenum tex_target, const char **glsl_sampler, const char **texture)
+{
+    switch (tex_target)
+    {
+        case GL_TEXTURE_EXTERNAL_OES:
+            *glsl_sampler = "samplerExternalOES";
+            *texture = "texture2D";
+            break;
+        case GL_TEXTURE_2D:
+            *glsl_sampler = "sampler2D";
+            *texture = "texture2D";
+            break;
+        case GL_TEXTURE_RECTANGLE:
+            *glsl_sampler = "sampler2DRect";
+            *texture = "texture2DRect";
+            break;
+        default:
+            vlc_assert_unreachable();
+    }
+}
+
 static int
 opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
                             const video_format_t *fmt)
@@ -754,23 +776,7 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
     }
 
     const char *glsl_sampler, *lookup;
-    switch (tex_target)
-    {
-        case GL_TEXTURE_EXTERNAL_OES:
-            glsl_sampler = "samplerExternalOES";
-            lookup = "texture2D";
-            break;
-        case GL_TEXTURE_2D:
-            glsl_sampler = "sampler2D";
-            lookup  = "texture2D";
-            break;
-        case GL_TEXTURE_RECTANGLE:
-            glsl_sampler = "sampler2DRect";
-            lookup  = "texture2DRect";
-            break;
-        default:
-            vlc_assert_unreachable();
-    }
+    GetNames(tex_target, &glsl_sampler, &lookup);
 
     struct vlc_memstream ms;
     if (vlc_memstream_open(&ms) != 0)



More information about the vlc-commits mailing list