Fix T40262: cycles GPU bake crash due to kernels not loaded, randomly due to thread...
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 19 May 2014 17:17:57 +0000 (19:17 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 19 May 2014 17:33:09 +0000 (19:33 +0200)
intern/cycles/blender/blender_session.cpp
intern/cycles/render/session.cpp
intern/cycles/render/session.h

index 01a5acd8982825d02afdc46a4368370d9b0ffadf..13d4041f6a7a7919bcdbe59d36150c7d4af73552 100644 (file)
@@ -518,6 +518,12 @@ void BlenderSession::bake(BL::Object b_object, const string& pass_type, BL::Bake
        size_t object_index = OBJECT_NONE;
        int tri_offset = 0;
 
+       /* ensure kernels are loaded before we do any scene updates */
+       session->load_kernels();
+
+       if(session->progress.get_cancel())
+               return;
+
        if(shader_type == SHADER_EVAL_UV) {
                /* force UV to be available */
                Pass::add(PASS_UV, scene->film->passes);
index 28b44df6b368dbfdcafc1d529ee040dcebfe058f..9fcd9fa85f53bd8005b2d269eba9a5e6387f2908 100644 (file)
@@ -592,9 +592,10 @@ void Session::run_cpu()
                update_progressive_refine(true);
 }
 
-void Session::run()
+void Session::load_kernels()
 {
-       /* load kernels */
+       thread_scoped_lock scene_lock(scene->mutex);
+
        if(!kernels_loaded) {
                progress.set_status("Loading render kernels (may take a few minutes the first time)");
 
@@ -603,6 +604,7 @@ void Session::run()
                        if(message.empty())
                                message = "Failed loading render kernel, see console for errors";
 
+                       progress.set_cancel(message);
                        progress.set_status("Error", message);
                        progress.set_update();
                        return;
@@ -610,6 +612,12 @@ void Session::run()
 
                kernels_loaded = true;
        }
+}
+
+void Session::run()
+{
+       /* load kernels */
+       load_kernels();
 
        /* session thread loop */
        progress.set_status("Waiting for render to start");
index 4638bb8cc372a60c5742b724e35ec006d5e2525d..9da7a0aafa3971f487710e144c0b496e9682575b 100644 (file)
@@ -138,7 +138,10 @@ public:
        void set_pause(bool pause);
 
        void update_scene();
+       void load_kernels();
+
        void device_free();
+
 protected:
        struct DelayedReset {
                thread_mutex mutex;