[cogl] arbfp: track which layers have combine constants



commit b6cea6bed6e51e59322e9f9398c9d1810a147563
Author: Robert Bragg <robert linux intel com>
Date:   Thu Sep 8 23:08:43 2011 +0100

    arbfp: track which layers have combine constants
    
    We weren't actually tracking which layers have been allocated param
    space for combine constants; all layers just had a default constant_id
    of 0 that indexes into the program.local[] params array and a dirty flag
    to say when the constant needs updating. There are times though when we
    say to update everything by-passing the dirty flag and because we
    weren't actually tracking which layers needed constants we would always
    write a constant to program.local[0] for every layer. The upshot was
    that we could end up clobbering a real constant that was actually
    allocated the constant_id = 0 slot.
    
    This patch adds a new UnitState bitfield to track if the layer has a
    corresponding constant that may need flushing and we only ever write the
    constant with glProgramLocalParameter4fv if that's set.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=658092
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/cogl-pipeline-fragend-arbfp.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/cogl/cogl-pipeline-fragend-arbfp.c b/cogl/cogl-pipeline-fragend-arbfp.c
index f02aec2..813bf14 100644
--- a/cogl/cogl-pipeline-fragend-arbfp.c
+++ b/cogl/cogl-pipeline-fragend-arbfp.c
@@ -61,6 +61,7 @@ typedef struct _UnitState
 {
   int constant_id; /* The program.local[] index */
   unsigned int dirty_combine_constant:1;
+  unsigned int has_combine_constant:1;
 
   unsigned int sampled:1;
 } UnitState;
@@ -404,6 +405,7 @@ setup_arg (CoglPipeline *pipeline,
         UnitState *unit_state = &shader_state->unit_state[unit_index];
 
         unit_state->constant_id = shader_state->next_constant_id++;
+        unit_state->has_combine_constant = TRUE;
         unit_state->dirty_combine_constant = TRUE;
 
         arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_CONSTANT;
@@ -786,7 +788,8 @@ update_constants_cb (CoglPipeline *pipeline,
 
   _COGL_GET_CONTEXT (ctx, FALSE);
 
-  if (state->update_all || unit_state->dirty_combine_constant)
+  if (unit_state->has_combine_constant &&
+      (state->update_all || unit_state->dirty_combine_constant))
     {
       float constant[4];
       _cogl_pipeline_get_layer_combine_constant (pipeline,



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