[Bf-blender-cvs] [02fc6ef] bake-cycles: Cycles-Bake: Cycles changes for shader evaluation to support cancelling via progress cancel callback

Dalai Felinto noreply at git.blender.org
Tue Apr 29 18:34:21 CEST 2014


Commit: 02fc6ef180e5e50519e3fd3ae48343519bffea2e
Author: Dalai Felinto
Date:   Mon Apr 28 17:10:52 2014 -0300
https://developer.blender.org/rB02fc6ef180e5e50519e3fd3ae48343519bffea2e

Cycles-Bake: Cycles changes for shader evaluation to support cancelling via progress cancel callback

I would like to hear from Brecht on that one. Currently I'm changing
only device_cpu, but if this is correct we will need to change the other
devices as well (though I can't test here - no GPU - so I would rather
doing that with someone that can test it).

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

M	intern/cycles/device/device_cpu.cpp
M	intern/cycles/render/bake.cpp
M	intern/cycles/render/light.cpp
M	intern/cycles/render/mesh_displace.cpp

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

diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index e14e403..c9cc759 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -395,7 +395,7 @@ public:
 			for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
 				kernel_cpu_avx_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
 
-				if(task_pool.canceled())
+				if(task.get_cancel() || task_pool.canceled())
 					break;
 			}
 		}
@@ -406,7 +406,7 @@ public:
 			for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
 				kernel_cpu_sse41_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
 
-				if(task_pool.canceled())
+				if(task.get_cancel() || task_pool.canceled())
 					break;
 			}
 		}
@@ -417,7 +417,7 @@ public:
 			for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
 				kernel_cpu_sse3_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
 
-				if(task_pool.canceled())
+				if(task.get_cancel() || task_pool.canceled())
 					break;
 			}
 		}
@@ -428,7 +428,7 @@ public:
 			for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
 				kernel_cpu_sse2_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
 
-				if(task_pool.canceled())
+				if(task.get_cancel() || task_pool.canceled())
 					break;
 			}
 		}
@@ -438,7 +438,7 @@ public:
 			for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) {
 				kernel_cpu_shader(&kg, (uint4*)task.shader_input, (float4*)task.shader_output, task.shader_eval_type, x);
 
-				if(task_pool.canceled())
+				if(task.get_cancel() || task_pool.canceled())
 					break;
 			}
 		}
diff --git a/intern/cycles/render/bake.cpp b/intern/cycles/render/bake.cpp
index b910e19..2e3022e 100644
--- a/intern/cycles/render/bake.cpp
+++ b/intern/cycles/render/bake.cpp
@@ -129,6 +129,7 @@ bool BakeManager::bake(Device *device, DeviceScene *dscene, Scene *scene, Progre
 	task.shader_eval_type = shader_type;
 	task.shader_x = 0;
 	task.shader_w = d_output.size();
+	task.get_cancel = function_bind(&Progress::get_cancel, &progress);
 
 	device->task_add(task);
 	device->task_wait();
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index cfc4f55..843472a 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -29,7 +29,7 @@
 
 CCL_NAMESPACE_BEGIN
 
-static void shade_background_pixels(Device *device, DeviceScene *dscene, int res, vector<float3>& pixels)
+static void shade_background_pixels(Device *device, DeviceScene *dscene, int res, vector<float3>& pixels, Progress& progress)
 {
 	/* create input */
 	int width = res;
@@ -66,6 +66,7 @@ static void shade_background_pixels(Device *device, DeviceScene *dscene, int res
 	main_task.shader_eval_type = SHADER_EVAL_BACKGROUND;
 	main_task.shader_x = 0;
 	main_task.shader_w = width*height;
+	main_task.get_cancel = function_bind(&Progress::get_cancel, &progress);
 
 	/* disabled splitting for now, there's an issue with multi-GPU mem_copy_from */
 	list<DeviceTask> split_tasks;
@@ -397,7 +398,7 @@ void LightManager::device_update_background(Device *device, DeviceScene *dscene,
 	assert(res > 0);
 
 	vector<float3> pixels;
-	shade_background_pixels(device, dscene, res, pixels);
+	shade_background_pixels(device, dscene, res, pixels, progress);
 
 	if(progress.get_cancel())
 		return;
diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp
index 09d3ce6..8354200 100644
--- a/intern/cycles/render/mesh_displace.cpp
+++ b/intern/cycles/render/mesh_displace.cpp
@@ -119,6 +119,7 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me
 	task.shader_eval_type = SHADER_EVAL_DISPLACE;
 	task.shader_x = 0;
 	task.shader_w = d_output.size();
+	task.get_cancel = function_bind(&Progress::get_cancel, &progress);
 
 	device->task_add(task);
 	device->task_wait();




More information about the Bf-blender-cvs mailing list