summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-02-10 14:17:10 +0000
committerNeil Roberts <neil@linux.intel.com>2012-02-13 17:15:35 +0000
commitaa9c2935027a3d5c6b14c80fa703375182b170fc (patch)
tree2d8d95534783709d14bdfd91f48d2ec625d5650f
parente6b3bfa41a18d7885ee6933d4333194b9976c0e4 (diff)
downloadcogl-aa9c2935027a3d5c6b14c80fa703375182b170fc.tar.gz
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. Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r--cogl/cogl-pipeline-fragend-glsl.c10
-rw-r--r--cogl/cogl-pipeline-progend-glsl.c4
2 files changed, 6 insertions, 8 deletions
diff --git a/cogl/cogl-pipeline-fragend-glsl.c b/cogl/cogl-pipeline-fragend-glsl.c
index faaa26c7..a1885c0b 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 561ea3ee..a0153a6e 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,