[Bf-blender-cvs] [6452d9f] master: Fix T39395: Switching to "Textured solid" and "GLSL" view will cause the FPS drop to 0

Sergey Sharybin noreply at git.blender.org
Tue Mar 25 07:33:17 CET 2014


Commit: 6452d9f02f07fb3aaa7c6601228ef96015a54996
Author: Sergey Sharybin
Date:   Tue Mar 25 12:30:41 2014 +0600
https://developer.blender.org/rB6452d9f02f07fb3aaa7c6601228ef96015a54996

Fix T39395: Switching to "Textured solid" and "GLSL" view will cause the FPS drop to 0

Issue was caused by the cache limitor which was removing 4k textures from the
memory when accessing other images.

This is pretty much awful situation and solved by making it so only image sequences
and movies ace cache-guarded.

Could be optimized further so images used by viewport are not being freed, but
that's much more tricky to do..

This is a nice candidature for 'a'.

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

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

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

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index aaeead4..7d8ada0 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -3058,7 +3058,6 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
 			if (ima->type == IMA_TYPE_MULTILAYER)
 				/* keeps render result, stores ibufs in listbase, allows saving */
 				ibuf = image_get_ibuf_multilayer(ima, iuser);
-
 		}
 		else if (ima->source == IMA_SRC_GENERATED) {
 			/* generated is: ibuf is allocated dynamically */
@@ -3076,9 +3075,6 @@ 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);
-				if (ibuf) {
-					ibuf->userflags |= IB_PERSISTENT;
-				}
 			}
 			else if (ima->type == IMA_TYPE_COMPOSITE) {
 				/* requires lock/unlock, otherwise don't return image */
@@ -3097,10 +3093,14 @@ 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;
 				}
 			}
 		}
+
+		/* We only want movies and sequences to be memory limited. */
+		if (ibuf != NULL && !ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+			ibuf->userflags |= IB_PERSISTENT;
+		}
 	}
 
 	BKE_image_tag_time(ima);
diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c
index 07ce3c3..f699afd 100644
--- a/source/blender/imbuf/intern/moviecache.c
+++ b/source/blender/imbuf/intern/moviecache.c
@@ -200,6 +200,18 @@ static size_t IMB_get_size_in_memory(ImBuf *ibuf)
 	int a;
 	size_t size = 0, channel_size = 0;
 
+	/* Persistent images should have no affect on how "normal"
+	 * images are cached.
+	 *
+	 * This is a bit arbitrary, but would make it so only movies
+	 * and sequences are memory limited, keeping textures in the
+	 * memory in order to avoid constant file reload on viewport
+	 * update.
+	 */
+	if (ibuf->userflags & IB_PERSISTENT) {
+		return 0;
+	}
+
 	size += sizeof(ImBuf);
 
 	if (ibuf->rect)




More information about the Bf-blender-cvs mailing list