From 8cfb158f63a1e1f4af614e17b0198850ff3bdbce Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 14 Sep 2010 20:25:23 +0100 Subject: [PATCH] material-arbfp: fix updating params if sharing progs If a single arbfp program is being shared between multiple CoglMaterials then we need to make sure we update all program.local params when switching between materials. Previously we had a dirty flag to track when combine_constant params were changed but didn't take in to account that different materials sharing the same program may have different combine constants. --- clutter/cogl/cogl/cogl-material-arbfp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/clutter/cogl/cogl/cogl-material-arbfp.c b/clutter/cogl/cogl/cogl-material-arbfp.c index 9c9a36edd..5c6c94871 100644 --- a/clutter/cogl/cogl/cogl-material-arbfp.c +++ b/clutter/cogl/cogl/cogl-material-arbfp.c @@ -980,6 +980,7 @@ _cogl_material_backend_arbfp_passthrough (CoglMaterial *material) typedef struct _UpdateConstantsState { int unit; + gboolean update_all; ArbfpProgramState *arbfp_program_state; } UpdateConstantsState; @@ -994,7 +995,7 @@ update_constants_cb (CoglMaterial *material, _COGL_GET_CONTEXT (ctx, FALSE); - if (unit_state->dirty_combine_constant) + if (state->update_all || unit_state->dirty_combine_constant) { float constant[4]; _cogl_material_get_layer_combine_constant (material, @@ -1072,11 +1073,20 @@ _cogl_material_backend_arbfp_end (CoglMaterial *material, UpdateConstantsState state; state.unit = 0; state.arbfp_program_state = arbfp_program_state; + /* If this arbfp program was last used with a different material + * then we need to ensure we update all program.local params */ + state.update_all = + material != arbfp_program_state->last_used_for_material; cogl_material_foreach_layer (material, update_constants_cb, &state); } + /* We need to track what material used this arbfp program last since + * we will need to update program.local params when switching + * between different materials. */ + arbfp_program_state->last_used_for_material = material; + return TRUE; }