Merge branch 'blender-v2.93-release'
This commit is contained in:
@@ -130,6 +130,7 @@ class PlayRenderedAnim(Operator):
|
|||||||
"-s", str(frame_start),
|
"-s", str(frame_start),
|
||||||
"-e", str(frame_end),
|
"-e", str(frame_end),
|
||||||
"-j", str(scene.frame_step),
|
"-j", str(scene.frame_step),
|
||||||
|
"-c", str(prefs.system.memory_cache_limit),
|
||||||
file,
|
file,
|
||||||
]
|
]
|
||||||
cmd.extend(opts)
|
cmd.extend(opts)
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ typedef struct PlayAnimPict {
|
|||||||
#ifdef USE_FRAME_CACHE_LIMIT
|
#ifdef USE_FRAME_CACHE_LIMIT
|
||||||
/** Back pointer to the #LinkData node for this struct in the #inmempicsbase list. */
|
/** Back pointer to the #LinkData node for this struct in the #inmempicsbase list. */
|
||||||
LinkData *frame_cache_node;
|
LinkData *frame_cache_node;
|
||||||
|
size_t size_in_memory;
|
||||||
#endif
|
#endif
|
||||||
} PlayAnimPict;
|
} PlayAnimPict;
|
||||||
|
|
||||||
@@ -254,7 +255,11 @@ static double fps_movie;
|
|||||||
|
|
||||||
#ifdef USE_FRAME_CACHE_LIMIT
|
#ifdef USE_FRAME_CACHE_LIMIT
|
||||||
static struct ListBase inmempicsbase = {NULL, NULL};
|
static struct ListBase inmempicsbase = {NULL, NULL};
|
||||||
|
/** Keep track of the memory used by #inmempicsbase when `frame_cache_memory_limit != 0`. */
|
||||||
|
size_t inmempicsbase_size_in_memory = 0;
|
||||||
static int added_images = 0;
|
static int added_images = 0;
|
||||||
|
/** Limit the amount of memory used for cache (in bytes). */
|
||||||
|
static size_t frame_cache_memory_limit = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step)
|
static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step)
|
||||||
@@ -1227,6 +1232,15 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
|||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
break;
|
break;
|
||||||
|
case 'c': {
|
||||||
|
#ifdef USE_FRAME_CACHE_LIMIT
|
||||||
|
const int memory_in_mb = max_ii(0, atoi(argv[2]));
|
||||||
|
frame_cache_memory_limit = (size_t)memory_in_mb * (1024 * 1024);
|
||||||
|
#endif
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
printf("unknown option '%c': skipping\n", argv[1][1]);
|
printf("unknown option '%c': skipping\n", argv[1][1]);
|
||||||
break;
|
break;
|
||||||
@@ -1422,8 +1436,19 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_FRAME_CACHE_LIMIT
|
#ifdef USE_FRAME_CACHE_LIMIT
|
||||||
|
if (ps.picture->frame_cache_node == NULL) {
|
||||||
|
ps.picture->frame_cache_node = BLI_genericNodeN(ps.picture);
|
||||||
|
BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node);
|
||||||
|
added_images++;
|
||||||
|
|
||||||
|
if (frame_cache_memory_limit != 0) {
|
||||||
|
BLI_assert(ps.picture->size_in_memory == 0);
|
||||||
|
ps.picture->size_in_memory = IMB_get_size_in_memory(ps.picture->ibuf);
|
||||||
|
inmempicsbase_size_in_memory += ps.picture->size_in_memory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
/* Don't free the current frame by moving it to the head of the list. */
|
/* Don't free the current frame by moving it to the head of the list. */
|
||||||
if (ps.picture->frame_cache_node != NULL) {
|
|
||||||
BLI_assert(ps.picture->frame_cache_node->data == ps.picture);
|
BLI_assert(ps.picture->frame_cache_node->data == ps.picture);
|
||||||
BLI_remlink(&inmempicsbase, ps.picture->frame_cache_node);
|
BLI_remlink(&inmempicsbase, ps.picture->frame_cache_node);
|
||||||
BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node);
|
BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node);
|
||||||
@@ -1431,14 +1456,20 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
|||||||
|
|
||||||
/* Really basic memory conservation scheme. Keep frames in a FIFO queue. */
|
/* Really basic memory conservation scheme. Keep frames in a FIFO queue. */
|
||||||
LinkData *node = inmempicsbase.last;
|
LinkData *node = inmempicsbase.last;
|
||||||
|
while (node && (frame_cache_memory_limit ?
|
||||||
while (node && added_images > PLAY_FRAME_CACHE_MAX) {
|
(inmempicsbase_size_in_memory > frame_cache_memory_limit) :
|
||||||
|
(added_images > PLAY_FRAME_CACHE_MAX))) {
|
||||||
PlayAnimPict *pic = node->data;
|
PlayAnimPict *pic = node->data;
|
||||||
BLI_assert(pic->frame_cache_node == node);
|
BLI_assert(pic->frame_cache_node == node);
|
||||||
|
|
||||||
if (pic->ibuf && pic->ibuf != ibuf) {
|
if (pic->ibuf && pic->ibuf != ibuf) {
|
||||||
LinkData *node_tmp;
|
LinkData *node_tmp;
|
||||||
IMB_freeImBuf(pic->ibuf);
|
IMB_freeImBuf(pic->ibuf);
|
||||||
|
if (frame_cache_memory_limit != 0) {
|
||||||
|
BLI_assert(pic->size_in_memory != 0);
|
||||||
|
inmempicsbase_size_in_memory -= pic->size_in_memory;
|
||||||
|
pic->size_in_memory = 0;
|
||||||
|
}
|
||||||
pic->ibuf = NULL;
|
pic->ibuf = NULL;
|
||||||
pic->frame_cache_node = NULL;
|
pic->frame_cache_node = NULL;
|
||||||
node_tmp = node->prev;
|
node_tmp = node->prev;
|
||||||
@@ -1451,11 +1482,6 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.picture->frame_cache_node == NULL) {
|
|
||||||
ps.picture->frame_cache_node = BLI_genericNodeN(ps.picture);
|
|
||||||
BLI_addhead(&inmempicsbase, ps.picture->frame_cache_node);
|
|
||||||
added_images++;
|
|
||||||
}
|
|
||||||
#endif /* USE_FRAME_CACHE_LIMIT */
|
#endif /* USE_FRAME_CACHE_LIMIT */
|
||||||
|
|
||||||
BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name));
|
BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name));
|
||||||
|
|||||||
@@ -1189,7 +1189,10 @@ static const char arg_handle_playback_mode_doc[] =
|
|||||||
"\t-s <frame>\n"
|
"\t-s <frame>\n"
|
||||||
"\t\tPlay from <frame>.\n"
|
"\t\tPlay from <frame>.\n"
|
||||||
"\t-e <frame>\n"
|
"\t-e <frame>\n"
|
||||||
"\t\tPlay until <frame>.";
|
"\t\tPlay until <frame>.\n"
|
||||||
|
"\t-c <cache_memory>\n"
|
||||||
|
"\t\tAmount of memory in megabytes to allow for caching images during playback.\n"
|
||||||
|
"\t\tZero disables (clamping to a fixed number of frames instead).";
|
||||||
static int arg_handle_playback_mode(int argc, const char **argv, void *UNUSED(data))
|
static int arg_handle_playback_mode(int argc, const char **argv, void *UNUSED(data))
|
||||||
{
|
{
|
||||||
/* not if -b was given first */
|
/* not if -b was given first */
|
||||||
|
|||||||
Reference in New Issue
Block a user