[Bf-blender-cvs] [b1bb7d2] master: Fix T38040: Crash after loading big image file in compositor

Sergey Sharybin noreply at git.blender.org
Mon Jan 13 13:47:21 CET 2014


Commit: b1bb7d2ee06d13e95154d13a6e830b8b0f845cde
Author: Sergey Sharybin
Date:   Mon Jan 13 18:42:40 2014 +0600
https://developer.blender.org/rBb1bb7d2ee06d13e95154d13a6e830b8b0f845cde

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.

===================================================================

M	source/blender/blenkernel/intern/image.c
M	source/blender/imbuf/IMB_imbuf_types.h
M	source/blender/imbuf/intern/moviecache.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f83112b..636c08f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -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;
 				}
 			}
 		}
diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h
index d201308..44cb7f1 100644
--- a/source/blender/imbuf/IMB_imbuf_types.h
+++ b/source/blender/imbuf/IMB_imbuf_types.h
@@ -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
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index 3718cb2..00d9dd2 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -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;




More information about the Bf-blender-cvs mailing list