Fix T38040: Crash after loading big image file in compositor

Issue was caused by cache limitor removing viewer image buffer
from the memory during compositing. Now made it so all viewer
images are persistent in the memory.

This solves the crash mentioned above and also makes it so
render/compo results are never lost.

Further tweaks are possible, but pretty much happy now, at
least no stoppers for work are there.
This commit is contained in:
Sergey Sharybin 2014-01-13 18:42:40 +06:00
parent daedf5be8c
commit b1bb7d2ee0
Notes: blender-bot 2023-02-14 11:24:05 +01:00
Referenced by issue #38040, Crash after loading big image file in compositor
3 changed files with 9 additions and 1 deletions

View File

@ -137,6 +137,9 @@ static void imagecache_put(Image *image, int index, ImBuf *ibuf)
ImageCacheKey key;
if (image->cache == NULL) {
// char cache_name[64];
// BLI_snprintf(cache_name, sizeof(cache_name), "Image Datablock %s", image->id.name);
image->cache = IMB_moviecache_create("Image Datablock Cache", sizeof(ImageCacheKey),
imagecache_hashhash, imagecache_hashcmp);
}
@ -3099,6 +3102,7 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
/* always verify entirely, and potentially
* returns pointer to release later */
ibuf = image_get_render_result(ima, iuser, lock_r);
ibuf->userflags |= IB_PERSISTENT;
}
else if (ima->type == IMA_TYPE_COMPOSITE) {
/* requires lock/unlock, otherwise don't return image */
@ -3117,6 +3121,7 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
ibuf = IMB_allocImBuf(256, 256, 32, IB_rect);
image_assign_ibuf(ima, ibuf, 0, frame);
}
ibuf->userflags |= IB_PERSISTENT;
}
}
}

View File

@ -150,6 +150,7 @@ typedef struct ImBuf {
#define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */
#define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */
#define IB_DISPLAY_BUFFER_INVALID (1 << 4) /* either float or byte buffer changed, need to re-calculate display buffers */
#define IB_PERSISTENT (1 << 5) /* image buffer is persistent in the memory and should never be removed from the cache */
/**
* \name Imbuf Component flags

View File

@ -262,7 +262,9 @@ static bool get_item_destroyable(void *item_v)
*
* Such buffers are never to be freed.
*/
if (item->ibuf->userflags & IB_BITMAPDIRTY) {
if ((item->ibuf->userflags & IB_BITMAPDIRTY) ||
(item->ibuf->userflags & IB_PERSISTENT))
{
return false;
}
return true;