From 17c9d7eea7b3365c59455a731fcb81e69bb86ce2 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 18 Jun 2010 13:52:17 +0100 Subject: llvmpipe: limit the number of fragment shader variants kept around llvmpipe can create a large number of shader variants for a single shader (which are quite big), and they were only ever deleted if the shader itself was deleted. This is especially apparent in things like glean blendFunc where a new variant is created for every different subtest, chewing up all memory. This change limits the numbers of fragment shader variants (for all shaders) which are kept around to a fixed number. If that would be exceeded a fixed portion of the cached variants is deleted (since without tracking the used variants this involves flushing we don't want to delete only one). Always the least recently used variants (from all shaders together) are deleted. For now this is all per-context. Both the number of how many variants are cached (1024) as well as how many will be deleted at once (1/4 of the cache size) are just rough guesses and subject to further optimization. --- src/gallium/drivers/llvmpipe/lp_state_fs.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers/llvmpipe/lp_state_fs.h') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.h b/src/gallium/drivers/llvmpipe/lp_state_fs.h index 64ead2a997..272c9269ea 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.h +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.h @@ -64,10 +64,16 @@ struct lp_fragment_shader_variant_key struct lp_sampler_static_state sampler[PIPE_MAX_SAMPLERS]; }; +struct lp_fs_variant_list_item +{ + struct lp_fragment_shader_variant *base; + struct lp_fs_variant_list_item *next, *prev; +}; struct lp_fragment_shader_variant { struct lp_fragment_shader_variant_key key; + struct lp_fragment_shader *lpfs; boolean opaque; @@ -75,7 +81,7 @@ struct lp_fragment_shader_variant lp_jit_frag_func jit_function[2]; - struct lp_fragment_shader_variant *next; + struct lp_fs_variant_list_item list_item_global, list_item_local; /* For debugging/profiling purposes */ unsigned no; @@ -89,11 +95,12 @@ struct lp_fragment_shader struct tgsi_shader_info info; - struct lp_fragment_shader_variant *variants; + struct lp_fs_variant_list_item variants; /* For debugging/profiling purposes */ unsigned no; - unsigned variant_no; + unsigned variants_created; + unsigned variants_cached; }; -- cgit v1.2.3