diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-05-22 05:58:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-05-22 05:58:07 +0400 |
commit | 049b6cfa6ddcc44d8001804922f041367f3051c6 (patch) | |
tree | c57f4aec1f85b037009036c22109b2a3330acdb3 /source/blender/gpu/intern | |
parent | 90db85a26301216d11c2adc956046b276ce8ef5f (diff) |
Fix for image garbage collection failing to run for render-only views
Check for freeing old images was running per-object, move this to viewport drawing.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 1845de16780..6d142adbc0c 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -76,6 +76,8 @@ #include "GPU_extensions.h" #include "GPU_material.h" +#include "PIL_time.h" + #include "smoke_API.h" extern Material defmaterial; /* from material.c */ @@ -1311,6 +1313,45 @@ void GPU_free_images_anim(void) GPU_free_image(ima); } + +void GPU_free_images_old(void) +{ + Image *ima; + static int lasttime = 0; + int ctime = (int)PIL_check_seconds_timer(); + + /* + * Run garbage collector once for every collecting period of time + * if textimeout is 0, that's the option to NOT run the collector + */ + if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime) + return; + + /* of course not! */ + if (G.is_rendering) + return; + + lasttime = ctime; + + ima = G.main->image.first; + while (ima) { + if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) { + /* If it's in GL memory, deallocate and set time tag to current time + * This gives textures a "second chance" to be used before dying. */ + if (ima->bindcode || ima->repbind) { + GPU_free_image(ima); + ima->lastused = ctime; + } + /* Otherwise, just kill the buffers */ + else { + BLI_image_free_buffers(ima); + } + } + ima = ima->id.next; + } +} + + /* OpenGL Materials */ #define FIXEDMAT 8 |