diff options
author | Richard Antalik <richardantalik@gmail.com> | 2020-12-20 03:51:23 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2020-12-20 05:51:56 +0300 |
commit | c4ff91aab76a9987ec109a733d39ff800ccbd15b (patch) | |
tree | 27f12a22b2778322f38220bdd822fc6a3411fac9 /source/blender/sequencer/intern/image_cache.c | |
parent | 0144b7094899798625f98cb08d90db2f05f329cb (diff) |
VSE: Fix incorrect cache memory usage calculation
If image is cached twice, it's size has been counted twice as well, but
only image reference count is increased, not memory usage.
Use `MEM_get_memory_in_use()` instead of size own tracking.
Diffstat (limited to 'source/blender/sequencer/intern/image_cache.c')
-rw-r--r-- | source/blender/sequencer/intern/image_cache.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 2fe59f52bf4..2cc25ae8d38 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -147,7 +147,6 @@ typedef struct SeqCache { struct BLI_mempool *keys_pool; struct BLI_mempool *items_pool; struct SeqCacheKey *last_key; - size_t memory_used; SeqDiskCache *disk_cache; } SeqCache; @@ -796,10 +795,8 @@ static void seq_cache_keyfree(void *val) static void seq_cache_valfree(void *val) { SeqCacheItem *item = (SeqCacheItem *)val; - SeqCache *cache = item->cache_owner; if (item->ibuf) { - cache->memory_used -= IMB_get_size_in_memory(item->ibuf); IMB_freeImBuf(item->ibuf); } @@ -816,7 +813,6 @@ static void seq_cache_put_ex(SeqCache *cache, SeqCacheKey *key, ImBuf *ibuf) if (BLI_ghash_reinsert(cache->hash, key, item, seq_cache_keyfree, seq_cache_valfree)) { IMB_refImBuf(ibuf); cache->last_key = key; - cache->memory_used += IMB_get_size_in_memory(ibuf); } } @@ -994,7 +990,6 @@ static SeqCacheKey *seq_cache_get_item_for_removal(Scene *scene) */ bool seq_cache_recycle_item(Scene *scene) { - size_t memory_total = seq_cache_get_mem_total(); SeqCache *cache = seq_cache_get_from_scene(scene); if (!cache) { return false; @@ -1002,7 +997,7 @@ bool seq_cache_recycle_item(Scene *scene) seq_cache_lock(scene); - while (cache->memory_used > memory_total) { + while (seq_cache_is_full()) { SeqCacheKey *finalkey = seq_cache_get_item_for_removal(scene); if (finalkey) { @@ -1466,13 +1461,7 @@ void SEQ_cache_iterate(struct Scene *scene, seq_cache_unlock(scene); } -bool seq_cache_is_full(Scene *scene) +bool seq_cache_is_full(void) { - size_t memory_total = seq_cache_get_mem_total(); - SeqCache *cache = seq_cache_get_from_scene(scene); - if (!cache) { - return false; - } - - return memory_total < cache->memory_used; + return seq_cache_get_mem_total() < MEM_get_memory_in_use(); } |