Merge branch 'blender2.7'
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 9 Jan 2019 16:20:58 +0000 (17:20 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 9 Jan 2019 16:20:58 +0000 (17:20 +0100)
build_files/build_environment/cmake/harvest.cmake
intern/cycles/blender/blender_session.cpp
intern/cycles/device/device_split_kernel.cpp
intern/cycles/device/device_split_kernel.h
intern/cycles/render/session.cpp

index f2e9c2f..d79d91f 100644 (file)
@@ -102,7 +102,6 @@ function(harvest from to)
                        FILES_MATCHING PATTERN ${pattern}
                        PATTERN "pkgconfig" EXCLUDE
                        PATTERN "cmake" EXCLUDE
-                       PATTERN "clang" EXCLUDE
                        PATTERN "__pycache__" EXCLUDE
                        PATTERN "tests" EXCLUDE)
        endif()
@@ -129,6 +128,7 @@ harvest(jemalloc/lib jemalloc/lib "*.a")
 harvest(jpg/include jpeg/include "*.h")
 harvest(jpg/lib jpeg/lib "libjpeg.a")
 harvest(lame/lib ffmpeg/lib "*.a")
+harvest(clang/bin llvm/bin "clang-format")
 harvest(llvm/bin llvm/bin "llvm-config")
 harvest(llvm/lib llvm/lib "libLLVM*.a")
 harvest(ogg/lib ffmpeg/lib "*.a")
index f84eefd..c634926 100644 (file)
@@ -114,9 +114,6 @@ BlenderSession::~BlenderSession()
 void BlenderSession::create()
 {
        create_session();
-
-       if(b_v3d)
-               session->start();
 }
 
 void BlenderSession::create_session()
@@ -804,7 +801,6 @@ void BlenderSession::synchronize(BL::Depsgraph& b_depsgraph_)
        {
                free_session();
                create_session();
-               session->start();
                return;
        }
 
@@ -857,6 +853,10 @@ void BlenderSession::synchronize(BL::Depsgraph& b_depsgraph_)
                /* reset time */
                start_resize_time = 0.0;
        }
+
+       /* Start rendering thread, if it's not running already. Do this
+        * after all scene data has been synced at least once. */
+       session->start();
 }
 
 bool BlenderSession::draw(int w, int h)
index efaae8c..ab2c11e 100644 (file)
@@ -32,10 +32,9 @@ DeviceSplitKernel::DeviceSplitKernel(Device *device)
   ray_state(device, "ray_state", MEM_READ_WRITE),
   queue_index(device, "queue_index"),
   use_queues_flag(device, "use_queues_flag"),
-  work_pool_wgs(device, "work_pool_wgs")
+  work_pool_wgs(device, "work_pool_wgs"),
+  kernel_data_initialized(false)
 {
-       first_tile = true;
-
        avg_time_per_sample = 0.0;
 
        kernel_path_init = NULL;
@@ -116,6 +115,9 @@ bool DeviceSplitKernel::load_kernels(const DeviceRequestedFeatures& requested_fe
 
 #undef LOAD_KERNEL
 
+       /* Re-initialiaze kernel-dependent data when kernels change. */
+       kernel_data_initialized = false;
+
        return true;
 }
 
@@ -137,33 +139,25 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
                return false;
        }
 
-       /* Get local size */
-       size_t local_size[2];
-       {
+       /* Allocate all required global memory once. */
+       if(!kernel_data_initialized) {
+               kernel_data_initialized = true;
+
+               /* Set local size */
                int2 lsize = split_kernel_local_size();
                local_size[0] = lsize[0];
                local_size[1] = lsize[1];
-       }
-
-       /* Number of elements in the global state buffer */
-       int num_global_elements = global_size[0] * global_size[1];
 
-       /* Allocate all required global memory once. */
-       if(first_tile) {
-               first_tile = false;
-
-               /* Set gloabl size */
-               {
-                       int2 gsize = split_kernel_global_size(kgbuffer, kernel_data, task);
+               /* Set global size */
+               int2 gsize = split_kernel_global_size(kgbuffer, kernel_data, task);
 
-                       /* Make sure that set work size is a multiple of local
-                        * work size dimensions.
-                        */
-                       global_size[0] = round_up(gsize[0], local_size[0]);
-                       global_size[1] = round_up(gsize[1], local_size[1]);
-               }
+               /* Make sure that set work size is a multiple of local
+                * work size dimensions.
+                */
+               global_size[0] = round_up(gsize[0], local_size[0]);
+               global_size[1] = round_up(gsize[1], local_size[1]);
 
-               num_global_elements = global_size[0] * global_size[1];
+               int num_global_elements = global_size[0] * global_size[1];
                assert(num_global_elements % WORK_POOL_SIZE == 0);
 
                /* Calculate max groups */
@@ -180,6 +174,9 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
                ray_state.alloc(num_global_elements);
        }
 
+       /* Number of elements in the global state buffer */
+       int num_global_elements = global_size[0] * global_size[1];
+
 #define ENQUEUE_SPLIT_KERNEL(name, global_size, local_size) \
                if(device->have_error()) { \
                        return false; \
index 5af4367..622733b 100644 (file)
@@ -92,10 +92,9 @@ private:
        /* Work pool with respect to each work group. */
        device_only_memory<unsigned int> work_pool_wgs;
 
-       /* Marked True in constructor and marked false at the end of path_trace(). */
-       bool first_tile;
-
-       /* Cached global size */
+       /* Cached kernel-dependent data, initialized once. */
+       bool kernel_data_initialized;
+       size_t local_size[2];
        size_t global_size[2];
 
 public:
index 2d1f60c..cb02d1f 100644 (file)
@@ -129,7 +129,9 @@ Session::~Session()
 
 void Session::start()
 {
-       session_thread = new thread(function_bind(&Session::run, this));
+       if (!session_thread) {
+               session_thread = new thread(function_bind(&Session::run, this));
+       }
 }
 
 bool Session::ready_to_reset()
@@ -830,8 +832,10 @@ void Session::set_pause(bool pause_)
 
 void Session::wait()
 {
-       session_thread->join();
-       delete session_thread;
+       if (session_thread) {
+               session_thread->join();
+               delete session_thread;
+       }
 
        session_thread = NULL;
 }