opengl render was freeing all images from the graphics card each update.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 20 May 2010 16:08:06 +0000 (16:08 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 20 May 2010 16:08:06 +0000 (16:08 +0000)
with some 4x4k and 4x8k textures this becomes very slow.

only free animated textures (movies and sequences)

source/blender/editors/space_view3d/view3d_draw.c
source/blender/gpu/GPU_draw.h
source/blender/gpu/intern/gpu_draw.c

index 9f9733bc80c1bcfd1f01597b4a49ea7f1ace6a98..53fd0125329d1db6add492584e248c096cbc35bb 100644 (file)
@@ -1965,7 +1965,10 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
 
        /* set flags */
        G.f |= G_RENDER_OGL;
-       GPU_free_images();
+
+       /* free images which can have changed on frame-change
+        * warning! can be slow so only free animated images - campbell */
+       GPU_free_images_anim();
 
        /* set background color, fallback on the view background color */
        if(scene->world) {
@@ -2030,7 +2033,8 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
        /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
        draw_gpencil_view3d_ext(scene, ar, 0);
 
-       GPU_free_images();
+       /* freeing the images again here could be done after the operator runs, leaving for now */
+       GPU_free_images_anim();
 
        /* restore size */
        ar->winx= bwinx;
index e233a3f3d94274a8b4aa580bbf7b15ede29c6785..92bf43e9a5a49c5159abf26ccf7cef57629e790a 100644 (file)
@@ -117,6 +117,7 @@ int GPU_update_image_time(struct Image *ima, double time);
 int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int tfmode, int compare, int mipmap);
 void GPU_free_image(struct Image *ima);
 void GPU_free_images(void);
+void GPU_free_images_anim(void);
 
 /* smoke drawing functions */
 void GPU_free_smoke(struct SmokeModifierData *smd);
index 6eb3e13c4e29191863fd6616e8027fa716a6966f..9a5a670442835bc9ea3704a86f91bf3892dac592 100644 (file)
@@ -851,6 +851,17 @@ void GPU_free_images(void)
                        GPU_free_image(ima);
 }
 
+/* same as above but only free animated images */
+void GPU_free_images_anim(void)
+{
+       Image* ima;
+
+       if(G.main)
+               for(ima=G.main->image.first; ima; ima=ima->id.next)
+                       if(ELEM(ima->type, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE))
+                               GPU_free_image(ima);
+}
+
 /* OpenGL Materials */
 
 #define FIXEDMAT       8