diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2016-11-26 06:22:34 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2016-12-03 07:02:21 +0300 |
commit | a2ebc5268f2b98ee7335e0054c177c849a45cfba (patch) | |
tree | f1c08ab691cc93b08df0a387b037d1e0a45e9a53 /intern/cycles/device | |
parent | 35d490b3f13c75e9a62cb30f3842ed38a27f6dbc (diff) |
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
Diffstat (limited to 'intern/cycles/device')
-rw-r--r-- | intern/cycles/device/device.h | 1 | ||||
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 7 | ||||
-rw-r--r-- | intern/cycles/device/device_cuda.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/device/device_multi.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/device/device_network.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/device/device_task.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/device/device_task.h | 4 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl_mega.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl_split.cpp | 4 |
9 files changed, 47 insertions, 8 deletions
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index b9bdffa2618..988ad10607d 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -220,6 +220,7 @@ public: DeviceInfo info; virtual const string& error_message() { return error_msg; } bool have_error() { return !error_message().empty(); } + virtual bool show_samples() const { return false; } /* statistics */ Stats &stats; diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index aed86d8d853..c8e001ec2fd 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -112,6 +112,11 @@ public: task_pool.stop(); } + virtual bool show_samples() const + { + return (TaskScheduler::num_threads() == 1); + } + void mem_alloc(device_memory& mem, MemoryType /*type*/) { mem.device_pointer = mem.data_pointer; @@ -275,7 +280,7 @@ public: tile.sample = sample + 1; - task.update_progress(&tile); + task.update_progress(&tile, tile.w*tile.h); } task.release_tile(tile); diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index fbb97f78e70..233f94be1bf 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -115,6 +115,12 @@ public: return path_exists(cubins_path); } + virtual bool show_samples() const + { + /* The CUDADevice only processes one tile at a time, so showing samples is fine. */ + return true; + } + /*#ifdef NDEBUG #define cuda_abort() #else @@ -1267,7 +1273,7 @@ public: tile.sample = sample + 1; - task->update_progress(&tile); + task->update_progress(&tile, tile.w*tile.h); } task->release_tile(tile); diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 48fd159d508..31b800640d3 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -89,6 +89,14 @@ public: return error_msg; } + virtual bool show_samples() const + { + if(devices.size() > 1) { + return false; + } + return devices.front().device->show_samples(); + } + bool load_kernels(const DeviceRequestedFeatures& requested_features) { foreach(SubDevice& sub, devices) diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp index 3eb5ad2d2db..53eef6cf199 100644 --- a/intern/cycles/device/device_network.cpp +++ b/intern/cycles/device/device_network.cpp @@ -51,6 +51,11 @@ public: thread_mutex rpc_lock; + virtual bool show_samples() const + { + return false; + } + NetworkDevice(DeviceInfo& info, Stats &stats, const char *address) : Device(info, stats, true), socket(io_service) { diff --git a/intern/cycles/device/device_task.cpp b/intern/cycles/device/device_task.cpp index 1f1128a28f8..48d18035c13 100644 --- a/intern/cycles/device/device_task.cpp +++ b/intern/cycles/device/device_task.cpp @@ -19,6 +19,8 @@ #include "device_task.h" +#include "buffers.h" + #include "util_algorithm.h" #include "util_time.h" @@ -99,14 +101,18 @@ void DeviceTask::split(list<DeviceTask>& tasks, int num, int max_size) } } -void DeviceTask::update_progress(RenderTile *rtile) +void DeviceTask::update_progress(RenderTile *rtile, int pixel_samples) { if((type != PATH_TRACE) && (type != SHADER)) return; - if(update_progress_sample) - update_progress_sample(); + if(update_progress_sample) { + if(pixel_samples == -1) { + pixel_samples = shader_w; + } + update_progress_sample(pixel_samples, rtile? rtile->sample : 0); + } if(update_tile_sample) { double current_time = time_dt(); diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h index 8423e83bdfd..8bd54c3d2b0 100644 --- a/intern/cycles/device/device_task.h +++ b/intern/cycles/device/device_task.h @@ -56,10 +56,10 @@ public: int get_subtask_count(int num, int max_size = 0); void split(list<DeviceTask>& tasks, int num, int max_size = 0); - void update_progress(RenderTile *rtile); + void update_progress(RenderTile *rtile, int pixel_samples = -1); function<bool(Device *device, RenderTile&)> acquire_tile; - function<void(void)> update_progress_sample; + function<void(long, int)> update_progress_sample; function<void(RenderTile&)> update_tile_sample; function<void(RenderTile&)> release_tile; function<bool(void)> get_cancel; diff --git a/intern/cycles/device/opencl/opencl_mega.cpp b/intern/cycles/device/opencl/opencl_mega.cpp index 369c086df57..6ea7619e022 100644 --- a/intern/cycles/device/opencl/opencl_mega.cpp +++ b/intern/cycles/device/opencl/opencl_mega.cpp @@ -39,6 +39,10 @@ public: { } + virtual bool show_samples() const { + return true; + } + virtual void load_kernels(const DeviceRequestedFeatures& /*requested_features*/, vector<OpenCLProgram*> &programs) { @@ -120,7 +124,7 @@ public: tile.sample = sample + 1; - task->update_progress(&tile); + task->update_progress(&tile, tile.w*tile.h); } /* Complete kernel execution before release tile */ diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index 239e73a40fd..3c3c2150128 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -247,6 +247,10 @@ public: } } + virtual bool show_samples() const { + return false; + } + /* Split kernel utility functions. */ size_t get_tex_size(const char *tex_name) { |