[cogl/wip/cogl-gst: 6/9] cogl-gst: Remove the uniforms and varyings from the snippets



commit a52d1374192a7a489c192ff2ba9ceb1121040dbe
Author: Neil Roberts <neil linux intel com>
Date:   Tue Feb 26 19:01:57 2013 +0000

    cogl-gst: Remove the uniforms and varyings from the snippets
    
    The cogl_gst_sample_video functions were declaring their own sampler
    uniforms. Setting these relies on guessing the unit number given the
    layer index number. Although in practice this will just work, in
    theory we don't expose the mapping of layer indices to unit numbers so
    it is possible that it won't always map directly in future. This patch
    simplifies it by just making the shader directly refer to the builtin
    sampler names such as cogl_sampler0.
    
    Additionally there was a varying called rgb_color which is not used
    anywhere so it has also been removed.

 cogl-gst/cogl-gst-shader.c     |   14 ++++----------
 cogl-gst/cogl-gst-video-sink.c |   32 ++------------------------------
 2 files changed, 6 insertions(+), 40 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-shader.c b/cogl-gst/cogl-gst-shader.c
index cdc627f..cb5d9ee 100644
--- a/cogl-gst/cogl-gst-shader.c
+++ b/cogl-gst/cogl-gst-shader.c
@@ -38,14 +38,10 @@
 
 const char
 _cogl_gst_shader_yv12_to_rgba_decl[] =
-  "uniform sampler2D ytex;\n"
-  "uniform sampler2D utex;\n"
-  "uniform sampler2D vtex;\n"
-  "varying vec4 rgb_color;\n"
   "vec4 cogl_gst_sample_video (vec2 UV) {\n"
-  "  float y = 1.1640625 * (texture2D (ytex, UV).g - 0.0625);\n"
-  "  float u = texture2D (utex, UV).g - 0.5;\n"
-  "  float v = texture2D (vtex, UV).g - 0.5;\n"
+  "  float y = 1.1640625 * (texture2D (cogl_sampler0, UV).g - 0.0625);\n"
+  "  float u = texture2D (cogl_sampler1, UV).g - 0.5;\n"
+  "  float v = texture2D (cogl_sampler2, UV).g - 0.5;\n"
   "  vec4 color;\n"
   "  color.r = y + 1.59765625 * v;\n"
   "  color.g = y - 0.390625 * u - 0.8125 * v;\n"
@@ -56,10 +52,8 @@ _cogl_gst_shader_yv12_to_rgba_decl[] =
 
 const char
 _cogl_gst_shader_ayuv_to_rgba_decl[] =
-  "uniform sampler2D tex;\n"
-  "varying vec4 rgb_color;\n"
   "vec4 cogl_gst_sample_video (vec2 UV) {\n"
-  "  vec4 color = texture2D (tex, UV);\n"
+  "  vec4 color = texture2D (cogl_sampler0, UV);\n"
   "  float y = 1.1640625 * (color.g - 0.0625);\n"
   "  float u = color.b - 0.5;\n"
   "  float v = color.a - 0.5;\n"
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 37b362f..2acafc9 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -293,11 +293,10 @@ static void
 create_template_pipeline (CoglGstVideoSink *sink,
                           const char *decl,
                           const char *post,
-                          CoglBool set_uniforms,
                           int n_layers)
 {
   CoglGstVideoSinkPrivate *priv = sink->priv;
-  priv->free_layer = 1;
+  priv->free_layer = n_layers;
 
   if (priv->pipeline)
     {
@@ -315,30 +314,6 @@ create_template_pipeline (CoglGstVideoSink *sink,
       cogl_object_unref (snippet);
     }
 
-  if (set_uniforms)
-    {
-      unsigned int location;
-      location = cogl_pipeline_get_uniform_location (priv->pipeline,
-                                                           "ytex");
-      cogl_pipeline_set_uniform_1i (priv->pipeline, location, 0);
-
-      if (n_layers > 1)
-        {
-          location = cogl_pipeline_get_uniform_location (priv->pipeline,
-                                                               "utex");
-          cogl_pipeline_set_uniform_1i (priv->pipeline, location, 1);
-          priv->free_layer++;
-        }
-
-      if (n_layers > 2)
-        {
-          location = cogl_pipeline_get_uniform_location (priv->pipeline,
-                                                           "vtex");
-          cogl_pipeline_set_uniform_1i (priv->pipeline, location, 2);
-          priv->free_layer++;
-        }
-    }
-
   g_signal_emit_by_name (sink, "cogl-pipeline-ready", 0);
 }
 
@@ -379,7 +354,7 @@ cogl_gst_dummy_deinit (CoglGstVideoSink *sink)
 static void
 cogl_gst_rgb_init (CoglGstVideoSink *sink)
 {
-  create_template_pipeline (sink, NULL, NULL, FALSE, 1);
+  create_template_pipeline (sink, NULL, NULL, 1);
 }
 
 static void
@@ -485,7 +460,6 @@ cogl_gst_yv12_glsl_init (CoglGstVideoSink *sink)
   create_template_pipeline (sink,
                             _cogl_gst_shader_yv12_to_rgba_decl,
                             _cogl_gst_shader_default_post,
-                            TRUE,
                             3);
 }
 
@@ -506,7 +480,6 @@ cogl_gst_i420_glsl_init (CoglGstVideoSink *sink)
   create_template_pipeline (sink,
                             _cogl_gst_shader_yv12_to_rgba_decl,
                             _cogl_gst_shader_default_post,
-                            TRUE,
                             3);
 }
 
@@ -527,7 +500,6 @@ cogl_gst_ayuv_glsl_init (CoglGstVideoSink *sink)
   create_template_pipeline (sink,
                             _cogl_gst_shader_ayuv_to_rgba_decl,
                             _cogl_gst_shader_default_post,
-                            TRUE,
                             1);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]