pipeline: Clarify stages for finding an arbfp program
In the arbfp backend there is a seqential approach to finding a suitable arbfp program to use for a given pipeline; first we see if there's already a program associated with the pipeline, 2nd we try and find a program associated with the "arbfp-authority" 3rd we try and lookup a program in a cache and finally we resort to starting code-generation for a new program. This patch slightly reworks the code of these steps to hopefully make them a bit clearer.
This commit is contained in:
parent
9606c42c55
commit
bac600b21b
@ -214,6 +214,7 @@ _cogl_pipeline_backend_arbfp_start (CoglPipeline *pipeline,
|
||||
CoglPipelineBackendARBfpPrivate *priv;
|
||||
CoglPipeline *authority;
|
||||
CoglPipelineBackendARBfpPrivate *authority_priv;
|
||||
ArbfpProgramState *arbfp_program_state;
|
||||
CoglHandle user_program;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||
@ -257,6 +258,17 @@ _cogl_pipeline_backend_arbfp_start (CoglPipeline *pipeline,
|
||||
*/
|
||||
authority = _cogl_pipeline_find_codegen_authority (pipeline, user_program);
|
||||
authority_priv = get_arbfp_priv (authority);
|
||||
if (authority_priv &&
|
||||
authority_priv->arbfp_program_state)
|
||||
{
|
||||
/* If we are going to share our program state with an arbfp-authority
|
||||
* then steal a reference to the program state associated with that
|
||||
* arbfp-authority... */
|
||||
priv->arbfp_program_state =
|
||||
arbfp_program_state_ref (authority_priv->arbfp_program_state);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!authority_priv)
|
||||
{
|
||||
authority_priv = g_slice_new0 (CoglPipelineBackendARBfpPrivate);
|
||||
@ -266,24 +278,39 @@ _cogl_pipeline_backend_arbfp_start (CoglPipeline *pipeline,
|
||||
/* If we haven't yet found an existing program then before we resort to
|
||||
* generating a new arbfp program we see if we can find a suitable
|
||||
* program in the arbfp_cache. */
|
||||
if (!authority_priv->arbfp_program_state &&
|
||||
G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_DISABLE_PROGRAM_CACHES)))
|
||||
if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_DISABLE_PROGRAM_CACHES)))
|
||||
{
|
||||
arbfp_program_state = g_hash_table_lookup (ctx->arbfp_cache, authority);
|
||||
if (arbfp_program_state)
|
||||
{
|
||||
priv->arbfp_program_state =
|
||||
arbfp_program_state_ref (arbfp_program_state);
|
||||
|
||||
/* Since we have already resolved the arbfp-authority at this point
|
||||
* we might as well also associate any program we find from the cache
|
||||
* with the authority too... */
|
||||
if (authority_priv != priv)
|
||||
authority_priv->arbfp_program_state =
|
||||
g_hash_table_lookup (ctx->arbfp_cache, authority);
|
||||
if (authority_priv->arbfp_program_state)
|
||||
arbfp_program_state_ref (authority_priv->arbfp_program_state);
|
||||
arbfp_program_state_ref (arbfp_program_state);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!authority_priv->arbfp_program_state)
|
||||
{
|
||||
ArbfpProgramState *arbfp_program_state =
|
||||
arbfp_program_state_new (n_layers);
|
||||
authority_priv->arbfp_program_state = arbfp_program_state;
|
||||
|
||||
/* If we don't have an existing program associated with the
|
||||
* arbfp-authority then start generating code for a new program...
|
||||
/* If we still haven't found an existing program then start
|
||||
* generating code for a new program...
|
||||
*/
|
||||
|
||||
arbfp_program_state = arbfp_program_state_new (n_layers);
|
||||
|
||||
priv->arbfp_program_state = arbfp_program_state_ref (arbfp_program_state);
|
||||
|
||||
/* Since we have already resolved the arbfp-authority at this point we might
|
||||
* as well also associate any program we generate with the authority too...
|
||||
*/
|
||||
if (authority_priv != priv)
|
||||
authority_priv->arbfp_program_state =
|
||||
arbfp_program_state_ref (arbfp_program_state);
|
||||
|
||||
arbfp_program_state->user_program = user_program;
|
||||
if (user_program == COGL_INVALID_HANDLE)
|
||||
{
|
||||
@ -306,16 +333,7 @@ _cogl_pipeline_backend_arbfp_start (CoglPipeline *pipeline,
|
||||
arbfp_program_state->unit_state[i].sampled = FALSE;
|
||||
arbfp_program_state->unit_state[i].dirty_combine_constant = FALSE;
|
||||
}
|
||||
arbfp_program_state->next_constant_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally, if the pipeline isn't actually its own arbfp-authority
|
||||
* then steal a reference to the program state associated with the
|
||||
* arbfp-authority... */
|
||||
if (authority != pipeline)
|
||||
priv->arbfp_program_state =
|
||||
arbfp_program_state_ref (authority_priv->arbfp_program_state);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user