[clutter/clutter-1.6] Implement COGL_DEBUG=disable-texturing for ARBFp and GLSL fragends



commit 2505f5b0afadd49d8c5d54d8fb1bf57b9f2a6014
Author: Neil Roberts <neil linux intel com>
Date:   Wed Jun 8 18:08:36 2011 +0100

    Implement COGL_DEBUG=disable-texturing for ARBFp and GLSL fragends
    
    The COGL_DEBUG=disable-texturing debug variable disables texturing in
    the fixed function fragend by not bothering to enable the texture
    targets. This wasn't working for the programmable fragends because the
    texture targets don't need to be enabled to use them. This patch
    modifies the two programmable backends to generate a constant value
    for the texture lookups in the shader when the debug variable is
    given.
    
    This is backported from commit c3c080481952b33737bea in Cogl master.

 clutter/cogl/cogl/cogl-pipeline-fragend-arbfp.c |   25 ++++++++++++++--------
 clutter/cogl/cogl/cogl-pipeline-fragend-glsl.c  |    9 ++++++++
 2 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/clutter/cogl/cogl/cogl-pipeline-fragend-arbfp.c b/clutter/cogl/cogl/cogl-pipeline-fragend-arbfp.c
index 15dacdf..58c34d4 100644
--- a/clutter/cogl/cogl/cogl-pipeline-fragend-arbfp.c
+++ b/clutter/cogl/cogl/cogl-pipeline-fragend-arbfp.c
@@ -381,15 +381,22 @@ setup_texture_source (ArbfpProgramState *arbfp_program_state,
 {
   if (!arbfp_program_state->unit_state[unit_index].sampled)
     {
-      g_string_append_printf (arbfp_program_state->source,
-                              "TEMP texel%d;\n"
-                              "TEX texel%d,fragment.texcoord[%d],"
-                              "texture[%d],%s;\n",
-                              unit_index,
-                              unit_index,
-                              unit_index,
-                              unit_index,
-                              gl_target_to_arbfp_string (gl_target));
+      if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
+        g_string_append_printf (arbfp_program_state->source,
+                                "TEMP texel%d;\n"
+                                "MOV texel%d, one;\n",
+                                unit_index,
+                                unit_index);
+      else
+        g_string_append_printf (arbfp_program_state->source,
+                                "TEMP texel%d;\n"
+                                "TEX texel%d,fragment.texcoord[%d],"
+                                "texture[%d],%s;\n",
+                                unit_index,
+                                unit_index,
+                                unit_index,
+                                unit_index,
+                                gl_target_to_arbfp_string (gl_target));
       arbfp_program_state->unit_state[unit_index].sampled = TRUE;
     }
 }
diff --git a/clutter/cogl/cogl/cogl-pipeline-fragend-glsl.c b/clutter/cogl/cogl/cogl-pipeline-fragend-glsl.c
index 6c273e1..8c57898 100644
--- a/clutter/cogl/cogl/cogl-pipeline-fragend-glsl.c
+++ b/clutter/cogl/cogl/cogl-pipeline-fragend-glsl.c
@@ -350,6 +350,15 @@ add_texture_lookup (GlslShaderState *glsl_shader_state,
   int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
   const char *target_string, *tex_coord_swizzle;
 
+  if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
+    {
+      g_string_append (glsl_shader_state->source,
+                       "vec4 (1.0, 1.0, 1.0, 1.0).");
+      g_string_append (glsl_shader_state->source, swizzle);
+
+      return;
+    }
+
   texture = _cogl_pipeline_layer_get_texture (layer);
 
   if (texture == COGL_INVALID_HANDLE)



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