mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
cogl-pipeline-glsl: Fix reusing shaders for shared ancestors
The check for whether we can reuse a program we've already generated was only being done if the pipeline already had a glsl_program_state. When there is no glsl_program_state it then looks for the nearest ancestor it can share the program with. It then wasn't checking whether that ancestor already had a GL program so it would start generating the source again. It wouldn't however compile that source again because _cogl_pipeline_backend_glsl_end does check whether there is already a program. This patch moves the check until after it has found the glsl_program_state, whether or not it was found from an ancestor or as its own state.
This commit is contained in:
parent
4cfe90bde2
commit
dd5431ef38
@ -305,23 +305,7 @@ _cogl_pipeline_backend_glsl_start (CoglPipeline *pipeline,
|
|||||||
set_glsl_priv (pipeline, priv);
|
set_glsl_priv (pipeline, priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we already have a valid GLSL program then we don't need to
|
if (!priv->glsl_program_state)
|
||||||
relink a new one */
|
|
||||||
if (priv->glsl_program_state)
|
|
||||||
{
|
|
||||||
/* However if the program has changed since the last link then we do
|
|
||||||
* need to relink */
|
|
||||||
if (user_program == NULL ||
|
|
||||||
(priv->glsl_program_state->user_program_age == user_program->age))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/* Destroy the existing program. We can't just dirty the whole
|
|
||||||
glsl state because otherwise if we are not the authority on
|
|
||||||
the user program then we'll just find the same state again */
|
|
||||||
delete_program (priv->glsl_program_state->gl_program);
|
|
||||||
priv->glsl_program_state->gl_program = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* If we don't have an associated glsl program yet then find the
|
/* If we don't have an associated glsl program yet then find the
|
||||||
* glsl-authority (the oldest ancestor whose state will result in
|
* glsl-authority (the oldest ancestor whose state will result in
|
||||||
@ -358,6 +342,20 @@ _cogl_pipeline_backend_glsl_start (CoglPipeline *pipeline,
|
|||||||
glsl_program_state_ref (authority_priv->glsl_program_state);
|
glsl_program_state_ref (authority_priv->glsl_program_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->glsl_program_state->gl_program)
|
||||||
|
{
|
||||||
|
/* If we already have a valid GLSL program then we don't need to
|
||||||
|
relink a new one. However if the program has changed since
|
||||||
|
the last link then we do need to relink */
|
||||||
|
if (user_program == NULL ||
|
||||||
|
(priv->glsl_program_state->user_program_age == user_program->age))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* We need to recreate the program so destroy the existing one */
|
||||||
|
delete_program (priv->glsl_program_state->gl_program);
|
||||||
|
priv->glsl_program_state->gl_program = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we make it here then we have a glsl_program_state struct
|
/* If we make it here then we have a glsl_program_state struct
|
||||||
without a gl_program either because this is the first time we've
|
without a gl_program either because this is the first time we've
|
||||||
encountered it or because the user program has changed since it
|
encountered it or because the user program has changed since it
|
||||||
|
Loading…
Reference in New Issue
Block a user