[Bf-blender-cvs] [85a0c5d] master: Cycles: network render code updated for latest changes and improved

Martijn Berger noreply at git.blender.org
Sat Dec 7 17:11:45 CET 2013


Commit: 85a0c5d4e1030a5fa95ad7450958a1b0fa033381
Author: Martijn Berger
Date:   Sat Dec 7 02:29:53 2013 +0100
http://developer.blender.org/rB85a0c5d4e1030a5fa95ad7450958a1b0fa033381

Cycles: network render code updated for latest changes and improved

This actually works somewhat now, although viewport rendering is broken and any
kind of network error or connection failure will kill Blender.

* Experimental WITH_CYCLES_NETWORK cmake option
* Networked Device is shown as an option next to CPU and GPU Compute
* Various updates to work with the latest Cycles code
* Locks and thread safety for RPC calls and tiles
* Refactored pointer mapping code
* Fix error in CPU brand string retrieval code

This includes work by Doug Gale, Martijn Berger and Brecht Van Lommel.

Reviewers: brecht

Differential Revision: http://developer.blender.org/D36

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

M	CMakeLists.txt
M	intern/cycles/app/CMakeLists.txt
M	intern/cycles/app/cycles_server.cpp
M	intern/cycles/blender/CCL_api.h
M	intern/cycles/blender/addon/engine.py
M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_python.cpp
M	intern/cycles/device/CMakeLists.txt
M	intern/cycles/device/device.cpp
M	intern/cycles/device/device.h
M	intern/cycles/device/device_cpu.cpp
M	intern/cycles/device/device_cuda.cpp
M	intern/cycles/device/device_intern.h
M	intern/cycles/device/device_multi.cpp
M	intern/cycles/device/device_network.cpp
M	intern/cycles/device/device_network.h
M	intern/cycles/device/device_opencl.cpp
M	intern/cycles/render/session.cpp
M	intern/cycles/util/util_string.cpp
M	intern/cycles/util/util_string.h
M	intern/cycles/util/util_system.cpp

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ff10d9..abca0ee 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -737,6 +737,9 @@ if(UNIX AND NOT APPLE)
 			if(WITH_INTERNATIONAL)
 				list(APPEND __boost_packages locale)
 			endif()
+			if(WITH_CYCLES_NETWORK)
+				list(APPEND __boost_packages serialization)
+			endif()
 			find_package(Boost 1.48 COMPONENTS ${__boost_packages})
 			unset(__boost_packages)
 			if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU)
@@ -1700,6 +1703,9 @@ elseif(APPLE)
 			list(APPEND BOOST_LIBRARIES boost_locale-mt)
 			set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale needs it !
 		endif()
+		if(WITH_CYCLES_NETWORK)
+			list(APPEND BOOST_LIBRARIES boost_serialization-mt)
+		endif()
 		set(BOOST_LIBPATH ${BOOST}/lib)
 		set(BOOST_DEFINITIONS)
 	endif()
diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt
index ada5ea5..8a81ddd 100644
--- a/intern/cycles/app/CMakeLists.txt
+++ b/intern/cycles/app/CMakeLists.txt
@@ -30,6 +30,10 @@ set(LIBRARIES
 	${TIFF_LIBRARY}
 )
 
+if(UNIX)
+       list(APPEND LIBRARIES dl)
+endif()
+
 if(WIN32)
 	list(APPEND LIBRARIES ${PTHREADS_LIBRARIES})
 endif()
diff --git a/intern/cycles/app/cycles_server.cpp b/intern/cycles/app/cycles_server.cpp
index e80fc0c..f4cacb2 100644
--- a/intern/cycles/app/cycles_server.cpp
+++ b/intern/cycles/app/cycles_server.cpp
@@ -35,6 +35,7 @@ int main(int argc, const char **argv)
 	string devicelist = "";
 	string devicename = "cpu";
 	bool list = false;
+	int threads = 0;
 
 	vector<DeviceType>& types = Device::available_types();
 
@@ -51,6 +52,7 @@ int main(int argc, const char **argv)
 	ap.options ("Usage: cycles_server [options]",
 		"--device %s", &devicename, ("Devices to use: " + devicelist).c_str(),
 		"--list-devices", &list, "List information about all available devices",
+		"--threads %d", &threads, "Number of threads to use for CPU device",
 		NULL);
 
 	if(ap.parse(argc, argv) < 0) {
@@ -84,11 +86,11 @@ int main(int argc, const char **argv)
 		}
 	}
 
-	TaskScheduler::init();
+	TaskScheduler::init(threads);
 
 	while(1) {
 		Stats stats;
-		Device *device = Device::create(device_info, stats);
+		Device *device = Device::create(device_info, stats, true);
 		printf("Cycles Server with device: %s\n", device->info.description.c_str());
 		device->server_run();
 		delete device;
diff --git a/intern/cycles/blender/CCL_api.h b/intern/cycles/blender/CCL_api.h
index 29d8ed0..6532315 100644
--- a/intern/cycles/blender/CCL_api.h
+++ b/intern/cycles/blender/CCL_api.h
@@ -30,7 +30,7 @@ typedef struct CCLDeviceInfo {
 	int value;
 } CCLDeviceInfo;
 
-CCLDeviceInfo *CCL_compute_device_list(int opencl);
+CCLDeviceInfo *CCL_compute_device_list(int device_type);
 
 /* create python module _cycles used by addon */
 
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index 3f15e23..66dc5e7 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -88,3 +88,7 @@ def available_devices():
 def with_osl():
     import _cycles
     return _cycles.with_osl
+    
+def with_network():
+    import _cycles
+    return _cycles.with_network
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 791f1ed..f5c052e 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -25,9 +25,15 @@ from bpy.props import (BoolProperty,
 
 # enums
 
+import _cycles
+
 enum_devices = (
-    ('CPU', "CPU", "Use CPU for rendering"),
-    ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in user preferences"))
+  ('CPU', "CPU", "Use CPU for rendering"),
+  ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in user preferences"),
+  )
+
+if _cycles.with_network:
+  enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),)
 
 enum_feature_set = (
     ('SUPPORTED', "Supported", "Only use finished and supported features"),
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 14e78c4..42d5e01 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1254,6 +1254,8 @@ def draw_device(self, context):
             layout.prop(cscene, "device")
         elif device_type == 'OPENCL':
             layout.prop(cscene, "device")
+        elif device_type == 'NETWORK':
+            layout.prop(cscene, "device")
 
         if engine.with_osl() and (cscene.device == 'CPU' or device_type == 'NONE'):
             layout.prop(cscene, "shading_system")
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 71c8486..8e6bcae 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -482,12 +482,34 @@ void *CCL_python_module_init()
 	Py_INCREF(Py_False);
 #endif
 
+#ifdef WITH_NETWORK
+	PyModule_AddObject(mod, "with_network", Py_True);
+	Py_INCREF(Py_True);
+#else /* WITH_NETWORK */
+	PyModule_AddObject(mod, "with_network", Py_False);
+	Py_INCREF(Py_False);
+#endif /* WITH_NETWORK */
+
 	return (void*)mod;
 }
 
-CCLDeviceInfo *CCL_compute_device_list(int opencl)
+CCLDeviceInfo *CCL_compute_device_list(int device_type)
 {
-	ccl::DeviceType type = (opencl)? ccl::DEVICE_OPENCL: ccl::DEVICE_CUDA;
+	ccl::DeviceType type;
+	switch(device_type) {
+		case 0:
+			type = ccl::DEVICE_CUDA;
+			break;
+		case 1:
+			type = ccl::DEVICE_OPENCL;
+			break;
+		case 2:
+			type = ccl::DEVICE_NETWORK;
+			break;
+		default:
+			type = ccl::DEVICE_NONE;
+			break;
+	}
 	return ccl::compute_device_list(type);
 }
 
diff --git a/intern/cycles/device/CMakeLists.txt b/intern/cycles/device/CMakeLists.txt
index 920223d..825e822 100644
--- a/intern/cycles/device/CMakeLists.txt
+++ b/intern/cycles/device/CMakeLists.txt
@@ -26,7 +26,7 @@ set(SRC
 	device_task.cpp
 )
 
-if(WITH_NETWORK)
+if(WITH_CYCLES_NETWORK)
 	list(APPEND SRC
 		device_network.cpp
 	)
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 5c771aa..6283e34 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -127,7 +127,7 @@ Device *Device::create(DeviceInfo& info, Stats &stats, bool background)
 
 	switch(info.type) {
 		case DEVICE_CPU:
-			device = device_cpu_create(info, stats);
+			device = device_cpu_create(info, stats, background);
 			break;
 #ifdef WITH_CUDA
 		case DEVICE_CUDA:
@@ -159,9 +159,6 @@ Device *Device::create(DeviceInfo& info, Stats &stats, bool background)
 			return NULL;
 	}
 
-	if(device)
-		device->info = info;
-
 	return device;
 }
 
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 18868d1..bd309e3 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -71,7 +71,7 @@ public:
 
 class Device {
 protected:
-	Device(Stats &stats_) : stats(stats_) {}
+	Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), info(info_), stats(stats_) {}
 
 	bool background;
 	string error_msg;
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 85a7b9c..e084116 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -45,11 +45,13 @@ class CPUDevice : public Device
 public:
 	TaskPool task_pool;
 	KernelGlobals kernel_globals;
+
 #ifdef WITH_OSL
 	OSLGlobals osl_globals;
 #endif
 	
-	CPUDevice(Stats &stats) : Device(stats)
+	CPUDevice(DeviceInfo& info, Stats &stats, bool background)
+	: Device(info, stats, background)
 	{
 #ifdef WITH_OSL
 		kernel_globals.osl = &osl_globals;
@@ -401,9 +403,9 @@ public:
 	}
 };
 
-Device *device_cpu_create(DeviceInfo& info, Stats &stats)
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, bool background)
 {
-	return new CPUDevice(stats);
+	return new CPUDevice(info, stats, background);
 }
 
 void device_cpu_info(vector<DeviceInfo>& devices)
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 4ce7f6f..8db915f 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -171,7 +171,8 @@ public:
 		cuda_assert(cuCtxSetCurrent(NULL));
 	}
 
-	CUDADevice(DeviceInfo& info, Stats &stats, bool background_) : Device(stats)
+    CUDADevice(DeviceInfo& info, Stats &stats, bool background_)
+	: Device(info, stats, background_)
 	{
 		first_error = true;
 		background = background_;
diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h
index d667478..7eb66c2 100644
--- a/intern/cycles/device/device_intern.h
+++ b/intern/cycles/device/device_intern.h
@@ -21,7 +21,7 @@ CCL_NAMESPACE_BEGIN
 
 class Device;
 
-Device *device_cpu_create(DeviceInfo& info, Stats &stats);
+Device *device_cpu_create(DeviceInfo& info, Stats &stats, bool background);
 Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background);
 Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background);
 Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address);
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 4df0fdb..27b9de0 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -45,25 +45,24 @@ public:
 	device_ptr unique_ptr;
 
 	MultiDevice(DeviceInfo& info, Stats &stats, bool background_)
-	: Device(stats), unique_ptr(1)
+	: Device(info, stats, background_), unique_ptr(1)
 	{
 		Device *device;
-		background = background_;
 
 		foreach(DeviceInfo& subinfo, info.multi_devices) {
 			device = Device::create(subinfo, stats, background);
 			devices.push_back(SubDevice(device));
 		}
 
-#if 0 //def WITH_NETWORK
+#ifdef WITH_NETWORK
 		/* try to add network devices */
 		ServerDiscovery discovery(true);
 		time_sleep(1.0);
 
-		list<string> servers = discovery.get_server_list();
+		vector<string> servers = discovery.get_server_list();
 
 		foreach(string& server, servers) {
-			device = device_network_create(info, server.c_str());
+			device = device_network_create(info, stats, server.c_str());
 			if(device)
 				devices.push_back(SubDevice(device

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list