mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
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.
This commit is contained in:
parent
d87522596d
commit
8cfb158f63
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user