[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49150] branches/soc-2011-tomato/intern/ cycles: Tomato Cycles: update buffers on every sample finished

Sergey Sharybin sergey.vfx at gmail.com
Mon Jul 23 20:45:29 CEST 2012


Revision: 49150
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49150
Author:   nazgul
Date:     2012-07-23 18:45:29 +0000 (Mon, 23 Jul 2012)
Log Message:
-----------
Tomato Cycles: update buffers on every sample finished

Was requested by Mango team to improve feedback during rendering.

Known issues:
- Updating of samples are accumulative, meaning that visually samples
  would be dark in the beginning becoming brighter during progress.
- Could give some % of slowdown, so probably should be disabled in
  background mode.

Still to come: update of samples when using CUDA and OpenCL.

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/cycles/device/device_cpu.cpp
    branches/soc-2011-tomato/intern/cycles/device/device_task.h
    branches/soc-2011-tomato/intern/cycles/render/session.cpp
    branches/soc-2011-tomato/intern/cycles/render/session.h

Modified: branches/soc-2011-tomato/intern/cycles/device/device_cpu.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/device/device_cpu.cpp	2012-07-23 18:28:00 UTC (rev 49149)
+++ branches/soc-2011-tomato/intern/cycles/device/device_cpu.cpp	2012-07-23 18:45:29 UTC (rev 49150)
@@ -153,38 +153,43 @@
 
 #ifdef WITH_OPTIMIZED_KERNEL
 			if(system_cpu_support_optimized()) {
-				for(int y = tile.y; y < tile.y + tile.h; y++) {
-					for(int x = tile.x; x < tile.x + tile.w; x++)
-						for(int sample = start_sample; sample < end_sample; sample++) {
-							if (task.get_cancel()) {
+				for(int sample = start_sample; sample < end_sample; sample++) {
+					for(int y = tile.y; y < tile.y + tile.h; y++) {
+						for(int x = tile.x; x < tile.x + tile.w; x++) {
+							if (task.get_cancel())
 								break;
-							}
 
+							if(task_pool.cancelled())
+								break;
+
 							kernel_cpu_optimized_path_trace(kg, render_buffer, rng_state,
 								sample, x, y, tile.offset, tile.stride);
 						}
+					}
 
-					if(task_pool.cancelled())
-						break;
+					task.update_tile_sample(tile);
 				}
 			}
 			else
 #endif
 			{
-				for(int y = tile.y; y < tile.y + tile.h; y++) {
-					for(int x = tile.x; x < tile.x + tile.w; x++)
-						for(int sample = start_sample; sample < end_sample; sample++) {
+				for(int sample = start_sample; sample < end_sample; sample++) {
+					for(int y = tile.y; y < tile.y + tile.h; y++) {
+						for(int x = tile.x; x < tile.x + tile.w; x++) {
 							if (task.get_cancel()) {
 								break;
 							}
 
+							if(task_pool.cancelled())
+								break;
+
 							kernel_cpu_path_trace(kg, render_buffer, rng_state,
 								sample, x, y, tile.offset, tile.stride);
 
 						}
+					}
 
-					if(task_pool.cancelled())
-						break;
+					task.update_tile_sample(tile);
 				}
 			}
 

Modified: branches/soc-2011-tomato/intern/cycles/device/device_task.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/device/device_task.h	2012-07-23 18:28:00 UTC (rev 49149)
+++ branches/soc-2011-tomato/intern/cycles/device/device_task.h	2012-07-23 18:45:29 UTC (rev 49150)
@@ -58,6 +58,7 @@
 	void split_max_size(list<DeviceTask>& tasks, int max_size);
 
 	boost::function<bool(Device *device, RenderTile&)> acquire_tile;
+	boost::function<void(RenderTile&)> update_tile_sample;
 	boost::function<void(RenderTile&)> release_tile;
 	boost::function<bool(void)> get_cancel;
 };

Modified: branches/soc-2011-tomato/intern/cycles/render/session.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/render/session.cpp	2012-07-23 18:28:00 UTC (rev 49149)
+++ branches/soc-2011-tomato/intern/cycles/render/session.cpp	2012-07-23 18:45:29 UTC (rev 49150)
@@ -373,12 +373,27 @@
 	return true;
 }
 
+void Session::update_tile_sample(RenderTile& rtile)
+{
+	thread_scoped_lock tile_lock(tile_mutex);
+
+	if(write_render_buffers_cb) {
+		/* todo: optimize this by making it thread safe and removing lock */
+
+		if(!progress.get_cancel())
+			write_render_buffers_cb(rtile.buffers);
+	}
+
+	update_status_time();
+}
+
 void Session::release_tile(RenderTile& rtile)
 {
 	thread_scoped_lock tile_lock(tile_mutex);
 
 	if(write_render_buffers_cb) {
 		/* todo: optimize this by making it thread safe and removing lock */
+		/* todo: this could be removed as soon as all devices would use update_tile_sample */
 		if(!progress.get_cancel())
 			write_render_buffers_cb(rtile.buffers);
 		delete rtile.buffers;
@@ -679,6 +694,7 @@
 	task.acquire_tile = function_bind(&Session::acquire_tile, this, _1, _2);
 	task.release_tile = function_bind(&Session::release_tile, this, _1);
 	task.get_cancel = function_bind(&Progress::get_cancel, &this->progress);
+	task.update_tile_sample = function_bind(&Session::update_tile_sample, this, _1);
 
 	device->task_add(task);
 }

Modified: branches/soc-2011-tomato/intern/cycles/render/session.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/render/session.h	2012-07-23 18:28:00 UTC (rev 49149)
+++ branches/soc-2011-tomato/intern/cycles/render/session.h	2012-07-23 18:45:29 UTC (rev 49150)
@@ -145,6 +145,7 @@
 	void reset_gpu(BufferParams& params, int samples);
 
 	bool acquire_tile(Device *tile_device, RenderTile& tile);
+	void update_tile_sample(RenderTile& tile);
 	void release_tile(RenderTile& tile);
 
 	bool device_use_gl;




More information about the Bf-blender-cvs mailing list