Fix part of #33132: render resoltuion refresh issues after persistent images
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 9 Nov 2012 23:54:58 +0000 (23:54 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 9 Nov 2012 23:54:58 +0000 (23:54 +0000)
was added for cycles.

This fixes the case where the option is disabled. I moved the option now to
Blender itself and made it keep the engine around only when it's enabled. Also
fixes case where there could be issues when switching to another renderer.

intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_sync.cpp
source/blender/editors/render/render_update.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/external_engine.c
source/blender/render/intern/source/pipeline.c

index 32b07f47ba8e4ddfe73e0bfd52cbd56180e89181..0b8ca6e0fbecff7159479fc973b489ab1f997559 100644 (file)
@@ -297,12 +297,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
                 default=False,
                 )
 
-        cls.use_persistent_images = BoolProperty(
-                name="Persistent Images",
-                description="Keep images loaded on the device so they could be reused by next render",
-                default=False,
-                )
-
     @classmethod
     def unregister(cls):
         del bpy.types.Scene.cycles
index 9ecd0d3e25242c427a5f801b62cb9281a2d822e5..4a651eb5aab2cd6a70f3b48579f62cf432fa8b77 100644 (file)
@@ -218,7 +218,7 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
 
         sub = col.column(align=True)
         sub.label(text="Final Render:")
-        sub.prop(cscene, "use_persistent_images")
+        sub.prop(rd, "use_persistent_data", text="Persistent Images")
 
 
 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
index ce589f55e601852ed9a329397a4bbf4f9287393d..9ebdcfd04bdc33aa3b0420a6350889ccfd7776f9 100644 (file)
@@ -284,6 +284,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer)
 
 SceneParams BlenderSync::get_scene_params(BL::Scene b_scene, bool background)
 {
+       BL::RenderSettings r = b_scene.render();
        SceneParams params;
        PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
        int shadingsystem = RNA_enum_get(&cscene, "shading_system");
@@ -301,7 +302,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene b_scene, bool background)
        params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
        params.use_bvh_cache = (background)? RNA_boolean_get(&cscene, "use_cache"): false;
 
-       params.persistent_images = (background)? RNA_boolean_get(&cscene, "use_persistent_images"): false;
+       params.persistent_images = (background)? r.use_persistent_data(): false;
 
        return params;
 }
index 0a2ca379518416e29490f94873de974dbecac9e9..5155f1001ab5e173c23d5df4b0d924d6cde2a198 100644 (file)
@@ -58,6 +58,7 @@
 #include "GPU_material.h"
 
 #include "RE_engine.h"
+#include "RE_pipeline.h"
 
 #include "ED_node.h"
 #include "ED_render.h"
@@ -157,6 +158,8 @@ void ED_render_engine_changed(Main *bmain)
        for (sc = bmain->screen.first; sc; sc = sc->id.next)
                for (sa = sc->areabase.first; sa; sa = sa->next)
                        ED_render_engine_area_exit(sa);
+
+       RE_FreePersistentData();
 }
 
 /***************************** Updates ***********************************
index 1479d5268edbd1b133b80bdf2a80b929e451a6b6..251e6a7eb4eec240f9b9d5e8744c760f2388bfa9 100644 (file)
@@ -1187,11 +1187,12 @@ typedef struct Scene {
                /* Use the same flag for autothreads */
 #define R_FIXED_THREADS                0x80000 
 
-#define R_SPEED                        0x100000
-#define R_SSS                  0x200000
-#define R_NO_OVERWRITE 0x400000 /* skip existing files */
-#define R_TOUCH                        0x800000 /* touch files before rendering */
-#define R_SIMPLIFY             0x1000000
+#define R_SPEED                                0x100000
+#define R_SSS                          0x200000
+#define R_NO_OVERWRITE         0x400000  /* skip existing files */
+#define R_TOUCH                                0x800000  /* touch files before rendering */
+#define R_SIMPLIFY                     0x1000000
+#define R_PERSISTENT_DATA      0x2000000 /* keep data around for re-render */
 
 /* seq_flag */
 #define R_SEQ_GL_PREV 1
index b102d463195b4c63f7048e489f18979bc53f2bc8..5e4eb526b767990ca17d92dc0562fd63a4b25702 100644 (file)
@@ -1254,6 +1254,12 @@ static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr
                rna_Scene_use_simplify_update(bmain, scene, ptr);
 }
 
+static void rna_Scene_use_persistent_data_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
+{
+       if (!(scene->r.mode & R_PERSISTENT_DATA))
+               RE_FreePersistentData();
+}
+
 static int rna_Scene_use_audio_get(PointerRNA *ptr)
 {
        Scene *scene = (Scene *)ptr->data;
@@ -4036,6 +4042,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE);
        RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated");
 
+       /* persistent data */
+       prop = RNA_def_property(srna, "use_persistent_data", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "mode", R_PERSISTENT_DATA);
+       RNA_def_property_ui_text(prop, "Persistent Data", "Keep render data around for faster re-renders");
+       RNA_def_property_update(prop, 0, "rna_Scene_use_persistent_data_update");
+
        /* Scene API */
        RNA_api_scene_render(srna);
 }
index 984b1a8e65104fcb0c10f89657fcfd241c0d895e..ecdd17742213340776ce15a8952b6139433b4005 100644 (file)
@@ -170,6 +170,8 @@ void RE_FreeRender (struct Render *re);
 void RE_FreeAllRender (void);
 /* only call on file load */
 void RE_FreeAllRenderResults(void);
+/* for external render engines that can keep persistent data */
+void RE_FreePersistentData(void);
 
 /* get results and statistics */
 void RE_FreeRenderResult(struct RenderResult *rr);
index 736cb5de7c33a041cb644a72b35206c548abde30..d771cf2253d42ac6618838a1bb3b31d9e6acab8d 100644 (file)
@@ -382,6 +382,11 @@ int RE_engine_render(Render *re, int do_all)
        if (type->render)
                type->render(engine, re->scene);
 
+       if(!(re->r.mode & R_PERSISTENT_DATA)) {
+               RE_engine_free(re->engine);
+               re->engine = NULL;
+       }
+
        if (re->result->do_exr_tile) {
                BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
                render_result_exr_file_end(re);
index 369818d37d53b956db5363c797673f3579daa604..3797430952cdb6cade261dcf7f48de1f6108f4dd 100644 (file)
@@ -244,6 +244,7 @@ Render *RE_GetRender(const char *name)
        return re;
 }
 
+
 /* if you want to know exactly what has been done */
 RenderResult *RE_AcquireResultRead(Render *re)
 {
@@ -424,6 +425,19 @@ void RE_FreeAllRenderResults(void)
        }
 }
 
+void RE_FreePersistentData()
+{
+       Render *re;
+
+       /* render engines can be kept around for quick re-render, this clears all */
+       for (re = RenderGlobal.renderlist.first; re; re = re->next) {
+               if (re->engine) {
+                       RE_engine_free(re);
+                       re->engine = NULL;
+               }
+       }
+}
+
 /* ********* initialize state ******** */