[Bf-blender-cvs] [7e59bf9] cycles_kernel_split: Force kernel re-compilation check for viewport render

varunsundar08 noreply at git.blender.org
Wed Apr 15 17:37:17 CEST 2015


Commit: 7e59bf9b2d499c65d9c8e5fe57cd464b348399d5
Author: varunsundar08
Date:   Wed Apr 15 18:32:20 2015 +0530
Branches: cycles_kernel_split
https://developer.blender.org/rB7e59bf9b2d499c65d9c8e5fe57cd464b348399d5

Force kernel re-compilation check for viewport render

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

M	intern/cycles/device/device.h
M	intern/cycles/device/device_opencl.cpp
M	intern/cycles/render/session.cpp

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

diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 65af602..eca713c 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -106,6 +106,9 @@ public:
 	/* Get all closure nodes associated with the scene */
 	set<int> closure_nodes;
 
+	/* Return background */
+	bool get_background() { return background; }
+
 	/* regular memory */
 	virtual void mem_alloc(device_memory& mem, MemoryType type) = 0;
 	virtual void mem_copy_to(device_memory& mem) = 0;
diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 3fe608b..cfb54b1 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -548,6 +548,9 @@ public:
 	unsigned int max_work_groups;
 #endif
 
+	/* clos_max value for which the kernels have been loaded currently */
+	int current_clos_max;
+
 	/* Marked True in constructor and marked false at the end of path_trace() */
 	bool first_tile;
 
@@ -784,6 +787,7 @@ public:
 		work_pool_wgs = NULL;
 		max_work_groups = 0;
 #endif
+		current_clos_max = -1;
 		first_tile = true;
 
 #else
@@ -1563,6 +1567,23 @@ public:
 			}
 		}
 		svm_build_options += " ";
+
+		/* if it is an interactive render; we ceil clos_max value to a multiple of 5 in order
+		 * to limit re-compilations
+		 */
+		if (!background) {
+			/* clos_max value can't be 0  */
+			clos_max = (clos_max == 0) ? 1 : clos_max;
+			clos_max = (((clos_max - 1) / 5) + 1) * 5;
+			/* clos_max value can't be greater than MAX_CLOSURE */
+			clos_max = (clos_max > MAX_CLOSURE) ? MAX_CLOSURE : clos_max;
+
+			if (current_clos_max == clos_max) {
+				/* present kernels have been created with the same closure count build option */
+				return true;
+			}
+		}
+
 #ifdef __MULTI_CLOSURE__
 		opt += string_printf("-DMAX_CLOSURE=%d ", clos_max);
 #endif
@@ -1654,6 +1675,8 @@ public:
 		if(!load_split_kernel_SPLIT_KERNEL(&sumAllRadiance_program, kernel_path, "sumAll", device_md5, kernel_init_source, clbin, " -D__SPLIT_KERNEL__ "))
 			return false;
 
+		current_clos_max = clos_max;
+
 		kernel_init_source = "#include \"kernel.cl\" // " + kernel_md5 + "\n";
 		device_md5 = device_md5_hash("");
 		clbin = string_printf("cycles_kernel_%s_%s.clbin", device_md5.c_str(), kernel_md5.c_str());
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index 36895d4..4866043 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -616,7 +616,10 @@ void Session::load_kernels()
 {
 	thread_scoped_lock scene_lock(scene->mutex);
 
-	if(!kernels_loaded) {
+	if (!kernels_loaded || !device->get_background()) {
+		/* for split kernel, in case if interactive rendering, we
+		 * we need to check kernel-reload before doing path trace
+		 */
 		progress.set_status("Loading render kernels (may take a few minutes the first time)");
 
 		if(!device->load_kernels(params.experimental)) {




More information about the Bf-blender-cvs mailing list