[Bf-blender-cvs] [d8ce3ed140a] blender2.8: Cycles: Allow samples to finish in split kernel to avoid artifacts when canceling

Mai Lavelle noreply at git.blender.org
Wed Apr 26 21:30:42 CEST 2017


Commit: d8ce3ed140ab5e2f371cc307a0a7de3287b53724
Author: Mai Lavelle
Date:   Wed Apr 26 10:22:48 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBd8ce3ed140ab5e2f371cc307a0a7de3287b53724

Cycles: Allow samples to finish in split kernel to avoid artifacts when canceling

Previously canceling a render done by the split kernel could cause artifacts
such as very bright or dark tiles. This was caused by unfinished samples
being included in the output buffer. To avoid this we now wait till all the
currently rendering samples have finished, up to a limit of twice the
expected time for them to finish (currently this is no more than 20 seconds,
but usually its much less). If samples still haven't finished by then we
stop anyways in case there's an endless loop occurring.

===================================================================

M	intern/cycles/device/device_split_kernel.cpp

===================================================================

diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp
index 981ec74fe56..71d52bb8097 100644
--- a/intern/cycles/device/device_split_kernel.cpp
+++ b/intern/cycles/device/device_split_kernel.cpp
@@ -227,6 +227,7 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
 		ENQUEUE_SPLIT_KERNEL(path_init, global_size, local_size);
 
 		bool activeRaysAvailable = true;
+		double cancel_time = DBL_MAX;
 
 		while(activeRaysAvailable) {
 			/* Do path-iteration in host [Enqueue Path-iteration kernels. */
@@ -247,7 +248,14 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
 				ENQUEUE_SPLIT_KERNEL(queue_enqueue, global_size, local_size);
 				ENQUEUE_SPLIT_KERNEL(buffer_update, global_size, local_size);
 
-				if(task->get_cancel()) {
+				if(task->get_cancel() && cancel_time == DBL_MAX) {
+					/* Wait up to twice as many seconds for current samples to finish 
+					 * to avoid artifacts in render result from ending too soon.
+					 */
+					cancel_time = time_dt() + 2.0 * time_multiplier;
+				}
+
+				if(time_dt() > cancel_time) {
 					return true;
 				}
 			}
@@ -271,7 +279,7 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
 				}
 			}
 
-			if(task->get_cancel()) {
+			if(time_dt() > cancel_time) {
 				return true;
 			}
 		}




More information about the Bf-blender-cvs mailing list