[cogl/wip/neil/master-next: 10/16] glsl: Use layer numbers not unit numbers for builtin uniforms



commit 300bcc3766eeae78eb990adc01aee6157827df98
Author: Neil Roberts <neil linux intel com>
Date:   Fri Feb 10 14:17:10 2012 +0000

    glsl: Use layer numbers not unit numbers for builtin uniforms
    
    When generating GLSL code, the names of the builtin uniforms for the
    sampler and the layer constant have been renamed to use the layer
    number not the unit number. This will make it easier if we ever want
    to make them public.

 cogl/cogl-pipeline-fragend-glsl.c |   10 ++++------
 cogl/cogl-pipeline-progend-glsl.c |    4 ++--
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/cogl/cogl-pipeline-fragend-glsl.c b/cogl/cogl-pipeline-fragend-glsl.c
index faaa26c..a1885c0 100644
--- a/cogl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/cogl-pipeline-fragend-glsl.c
@@ -367,11 +367,9 @@ add_constant_lookup (CoglPipelineShaderState *shader_state,
                      CoglPipelineLayer *layer,
                      const char *swizzle)
 {
-  int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
-
   g_string_append_printf (shader_state->header,
                           "_cogl_layer_constant_%i.%s",
-                          unit_index, swizzle);
+                          layer->index, swizzle);
 }
 
 static void
@@ -456,7 +454,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
         g_string_append_printf (shader_state->header,
                                 "uniform sampler%s _cogl_sampler_%i;\n",
                                 target_string,
-                                unit_index);
+                                layer->index);
 
       g_string_append_printf (shader_state->header,
                               "vec4\n"
@@ -471,7 +469,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
       else
         g_string_append_printf (shader_state->header,
                                 "texture%s (_cogl_sampler_%i, coords.%s);\n",
-                                target_string, unit_index, tex_coord_swizzle);
+                                target_string, layer->index, tex_coord_swizzle);
 
       g_string_append (shader_state->header, "}\n");
     }
@@ -612,7 +610,7 @@ ensure_arg_generated (CoglPipeline *pipeline,
           {
             g_string_append_printf (shader_state->header,
                                     "uniform vec4 _cogl_layer_constant_%i;\n",
-                                    unit_index);
+                                    layer->index);
             shader_state->unit_state[unit_index].combine_constant_used = TRUE;
           }
       }
diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c
index 561ea3e..a0153a6 100644
--- a/cogl/cogl-pipeline-progend-glsl.c
+++ b/cogl/cogl-pipeline-progend-glsl.c
@@ -371,7 +371,7 @@ get_uniform_cb (CoglPipeline *pipeline,
      the program has now been linked */
   g_string_set_size (ctx->codegen_source_buffer, 0);
   g_string_append_printf (ctx->codegen_source_buffer,
-                          "_cogl_sampler_%i", state->unit);
+                          "_cogl_sampler_%i", layer_index);
 
   GE_RET( uniform_location,
           ctx, glGetUniformLocation (state->gl_program,
@@ -386,7 +386,7 @@ get_uniform_cb (CoglPipeline *pipeline,
 
   g_string_set_size (ctx->codegen_source_buffer, 0);
   g_string_append_printf (ctx->codegen_source_buffer,
-                          "_cogl_layer_constant_%i", state->unit);
+                          "_cogl_layer_constant_%i", layer_index);
 
   GE_RET( uniform_location,
           ctx, glGetUniformLocation (state->gl_program,



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