diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-09 19:20:58 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-09 19:20:58 +0300 |
commit | 60799d6fee256427bcac7c0ca30d5197b4eddbc1 (patch) | |
tree | 62a9c42a0b5b376097c64788228d7b27b97d2cce /intern/cycles | |
parent | 513bc5954c714edfbc4a48dff118ac6b83f9a7bb (diff) | |
parent | 49e3f08815af17704e94c0e9eba0c6228a43972a (diff) |
Merge branch 'blender2.7'
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/device/device_split_kernel.cpp | 45 | ||||
-rw-r--r-- | intern/cycles/device/device_split_kernel.h | 7 | ||||
-rw-r--r-- | intern/cycles/render/session.cpp | 10 |
4 files changed, 35 insertions, 35 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index f84eefd0233..c634926ea9f 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -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) diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp index efaae8c84f4..ab2c11e904d 100644 --- a/intern/cycles/device/device_split_kernel.cpp +++ b/intern/cycles/device/device_split_kernel.cpp @@ -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; \ diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h index 5af4367d1b6..622733b843f 100644 --- a/intern/cycles/device/device_split_kernel.h +++ b/intern/cycles/device/device_split_kernel.h @@ -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: diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 2d1f60c722b..cb02d1f900c 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -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; } |