mirror of
https://github.com/brl/mutter.git
synced 2024-12-02 04:40:43 -05:00
5085919acc
Previously when a pipeline is added to the cache it would never be removed. If the application is generating a lot of unique pipelines this can end up effectively leaking a large number of resources including the GL program objects. Arguably this isn't really a problem because if the application is generating that many unique pipelines then it is doing something wrong anyway. It also implies that it will be recompiling shaders very often so the cache leaking will likely be the least of the problems. This patch makes it keep track of which pipelines in the cache are in use. The cache now returns a struct representing the entry instead of directly returning the pipeline. This entry contains a usage counter which the pipeline backends can use to mark when there is a pipeline alive that is using the cache entry. When the hash table decides that it's a good time to prune some entries, it will make a list of all of the pipelines that are not in use and then remove the least recently used half of the pipelines. That way it is less likely to remove pipelines that the application is actually regenerating often even if they aren't in use all of the time. When the cache is pruned the hash table makes a note of how small the cache could be if it removed all of the unused pipelines. The hash table starts pruning when there are more entries than twice this minimum expected size. The idea is that if that case it hit then the hash table is more than half full of useless pipelines so the application is generating lots of redundant pipelines and it is a good time to remove them. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit c21aac22992bb7fef5a8d0913130b8245e67f2eb) Conflicts: cogl/driver/gl/cogl-pipeline-fragend-glsl.c cogl/driver/gl/cogl-pipeline-progend-glsl.c cogl/driver/gl/cogl-pipeline-vertend-glsl.c cogl/driver/gl/gl/cogl-pipeline-fragend-arbfp.c |
||
---|---|---|
.. | ||
gl | ||
nop |