[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43237] trunk/blender/intern/cycles: Cycles: show elapsed time for F12/background render.

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jan 9 17:57:47 CET 2012


Revision: 43237
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43237
Author:   blendix
Date:     2012-01-09 16:57:46 +0000 (Mon, 09 Jan 2012)
Log Message:
-----------
Cycles: show elapsed time for F12/background render.

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/blender_session.cpp
    trunk/blender/intern/cycles/render/session.cpp
    trunk/blender/intern/cycles/util/util_progress.h

Modified: trunk/blender/intern/cycles/blender/blender_session.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_session.cpp	2012-01-09 16:57:26 UTC (rev 43236)
+++ trunk/blender/intern/cycles/blender/blender_session.cpp	2012-01-09 16:57:46 UTC (rev 43237)
@@ -298,10 +298,8 @@
 	get_status(status, substatus);
 	get_progress(progress, total_time);
 
-	if(!background) {
-		BLI_timestr(total_time, time_str);
-		status = "Time: " + string(time_str) + " | " + status;
-	}
+	BLI_timestr(total_time, time_str);
+	status = "Elapsed: " + string(time_str) + " | " + status;
 
 	if(substatus.size() > 0)
 		status += " | " + substatus;

Modified: trunk/blender/intern/cycles/render/session.cpp
===================================================================
--- trunk/blender/intern/cycles/render/session.cpp	2012-01-09 16:57:26 UTC (rev 43236)
+++ trunk/blender/intern/cycles/render/session.cpp	2012-01-09 16:57:46 UTC (rev 43237)
@@ -162,6 +162,9 @@
 	reset_time = time_dt();
 	paused_time = 0.0;
 
+	if(!params.background)
+		progress.set_start_time(start_time - paused_time);
+
 	while(!progress.get_cancel()) {
 		/* advance to next tile */
 		bool no_tiles = !tile_manager.next();
@@ -186,6 +189,9 @@
 					pause_cond.wait(pause_lock);
 					paused_time += time_dt() - pause_start;
 
+					if(!params.background)
+						progress.set_start_time(start_time - paused_time);
+
 					update_status_time(pause, no_tiles);
 					progress.set_update();
 
@@ -332,6 +338,9 @@
 					pause_cond.wait(pause_lock);
 					paused_time += time_dt() - pause_start;
 
+					if(!params.background)
+						progress.set_start_time(start_time - paused_time);
+
 					update_status_time(pause, no_tiles);
 					progress.set_update();
 
@@ -457,6 +466,9 @@
 	preview_time = 0.0;
 	paused_time = 0.0;
 	sample = 0;
+
+	if(!params.background)
+		progress.set_start_time(start_time - paused_time);
 }
 
 void Session::reset(BufferParams& buffer_params, int samples)
@@ -556,15 +568,13 @@
 	/* update timing */
 	if(preview_time == 0.0 && resolution == 1)
 		preview_time = time_dt();
-
-	double total_time = time_dt() - start_time - paused_time;
+	
 	double sample_time = (sample == 0)? 0.0: (time_dt() - preview_time - paused_time)/(sample);
 
 	/* negative can happen when we pause a bit before rendering, can discard that */
-	if(total_time < 0.0) total_time = 0.0;
 	if(preview_time < 0.0) preview_time = 0.0;
 
-	progress.set_sample(sample + 1, total_time, sample_time);
+	progress.set_sample(sample + 1, sample_time);
 }
 
 void Session::path_trace(Tile& tile)

Modified: trunk/blender/intern/cycles/util/util_progress.h
===================================================================
--- trunk/blender/intern/cycles/util/util_progress.h	2012-01-09 16:57:26 UTC (rev 43236)
+++ trunk/blender/intern/cycles/util/util_progress.h	2012-01-09 16:57:46 UTC (rev 43237)
@@ -27,6 +27,7 @@
 
 #include "util_function.h"
 #include "util_string.h"
+#include "util_time.h"
 #include "util_thread.h"
 
 CCL_NAMESPACE_BEGIN
@@ -36,6 +37,7 @@
 	Progress()
 	{
 		sample = 0;
+		start_time = time_dt();
 		total_time = 0.0f;
 		sample_time = 0.0f;
 		status = "Initializing";
@@ -90,12 +92,19 @@
 
 	/* sample and timing information */
 
-	void set_sample(int sample_, double total_time_, double sample_time_)
+	void set_start_time(double start_time_)
 	{
 		thread_scoped_lock lock(progress_mutex);
 
+		start_time = start_time;
+	}
+
+	void set_sample(int sample_, double sample_time_)
+	{
+		thread_scoped_lock lock(progress_mutex);
+
 		sample = sample_;
-		total_time = total_time_;
+		total_time = time_dt() - start_time;
 		sample_time = sample_time_;
 	}
 
@@ -104,7 +113,7 @@
 		thread_scoped_lock lock(progress_mutex);
 
 		sample_ = sample;
-		total_time_ = total_time;
+		total_time_ = (total_time > 0.0)? total_time: 0.0;
 		sample_time_ = sample_time;
 	}
 
@@ -116,6 +125,7 @@
 			thread_scoped_lock lock(progress_mutex);
 			status = status_;
 			substatus = substatus_;
+			total_time = time_dt() - start_time;
 		}
 
 		set_update();
@@ -126,6 +136,7 @@
 		{
 			thread_scoped_lock lock(progress_mutex);
 			substatus = substatus_;
+			total_time = time_dt() - start_time;
 		}
 
 		set_update();
@@ -158,6 +169,7 @@
 
 	int sample;
 
+	double start_time;
 	double total_time;
 	double sample_time;
 



More information about the Bf-blender-cvs mailing list