[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49652] branches/soc-2011-tomato/intern/ cycles: Tomato Cycles: report currently rendering sample when using GPU

Sergey Sharybin sergey.vfx at gmail.com
Tue Aug 7 15:27:19 CEST 2012


Revision: 49652
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49652
Author:   nazgul
Date:     2012-08-07 13:27:19 +0000 (Tue, 07 Aug 2012)
Log Message:
-----------
Tomato Cycles: report currently rendering sample when using GPU

Currently it makes more sense to use single tile for GPU rendering
and in this case tile-based progress report doesn't work well.

Since threading happens within single tile, it's possible to
detect currently computing sample and report it to the interface,

This also allows to display smoother progress when using CPU
with small amount of tiles.

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp
    branches/soc-2011-tomato/intern/cycles/device/device_task.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
    branches/soc-2011-tomato/intern/cycles/util/util_progress.h

Modified: branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp	2012-08-07 13:22:40 UTC (rev 49651)
+++ branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp	2012-08-07 13:27:19 UTC (rev 49652)
@@ -460,11 +460,15 @@
 void BlenderSession::get_progress(float& progress, double& total_time)
 {
 	double tile_time;
-	int tile;
+	int tile, sample, samples_per_tile;
 	int tile_total = session->tile_manager.state.num_tiles;
 
 	session->progress.get_tile(tile, total_time, tile_time);
-	progress = ((float)tile/(float)tile_total);
+
+	sample = session->progress.get_sample();
+	samples_per_tile = session->tile_manager.state.num_samples;
+
+	progress = ((float)sample/(float)(tile_total * samples_per_tile));
 }
 
 void BlenderSession::update_status_progress()

Modified: branches/soc-2011-tomato/intern/cycles/device/device_task.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/device/device_task.cpp	2012-08-07 13:22:40 UTC (rev 49651)
+++ branches/soc-2011-tomato/intern/cycles/device/device_task.cpp	2012-08-07 13:27:19 UTC (rev 49652)
@@ -95,7 +95,10 @@
 	if (type != PATH_TRACE)
 		return;
 
-	if (update_tile_sample) {
+	if(update_progress_sample)
+		update_progress_sample();
+
+	if(update_tile_sample) {
 		double current_time = time_dt();
 
 		if (current_time - last_update_time >= 1.0f) {

Modified: branches/soc-2011-tomato/intern/cycles/device/device_task.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/device/device_task.h	2012-08-07 13:22:40 UTC (rev 49651)
+++ branches/soc-2011-tomato/intern/cycles/device/device_task.h	2012-08-07 13:27:19 UTC (rev 49652)
@@ -60,6 +60,7 @@
 	void update_progress(RenderTile &rtile);
 
 	boost::function<bool(Device *device, RenderTile&)> acquire_tile;
+	boost::function<void(void)> update_progress_sample;
 	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-08-07 13:22:40 UTC (rev 49651)
+++ branches/soc-2011-tomato/intern/cycles/render/session.cpp	2012-08-07 13:27:19 UTC (rev 49652)
@@ -653,8 +653,29 @@
 	/* update status */
 	string status, substatus;
 
-	if(!params.progressive)
+	if(!params.progressive) {
 		substatus = string_printf("Path Tracing Tile %d/%d", tile, num_tiles);
+
+		if(params.device.type == DEVICE_CUDA || params.device.type == DEVICE_OPENCL) {
+			/* when rendering on GPU multithreading happens within single tile, as in
+			 * tiles are handling sequentially and in this case we could display
+			 * currently rendering sample number
+			 * this helps a lot from feedback point of view
+			 */
+
+			int sample = progress.get_sample(), num_samples = tile_manager.state.num_samples;
+
+			if(tile > 1) {
+				/* sample counter is global for all tiles, subtract samples
+				 * from already finished tiles to get sample counter for
+				 * current tile only
+				 */
+				sample -= (tile - 1) * num_samples;
+			}
+
+			substatus += string_printf(", Sample %d/%d", sample, num_samples);
+		}
+	}
 	else if(params.samples == INT_MAX)
 		substatus = string_printf("Path Tracing Sample %d", sample+1);
 	else
@@ -681,6 +702,10 @@
 	progress.set_tile(tile, tile_time);
 }
 
+void Session::update_progress_sample()
+{
+	progress.increment_sample();
+}
 
 void Session::path_trace()
 {
@@ -691,6 +716,7 @@
 	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);
+	task.update_progress_sample = function_bind(&Session::update_progress_sample, this);
 
 	device->task_add(task);
 }

Modified: branches/soc-2011-tomato/intern/cycles/render/session.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/render/session.h	2012-08-07 13:22:40 UTC (rev 49651)
+++ branches/soc-2011-tomato/intern/cycles/render/session.h	2012-08-07 13:27:19 UTC (rev 49652)
@@ -148,6 +148,8 @@
 	void update_tile_sample(RenderTile& tile);
 	void release_tile(RenderTile& tile);
 
+	void update_progress_sample();
+
 	bool device_use_gl;
 
 	thread *session_thread;

Modified: branches/soc-2011-tomato/intern/cycles/util/util_progress.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/util/util_progress.h	2012-08-07 13:22:40 UTC (rev 49651)
+++ branches/soc-2011-tomato/intern/cycles/util/util_progress.h	2012-08-07 13:27:19 UTC (rev 49652)
@@ -37,6 +37,7 @@
 	Progress()
 	{
 		tile = 0;
+		sample = 0;
 		start_time = time_dt();
 		total_time = 0.0f;
 		tile_time = 0.0f;
@@ -60,6 +61,8 @@
 		progress.get_status(status, substatus);
 		progress.get_tile(tile, total_time, tile_time);
 
+		sample = progress.get_sample();
+
 		return *this;
 	}
 
@@ -117,6 +120,18 @@
 		tile_time_ = tile_time;
 	}
 
+	void increment_sample()
+	{
+		thread_scoped_lock lock(progress_mutex);
+
+		sample++;
+	}
+
+	int get_sample()
+	{
+		return sample;
+	}
+
 	/* status messages */
 
 	void set_status(const string& status_, const string& substatus_ = "")
@@ -170,7 +185,8 @@
 	boost::function<void(void)> update_cb;
 	boost::function<void(void)> cancel_cb;
 
-	int tile;
+	int tile;    /* counter for rendered tiles */
+	int sample;  /* counter of rendered samples, global for all tiles */
 
 	double start_time;
 	double total_time;




More information about the Bf-blender-cvs mailing list