Cycles: Reload kernels from Session when requested features change
authorMai Lavelle <mai.lavelle@gmail.com>
Thu, 18 May 2017 02:14:12 +0000 (22:14 -0400)
committerMai Lavelle <mai.lavelle@gmail.com>
Fri, 19 May 2017 20:24:19 +0000 (16:24 -0400)
This fixes T49496.

intern/cycles/render/session.cpp
intern/cycles/render/session.h

index 3f080407b1fea92747f19117accac3e215a65b21..08909943c49c95e658346b7f1c085909003c3e11 100644 (file)
@@ -726,16 +726,20 @@ DeviceRequestedFeatures Session::get_requested_device_features()
        return requested_features;
 }
 
-void Session::load_kernels()
+void Session::load_kernels(bool lock_scene)
 {
-       thread_scoped_lock scene_lock(scene->mutex);
+       thread_scoped_lock scene_lock;
+       if(lock_scene) {
+               scene_lock = thread_scoped_lock(scene->mutex);
+       }
 
-       if(!kernels_loaded) {
+       DeviceRequestedFeatures requested_features = get_requested_device_features();
+
+       if(!kernels_loaded || loaded_kernel_features.modified(requested_features)) {
                progress.set_status("Loading render kernels (may take a few minutes the first time)");
 
                scoped_timer timer;
 
-               DeviceRequestedFeatures requested_features = get_requested_device_features();
                VLOG(2) << "Requested features:\n" << requested_features;
                if(!device->load_kernels(requested_features)) {
                        string message = device->error_message();
@@ -752,6 +756,7 @@ void Session::load_kernels()
                VLOG(1) << "Total time spent loading kernels: " << time_dt() - timer.get_start();
 
                kernels_loaded = true;
+               loaded_kernel_features = requested_features;
        }
 }
 
@@ -902,6 +907,8 @@ void Session::update_scene()
 
        /* update scene */
        if(scene->need_update()) {
+               load_kernels(false);
+
                progress.set_status("Updating Scene");
                MEM_GUARDED_CALL(&progress, scene->device_update, device, progress);
        }
index a7ca90abbce262542c7a5a35408b2e0c29791946..5fb1a365ee92210f78723d90b0bb3e77aa1c5103 100644 (file)
@@ -158,7 +158,7 @@ public:
        void set_pause(bool pause);
 
        void update_scene();
-       void load_kernels();
+       void load_kernels(bool lock_scene=true);
 
        void device_free();
 
@@ -215,6 +215,7 @@ protected:
        thread_mutex display_mutex;
 
        bool kernels_loaded;
+       DeviceRequestedFeatures loaded_kernel_features;
 
        double reset_time;