[Cogl] [PATCH 2/2] Cache the debug wireframe snippet
Robert Bragg
robert at sixbynine.org
Mon May 21 08:45:08 PDT 2012
This looks good to land to me:
Reviewed-by: Robert Bragg <robert at linux.intel.com>
thanks,
- Robert
On Sat, May 19, 2012 at 11:17 PM, Neil Roberts <neil at linux.intel.com> wrote:
> When rendering the debug wireframe Cogl generates a child pipeline of
> the application's pipeline to replace the fragment processing.
> Previously it was creating a new snippet every time something was
> drawn. Cogl doesn't attempt to compare the contents of snippets when
> looking in the program cache for a matching pipeline so this would
> cause it to generate a new program for every primitive. It then quite
> quickly ends printing the warning about there being more than 50
> programs in the cache. To fix that this patch makes it cache the
> snippet so that Cogl can successfully recognise that it already has a
> program generated for the new pipeline.
> ---
> cogl/cogl-framebuffer.c | 20 +++++++++++++-------
> 1 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
> index fc0bf0b..ec4acf6 100644
> --- a/cogl/cogl-framebuffer.c
> +++ b/cogl/cogl-framebuffer.c
> @@ -3261,15 +3261,21 @@ draw_wireframe (CoglContext *ctx,
> * of the wire color leaving the rest of the state untouched. */
> if (cogl_has_feature (framebuffer->context, COGL_FEATURE_ID_GLSL))
> {
> - CoglSnippet *snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
> - NULL,
> - NULL);
> - cogl_snippet_set_replace (snippet,
> - "cogl_color_out = "
> - "vec4 (0.0, 1.0, 0.0, 1.0);\n");
> + static CoglSnippet *snippet = NULL;
> +
> + /* The snippet is cached so that it will reuse the program
> + * from the pipeline cache if possible */
> + if (snippet == NULL)
> + {
> + snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
> + NULL,
> + NULL);
> + cogl_snippet_set_replace (snippet,
> + "cogl_color_out = "
> + "vec4 (0.0, 1.0, 0.0, 1.0);\n");
> + }
>
> cogl_pipeline_add_snippet (wire_pipeline, snippet);
> - cogl_object_unref (snippet);
> }
> else
> {
> --
> 1.7.3.16.g9464b
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
More information about the Cogl
mailing list