cogl-material: Always reset the GLSL program to zero when flushing
authorNeil Roberts <neil@linux.intel.com>
Wed, 21 Jul 2010 22:22:07 +0000 (23:22 +0100)
committerNeil Roberts <neil@linux.intel.com>
Thu, 22 Jul 2010 16:50:56 +0000 (17:50 +0100)
When flushing a fixed-function or arbfp material it would always call
disable_glsl to try to get rid of the previous GLSL shader. This is
needed even if current_use_program_type is not GLSL because if an
application calls cogl_program_uniform then Cogl will have to bind the
program to set the uniform. If this happens then it won't update
current_use_program_type presumably because the enabled state of arbfp
is still valid.

The problem was that disable_glsl would only select program zero when
the current_use_program_type is set to GLSL which wouldn't be the case
if cogl_program_uniform was called. This patch changes it to just
directly call _cogl_gl_use_program_wrapper(0) instead of having a
separate disable_glsl function. The current program is cached in the
cogl context anyway so it shouldn't cause any extra unnecessary GL
calls.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2232

clutter/cogl/cogl/cogl-material-opengl.c

index 236196d..d00d17e 100644 (file)
@@ -311,17 +311,6 @@ _cogl_gl_use_program_wrapper (GLuint program)
 }
 
 static void
-disable_glsl (void)
-{
-#ifdef COGL_MATERIAL_BACKEND_GLSL
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  if (ctx->current_use_program_type == COGL_MATERIAL_PROGRAM_TYPE_GLSL)
-    _cogl_gl_use_program_wrapper (0);
-#endif
-}
-
-static void
 disable_arbfp (void)
 {
 #ifdef COGL_MATERIAL_BACKEND_ARBFP
@@ -367,7 +356,7 @@ _cogl_use_program (CoglHandle program_handle, CoglMaterialProgramType type)
       /* _cogl_gl_use_program_wrapper can be called by cogl-program.c
        * so we can't bailout without making sure we glUseProgram (0)
        * first. */
-      disable_glsl ();
+      _cogl_gl_use_program_wrapper (0);
 
       if (ctx->current_use_program_type == COGL_MATERIAL_PROGRAM_TYPE_ARBFP)
         break;
@@ -387,7 +376,7 @@ _cogl_use_program (CoglHandle program_handle, CoglMaterialProgramType type)
       /* _cogl_gl_use_program_wrapper can be called by cogl-program.c
        * so we can't bailout without making sure we glUseProgram (0)
        * first. */
-      disable_glsl ();
+      _cogl_gl_use_program_wrapper (0);
 
       if (ctx->current_use_program_type == COGL_MATERIAL_PROGRAM_TYPE_FIXED)
         break;