[Bf-blender-cvs] [80837d0] master: Cycles: Support earlier tile rendering termination on cancel

Sergey Sharybin noreply at git.blender.org
Thu Sep 29 16:01:44 CEST 2016


Commit: 80837d06decac612ec5dac68eca033292fcb4762
Author: Sergey Sharybin
Date:   Thu Sep 29 16:00:25 2016 +0200
Branches: master
https://developer.blender.org/rB80837d06decac612ec5dac68eca033292fcb4762

Cycles: Support earlier tile rendering termination on cancel

It will discard the whole tile, but it's still kind of more friendly than
fully locked interface (sort of) for until tile is fully sampled.

Sorry if it causes PITA to merge for the opencl split work, but this issue
bothering a lot when collecting benchmarks.

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

M	intern/cycles/device/device_opencl.cpp

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

diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index c43a387..830e4d0 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -2346,7 +2346,9 @@ public:
 		}
 	}
 
-	void path_trace(SplitRenderTile& rtile, int2 max_render_feasible_tile_size)
+	void path_trace(DeviceTask *task,
+	                SplitRenderTile& rtile,
+	                int2 max_render_feasible_tile_size)
 	{
 		/* cast arguments to cl types */
 		cl_mem d_data = CL_MEM_PTR(const_mem_map["__data"]->device_pointer);
@@ -2739,6 +2741,7 @@ public:
 		/* Record number of time host intervention has been made */
 		unsigned int numHostIntervention = 0;
 		unsigned int numNextPathIterTimes = PathIteration_times;
+		bool canceled = false;
 		while(activeRaysAvailable) {
 			/* Twice the global work size of other kernels for
 			 * ckPathTraceKernel_shadow_blocked_direct_lighting. */
@@ -2757,6 +2760,10 @@ public:
 				ENQUEUE_SPLIT_KERNEL(direct_lighting, global_size, local_size);
 				ENQUEUE_SPLIT_KERNEL(shadow_blocked, global_size_shadow_blocked, local_size);
 				ENQUEUE_SPLIT_KERNEL(next_iteration_setup, global_size, local_size);
+				if(task->get_cancel()) {
+					canceled = true;
+					break;
+				}
 			}
 
 			/* Read ray-state into Host memory to decide if we should exit
@@ -2794,22 +2801,28 @@ public:
 				 */
 				numNextPathIterTimes += PATH_ITER_INC_FACTOR;
 			}
+			if(task->get_cancel()) {
+				canceled = true;
+				break;
+			}
 		}
 
 		/* Execute SumALLRadiance kernel to accumulate radiance calculated in
 		 * per_sample_output_buffers into RenderTile's output buffer.
 		 */
-		size_t sum_all_radiance_local_size[2] = {16, 16};
-		size_t sum_all_radiance_global_size[2];
-		sum_all_radiance_global_size[0] =
-			(((d_w - 1) / sum_all_radiance_local_size[0]) + 1) *
-			sum_all_radiance_local_size[0];
-		sum_all_radiance_global_size[1] =
-			(((d_h - 1) / sum_all_radiance_local_size[1]) + 1) *
-			sum_all_radiance_local_size[1];
-		ENQUEUE_SPLIT_KERNEL(sum_all_radiance,
-		                     sum_all_radiance_global_size,
-		                     sum_all_radiance_local_size);
+		if (!canceled) {
+			size_t sum_all_radiance_local_size[2] = {16, 16};
+			size_t sum_all_radiance_global_size[2];
+			sum_all_radiance_global_size[0] =
+				(((d_w - 1) / sum_all_radiance_local_size[0]) + 1) *
+				sum_all_radiance_local_size[0];
+			sum_all_radiance_global_size[1] =
+				(((d_h - 1) / sum_all_radiance_local_size[1]) + 1) *
+				sum_all_radiance_local_size[1];
+			ENQUEUE_SPLIT_KERNEL(sum_all_radiance,
+			                     sum_all_radiance_global_size,
+			                     sum_all_radiance_local_size);
+		}
 
 #undef ENQUEUE_SPLIT_KERNEL
 #undef GLUE
@@ -3182,7 +3195,8 @@ public:
 					    tile_iter < to_path_trace_render_tiles.size();
 					    ++tile_iter)
 					{
-						path_trace(to_path_trace_render_tiles[tile_iter],
+						path_trace(task,
+						           to_path_trace_render_tiles[tile_iter],
 						           max_render_feasible_tile_size);
 					}
 				}
@@ -3198,7 +3212,7 @@ public:
 					/* buffer_rng_state_stride is stride itself. */
 					SplitRenderTile split_tile(tile);
 					split_tile.buffer_rng_state_stride = tile.stride;
-					path_trace(split_tile, max_render_feasible_tile_size);
+					path_trace(task, split_tile, max_render_feasible_tile_size);
 				}
 				tile.sample = tile.start_sample + tile.num_samples;




More information about the Bf-blender-cvs mailing list