[Bf-blender-cvs] [4bc2065] cycles_kernel_split: Cycles kernel split: De-duplicte device task logic

Sergey Sharybin noreply at git.blender.org
Sat May 9 13:30:43 CEST 2015


Commit: 4bc206548ac46d3ca51f1a237bfda9d1a4918b4b
Author: Sergey Sharybin
Date:   Sat May 9 16:29:29 2015 +0500
Branches: cycles_kernel_split
https://developer.blender.org/rB4bc206548ac46d3ca51f1a237bfda9d1a4918b4b

Cycles kernel split: De-duplicte device task logic

Move it to the base class and make thread-run virtual function.
This way we don't need to keep task-related logic in all the
derived classes.

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

M	intern/cycles/device/device_opencl.cpp

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

diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 6710315..146d15b 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -372,6 +372,7 @@ public:
 class OpenCLDeviceBase : public Device
 {
 public:
+	DedicatedTaskPool task_pool;
 	cl_context cxContext;
 	cl_command_queue cqCommandQueue;
 	cl_platform_id cpPlatform;
@@ -1083,6 +1084,39 @@ public:
 		}
 	}
 
+	class OpenCLDeviceTask : public DeviceTask {
+	public:
+		OpenCLDeviceTask(OpenCLDeviceBase *device, DeviceTask& task)
+		: DeviceTask(task)
+		{
+			run = function_bind(&OpenCLDeviceBase::thread_run,
+			                    device,
+			                    this);
+		}
+	};
+
+	int get_split_task_count(DeviceTask& /*task*/)
+	{
+		return 1;
+	}
+
+	void task_add(DeviceTask& task)
+	{
+		task_pool.push(new OpenCLDeviceTask(this, task));
+	}
+
+	void task_wait()
+	{
+		task_pool.wait();
+	}
+
+	void task_cancel()
+	{
+		task_pool.cancel();
+	}
+
+	virtual void thread_run(DeviceTask * /*task*/) = 0;
+
 protected:
 	class ArgumentWrapper {
 	public:
@@ -1209,8 +1243,6 @@ protected:
 class OpenCLDeviceMegaKernel : public OpenCLDeviceBase
 {
 public:
-	DedicatedTaskPool task_pool;
-
 	cl_kernel ckPathTraceKernel;
 	cl_program path_trace_program;
 
@@ -1394,37 +1426,6 @@ public:
 			}
 		}
 	}
-
-	class OpenCLDeviceTask : public DeviceTask {
-	public:
-		OpenCLDeviceTask(OpenCLDeviceMegaKernel *device, DeviceTask& task)
-		: DeviceTask(task)
-		{
-			run = function_bind(&OpenCLDeviceMegaKernel::thread_run,
-			                    device,
-			                    this);
-		}
-	};
-
-	int get_split_task_count(DeviceTask& /*task*/)
-	{
-		return 1;
-	}
-
-	void task_add(DeviceTask& task)
-	{
-		task_pool.push(new OpenCLDeviceTask(this, task));
-	}
-
-	void task_wait()
-	{
-		task_pool.wait();
-	}
-
-	void task_cancel()
-	{
-		task_pool.cancel();
-	}
 };
 
 /* TODO(sergey): This is to keep tile split on OpenCL level working
@@ -1488,8 +1489,6 @@ public:
 class OpenCLDeviceSplitKernel : public OpenCLDeviceBase
 {
 public:
-	DedicatedTaskPool task_pool;
-
 	/* Kernel declaration. */
 	cl_kernel ckPathTraceKernel_DataInit;
 	cl_kernel ckPathTraceKernel_SceneIntersect;
@@ -3179,35 +3178,6 @@ public:
 		}
 	}
 
-	class OpenCLDeviceTask : public DeviceTask {
-	public:
-		OpenCLDeviceTask(OpenCLDeviceSplitKernel *device, DeviceTask& task)
-			: DeviceTask(task)
-		{
-			run = function_bind(&OpenCLDeviceSplitKernel::thread_run, device, this);
-		}
-	};
-
-	int get_split_task_count(DeviceTask& /*task*/)
-	{
-		return 1;
-	}
-
-	void task_add(DeviceTask& task)
-	{
-		task_pool.push(new OpenCLDeviceTask(this, task));
-	}
-
-	void task_wait()
-	{
-		task_pool.wait();
-	}
-
-	void task_cancel()
-	{
-		task_pool.cancel();
-	}
-
 protected:
 	cl_mem mem_alloc(size_t bufsize, cl_mem_flags mem_flag = CL_MEM_READ_WRITE)
 	{




More information about the Bf-blender-cvs mailing list